blob: 0a423bc0013541192c3512e0a5aec16466517097 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/resource_coordinator/time.h"
#include "base/logging.h"
#include "base/time/tick_clock.h"
namespace resource_coordinator {
namespace {
base::TickClock* g_tick_clock_for_testing = nullptr;
} // namespace
base::TimeTicks NowTicks() {
return g_tick_clock_for_testing ? g_tick_clock_for_testing->NowTicks()
: base::TimeTicks::Now();
}
base::TickClock* GetTickClock() {
return g_tick_clock_for_testing;
}
ScopedSetTickClockForTesting::ScopedSetTickClockForTesting(
base::TickClock* tick_clock) {
DCHECK(!g_tick_clock_for_testing);
g_tick_clock_for_testing = tick_clock;
}
ScopedSetTickClockForTesting::~ScopedSetTickClockForTesting() {
g_tick_clock_for_testing = nullptr;
}
} // namespace resource_coordinator