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

Unified Diff: third_party/WebKit/Source/wtf/CurrentTime.cpp

Issue 1550563002: Blink Platform: Remove time functions from Platform. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merrrge agaaain. Created 4 years, 10 months 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
« no previous file with comments | « third_party/WebKit/Source/wtf/CurrentTime.h ('k') | third_party/WebKit/Source/wtf/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/CurrentTime.cpp
diff --git a/third_party/WebKit/Source/wtf/CurrentTime.cpp b/third_party/WebKit/Source/wtf/CurrentTime.cpp
index c29636f98c9cc551ec735476ecca99893408a8a3..dc64e33663f4e558739a699d96be1a4519a2098d 100644
--- a/third_party/WebKit/Source/wtf/CurrentTime.cpp
+++ b/third_party/WebKit/Source/wtf/CurrentTime.cpp
@@ -30,29 +30,31 @@
#include "wtf/CurrentTime.h"
-namespace WTF {
+#include "base/time/time.h"
-static TimeFunction currentTimeFunction;
-static TimeFunction monotonicallyIncreasingTimeFunction;
+namespace WTF {
-void setCurrentTimeFunction(TimeFunction func)
-{
- currentTimeFunction = func;
-}
+static TimeFunction mockTimeFunctionForTesting = nullptr;
-void setMonotonicallyIncreasingTimeFunction(TimeFunction func)
+double currentTime()
{
- monotonicallyIncreasingTimeFunction = func;
+ if (mockTimeFunctionForTesting)
+ return mockTimeFunctionForTesting();
+ return base::Time::Now().ToDoubleT();
}
-double currentTime()
+double monotonicallyIncreasingTime()
{
- return (*currentTimeFunction)();
+ if (mockTimeFunctionForTesting)
+ return mockTimeFunctionForTesting();
+ return base::TimeTicks::Now().ToInternalValue() / static_cast<double>(base::Time::kMicrosecondsPerSecond);
}
-double monotonicallyIncreasingTime()
+TimeFunction setTimeFunctionsForTesting(TimeFunction newFunction)
{
- return (*monotonicallyIncreasingTimeFunction)();
+ TimeFunction oldFunction = mockTimeFunctionForTesting;
+ mockTimeFunctionForTesting = newFunction;
+ return oldFunction;
}
} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/CurrentTime.h ('k') | third_party/WebKit/Source/wtf/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698