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

Side by Side Diff: third_party/WebKit/Source/core/timing/PerformanceBase.cpp

Issue 1361803003: Clamp resolution of requestIdleCallback timeRemaining() to 5us. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rIC_histograms
Patch Set: Rebase Created 5 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/timing/PerformanceBase.h ('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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 copyToVector(m_activeObservers, observers); 408 copyToVector(m_activeObservers, observers);
409 m_activeObservers.clear(); 409 m_activeObservers.clear();
410 for (size_t i = 0; i < observers.size(); ++i) { 410 for (size_t i = 0; i < observers.size(); ++i) {
411 if (observers[i]->shouldBeSuspended()) 411 if (observers[i]->shouldBeSuspended())
412 m_suspendedObservers.add(observers[i]); 412 m_suspendedObservers.add(observers[i]);
413 else 413 else
414 observers[i]->deliver(); 414 observers[i]->deliver();
415 } 415 }
416 } 416 }
417 417
418 // static
419 double PerformanceBase::clampTimeResolution(double timeSeconds)
420 {
421 const double resolutionSeconds = 0.000005;
422 return floor(timeSeconds / resolutionSeconds) * resolutionSeconds;
423 }
424
418 double PerformanceBase::now() const 425 double PerformanceBase::now() const
419 { 426 {
420 double nowSeconds = monotonicallyIncreasingTime() - m_timeOrigin; 427 double nowSeconds = monotonicallyIncreasingTime() - m_timeOrigin;
421 const double resolutionSeconds = 0.000005; 428 return 1000.0 * clampTimeResolution(nowSeconds);
422 return 1000.0 * floor(nowSeconds / resolutionSeconds) * resolutionSeconds;
423 } 429 }
424 430
425 DEFINE_TRACE(PerformanceBase) 431 DEFINE_TRACE(PerformanceBase)
426 { 432 {
427 visitor->trace(m_frameTimingBuffer); 433 visitor->trace(m_frameTimingBuffer);
428 visitor->trace(m_resourceTimingBuffer); 434 visitor->trace(m_resourceTimingBuffer);
429 visitor->trace(m_userTiming); 435 visitor->trace(m_userTiming);
430 visitor->trace(m_observers); 436 visitor->trace(m_observers);
431 visitor->trace(m_activeObservers); 437 visitor->trace(m_activeObservers);
432 visitor->trace(m_suspendedObservers); 438 visitor->trace(m_suspendedObservers);
433 RefCountedGarbageCollectedEventTargetWithInlineData<PerformanceBase>::trace( visitor); 439 RefCountedGarbageCollectedEventTargetWithInlineData<PerformanceBase>::trace( visitor);
434 } 440 }
435 441
436 } // namespace blink 442 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/timing/PerformanceBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698