| 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..6d9587ff92b32a44439f346f879de01133e4366d
|
| --- /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/test/scoped_time_controller.h"
|
| +
|
| +namespace base {
|
| +namespace test {
|
| +
|
| +ScopedTimeController::ScopedTimeController() {
|
| + replaced_instance_ = TimeFactory::instance_;
|
| + TimeFactory::instance_ = this;
|
| +}
|
| +
|
| +ScopedTimeController::~ScopedTimeController() {
|
| + TimeFactory::instance_ = replaced_instance_;
|
| +}
|
| +
|
| +void ScopedTimeController::Advance(base::TimeDelta delta) {
|
| + current_time_ += delta;
|
| + current_timeticks_ += delta;
|
| +}
|
| +
|
| +Time ScopedTimeController::TimeNow() {
|
| + return current_time_;
|
| +}
|
| +
|
| +TimeTicks ScopedTimeController::TimeTicksNow() {
|
| + return current_timeticks_;
|
| +}
|
| +
|
| +TimeTicks ScopedTimeController::TimeTicksHighResNow() {
|
| + return current_timeticks_;
|
| +}
|
| +
|
| +} // namespace base
|
| +} // namespace test
|
|
|