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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/http/tests/misc/webtiming-resolution-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 314
315 void PerformanceBase::clearMeasures(const String& measureName) 315 void PerformanceBase::clearMeasures(const String& measureName)
316 { 316 {
317 if (!m_userTiming) 317 if (!m_userTiming)
318 m_userTiming = UserTiming::create(this); 318 m_userTiming = UserTiming::create(this);
319 m_userTiming->clearMeasures(measureName); 319 m_userTiming->clearMeasures(measureName);
320 } 320 }
321 321
322 double PerformanceBase::now() const 322 double PerformanceBase::now() const
323 { 323 {
324 return 1000.0 * (monotonicallyIncreasingTime() - m_timeOrigin); 324 double nowSeconds = monotonicallyIncreasingTime() - m_timeOrigin;
325 const double resolutionSeconds = 0.000005;
326 return 1000.0 * floor(nowSeconds / resolutionSeconds) * resolutionSeconds;
325 } 327 }
326 328
327 DEFINE_TRACE(PerformanceBase) 329 DEFINE_TRACE(PerformanceBase)
328 { 330 {
329 visitor->trace(m_frameTimingBuffer); 331 visitor->trace(m_frameTimingBuffer);
330 visitor->trace(m_resourceTimingBuffer); 332 visitor->trace(m_resourceTimingBuffer);
331 visitor->trace(m_userTiming); 333 visitor->trace(m_userTiming);
332 EventTargetWithInlineData::trace(visitor); 334 EventTargetWithInlineData::trace(visitor);
333 } 335 }
334 336
335 } // namespace blink 337 } // namespace blink
OLDNEW
« 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