Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / base / test / mock_time_provider.cc
blob9e5547fcd94119e3b2978f6c2c41fe5687708cb5
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/logging.h"
6 #include "base/test/mock_time_provider.h"
8 using ::testing::DefaultValue;
10 namespace base {
12 MockTimeProvider* MockTimeProvider::instance_ = NULL;
14 MockTimeProvider::MockTimeProvider() {
15 DCHECK(!instance_) << "Only one instance of MockTimeProvider can exist";
16 DCHECK(!DefaultValue<Time>::IsSet());
17 instance_ = this;
18 DefaultValue<Time>::Set(Time::FromInternalValue(0));
21 MockTimeProvider::~MockTimeProvider() {
22 instance_ = NULL;
23 DefaultValue<Time>::Clear();
26 // static
27 Time MockTimeProvider::StaticNow() {
28 return instance_->Now();
31 } // namespace base