Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 observer->deliver(); | 562 observer->deliver(); |
| 563 } | 563 } |
| 564 } | 564 } |
| 565 | 565 |
| 566 // static | 566 // static |
| 567 double PerformanceBase::clampTimeResolution(double timeSeconds) { | 567 double PerformanceBase::clampTimeResolution(double timeSeconds) { |
| 568 const double resolutionSeconds = 0.000005; | 568 const double resolutionSeconds = 0.000005; |
| 569 return floor(timeSeconds / resolutionSeconds) * resolutionSeconds; | 569 return floor(timeSeconds / resolutionSeconds) * resolutionSeconds; |
| 570 } | 570 } |
| 571 | 571 |
| 572 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp( | 572 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp( |
|
skobes
2017/01/13 22:31:44
I suggest adding a comment to the declaration of t
sunjian
2017/01/14 01:04:32
Done. I don't think anyone else violates the DCHEC
| |
| 573 double timeOrigin, | 573 double timeOrigin, |
| 574 double monotonicTime) { | 574 double monotonicTime) { |
| 575 // Avoid exposing raw platform timestamps. | 575 // Avoid exposing raw platform timestamps. |
| 576 if (!monotonicTime || !timeOrigin) | 576 if (!monotonicTime || !timeOrigin) |
| 577 return 0.0; | 577 return 0.0; |
| 578 | 578 |
| 579 double timeInSeconds = monotonicTime - timeOrigin; | 579 double timeInSeconds = monotonicTime - timeOrigin; |
| 580 if (timeInSeconds < 0) | 580 DCHECK_GE(timeInSeconds, 0); |
| 581 return 0.0; | |
| 582 return convertSecondsToDOMHighResTimeStamp( | 581 return convertSecondsToDOMHighResTimeStamp( |
| 583 clampTimeResolution(timeInSeconds)); | 582 clampTimeResolution(timeInSeconds)); |
| 584 } | 583 } |
| 585 | 584 |
| 586 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp( | 585 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp( |
| 587 double monotonicTime) const { | 586 double monotonicTime) const { |
| 588 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, monotonicTime); | 587 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, monotonicTime); |
| 589 } | 588 } |
| 590 | 589 |
| 591 DOMHighResTimeStamp PerformanceBase::now() const { | 590 DOMHighResTimeStamp PerformanceBase::now() const { |
| 592 return monotonicTimeToDOMHighResTimeStamp(monotonicallyIncreasingTime()); | 591 return monotonicTimeToDOMHighResTimeStamp(monotonicallyIncreasingTime()); |
| 593 } | 592 } |
| 594 | 593 |
| 595 DEFINE_TRACE(PerformanceBase) { | 594 DEFINE_TRACE(PerformanceBase) { |
| 596 visitor->trace(m_frameTimingBuffer); | 595 visitor->trace(m_frameTimingBuffer); |
| 597 visitor->trace(m_resourceTimingBuffer); | 596 visitor->trace(m_resourceTimingBuffer); |
| 598 visitor->trace(m_navigationTiming); | 597 visitor->trace(m_navigationTiming); |
| 599 visitor->trace(m_userTiming); | 598 visitor->trace(m_userTiming); |
| 600 visitor->trace(m_observers); | 599 visitor->trace(m_observers); |
| 601 visitor->trace(m_activeObservers); | 600 visitor->trace(m_activeObservers); |
| 602 visitor->trace(m_suspendedObservers); | 601 visitor->trace(m_suspendedObservers); |
| 603 EventTargetWithInlineData::trace(visitor); | 602 EventTargetWithInlineData::trace(visitor); |
| 604 } | 603 } |
| 605 | 604 |
| 606 } // namespace blink | 605 } // namespace blink |
| OLD | NEW |