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

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

Issue 1352523002: Use high precision timestamp for Event.timestamp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
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 double toSafePrecisionTime(double timeInSeconds)
419 {
420 static const double precision = 0.000005; // in seconds
421 return floor(timeInSeconds / precision) * precision;
422 }
423
418 double PerformanceBase::now() const 424 double PerformanceBase::now() const
419 { 425 {
420 double nowSeconds = monotonicallyIncreasingTime() - m_timeOrigin; 426 double nowSeconds = monotonicallyIncreasingTime() - m_timeOrigin;
421 const double resolutionSeconds = 0.000005; 427 return 1000.0 * toSafePrecisionTime(nowSeconds);
422 return 1000.0 * floor(nowSeconds / resolutionSeconds) * resolutionSeconds;
423 } 428 }
424 429
425 DEFINE_TRACE(PerformanceBase) 430 DEFINE_TRACE(PerformanceBase)
426 { 431 {
427 visitor->trace(m_frameTimingBuffer); 432 visitor->trace(m_frameTimingBuffer);
428 visitor->trace(m_resourceTimingBuffer); 433 visitor->trace(m_resourceTimingBuffer);
429 visitor->trace(m_userTiming); 434 visitor->trace(m_userTiming);
430 visitor->trace(m_observers); 435 visitor->trace(m_observers);
431 visitor->trace(m_activeObservers); 436 visitor->trace(m_activeObservers);
432 visitor->trace(m_suspendedObservers); 437 visitor->trace(m_suspendedObservers);
433 RefCountedGarbageCollectedEventTargetWithInlineData<PerformanceBase>::trace( visitor); 438 RefCountedGarbageCollectedEventTargetWithInlineData<PerformanceBase>::trace( visitor);
434 } 439 }
435 440
436 } // namespace blink 441 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698