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

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

Issue 1936853002: Assert event timestamp to be monotonic and not from future Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change to histogram Created 4 years, 2 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/testing/RunAllTests.cpp » ('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 dc64e33663f4e558739a699d96be1a4519a2098d..03f0771c01a2b5c57df941085551b3a72f2cf858 100644
--- a/third_party/WebKit/Source/wtf/CurrentTime.cpp
+++ b/third_party/WebKit/Source/wtf/CurrentTime.cpp
@@ -34,27 +34,36 @@
namespace WTF {
-static TimeFunction mockTimeFunctionForTesting = nullptr;
+static TimeFunction mockCurrentTimeFunction = nullptr;
+static TimeFunction mockMonotonicallyIncreasingTimeFunction = nullptr;
double currentTime()
{
- if (mockTimeFunctionForTesting)
- return mockTimeFunctionForTesting();
+ if (mockCurrentTimeFunction)
+ return mockCurrentTimeFunction();
return base::Time::Now().ToDoubleT();
}
double monotonicallyIncreasingTime()
{
- if (mockTimeFunctionForTesting)
- return mockTimeFunctionForTesting();
+ if (mockMonotonicallyIncreasingTimeFunction)
+ return mockMonotonicallyIncreasingTimeFunction();
return base::TimeTicks::Now().ToInternalValue() / static_cast<double>(base::Time::kMicrosecondsPerSecond);
}
-TimeFunction setTimeFunctionsForTesting(TimeFunction newFunction)
+TimeFunction setCurrentTimeFunctionForTesting(TimeFunction newFunction)
{
- TimeFunction oldFunction = mockTimeFunctionForTesting;
- mockTimeFunctionForTesting = newFunction;
+ TimeFunction oldFunction = mockCurrentTimeFunction;
+ mockCurrentTimeFunction = newFunction;
return oldFunction;
}
+TimeFunction setMonotonicallyIncreasingTimeFunctionForTesting(TimeFunction newFunction)
+{
+ TimeFunction oldFunction = mockMonotonicallyIncreasingTimeFunction;
+ mockMonotonicallyIncreasingTimeFunction = newFunction;
+ return oldFunction;
+}
+
+
} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/CurrentTime.h ('k') | third_party/WebKit/Source/wtf/testing/RunAllTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698