| Index: base/test/scoped_time_controller.cc
|
| diff --git a/base/test/scoped_time_controller.cc b/base/test/scoped_time_controller.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..32aba03f9c40a68788990a2854c7e3e001b47ecd
|
| --- /dev/null
|
| +++ b/base/test/scoped_time_controller.cc
|
| @@ -0,0 +1,37 @@
|
| +// Copyright (c) 2011 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 "base/logging.h"
|
| +#include "base/test/scoped_time_controller.h"
|
| +
|
| +namespace base {
|
| +namespace test {
|
| +
|
| +ScopedTimeController::ScopedTimeController()
|
| + : current_time_(Time::Now()),
|
| + current_timeticks_(TimeTicks::Now()) {
|
| + replaced_instance_ = TimeFactory::instance_;
|
| + TimeFactory::instance_ = this;
|
| +}
|
| +
|
| +ScopedTimeController::~ScopedTimeController() {
|
| + TimeFactory::instance_ = replaced_instance_;
|
| +}
|
| +
|
| +void ScopedTimeController::Advance(base::TimeDelta delta) {
|
| + DCHECK(delta >= base::TimeDelta());
|
| + current_time_ += delta;
|
| + current_timeticks_ += delta;
|
| +}
|
| +
|
| +Time ScopedTimeController::TimeNow() {
|
| + return current_time_;
|
| +}
|
| +
|
| +TimeTicks ScopedTimeController::TimeTicksNow() {
|
| + return current_timeticks_;
|
| +}
|
| +
|
| +} // namespace base
|
| +} // namespace test
|
|
|