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

Unified Diff: Source/core/timing/PerformanceBase.cpp

Issue 1214063008: Reduce resolution of performance.now to prevent timing attacks (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 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 | « LayoutTests/http/tests/misc/webtiming-resolution-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/timing/PerformanceBase.cpp
diff --git a/Source/core/timing/PerformanceBase.cpp b/Source/core/timing/PerformanceBase.cpp
index 59e29deb265334541ee8d8745f105481ffffc844..219f3f5b51331991db0f63fb8f2a52bb9ffdd724 100644
--- a/Source/core/timing/PerformanceBase.cpp
+++ b/Source/core/timing/PerformanceBase.cpp
@@ -321,7 +321,9 @@ void PerformanceBase::clearMeasures(const String& measureName)
double PerformanceBase::now() const
{
- return 1000.0 * (monotonicallyIncreasingTime() - m_timeOrigin);
+ double nowSeconds = monotonicallyIncreasingTime() - m_timeOrigin;
+ const double resolutionSeconds = 0.000005;
+ return 1000.0 * floor(nowSeconds / resolutionSeconds) * resolutionSeconds;
}
DEFINE_TRACE(PerformanceBase)
« no previous file with comments | « LayoutTests/http/tests/misc/webtiming-resolution-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698