Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(421)

Unified Diff: base/default_clock.cc

Issue 11607003: Add a Clock and TickClock interface for mocking out time (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/default_clock.cc
diff --git a/base/default_clock.cc b/base/default_clock.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a2c20cd1100834777790bd5c89fa54888681f201
--- /dev/null
+++ b/base/default_clock.cc
@@ -0,0 +1,27 @@
+// Copyright (c) 2012 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/default_clock.h"
+#include "base/lazy_instance.h"
+
+namespace base {
+
+namespace {
+
+LazyInstance<DefaultClock> default_clock = LAZY_INSTANCE_INITIALIZER;
Ryan Sleevi 2012/12/17 19:54:46 DESIGN: Should this be Leaky, to match the worker-
awong 2012/12/17 19:55:11 nit: g_default_clock
akalin 2012/12/17 22:38:31 Brett didn't like the lazy instance, so I removed
akalin 2012/12/17 22:38:31 removed lazy instance
+
+} // namespace
+
+DefaultClock::~DefaultClock() {}
+
+Time DefaultClock::Now() {
+ return Time::Now();
+}
+
+// static
+DefaultClock* DefaultClock::Get() {
+ return default_clock.Pointer();
+}
+
+} // namespace base
« no previous file with comments | « base/default_clock.h ('k') | base/default_tick_clock.h » ('j') | base/default_tick_clock.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698