| 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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 observer->Deliver(); | 498 observer->Deliver(); |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 | 501 |
| 502 // static | 502 // static |
| 503 double PerformanceBase::ClampTimeResolution(double time_seconds) { | 503 double PerformanceBase::ClampTimeResolution(double time_seconds) { |
| 504 const double kResolutionSeconds = 0.000005; | 504 const double kResolutionSeconds = 0.000005; |
| 505 return floor(time_seconds / kResolutionSeconds) * kResolutionSeconds; | 505 return floor(time_seconds / kResolutionSeconds) * kResolutionSeconds; |
| 506 } | 506 } |
| 507 | 507 |
| 508 // static |
| 508 DOMHighResTimeStamp PerformanceBase::MonotonicTimeToDOMHighResTimeStamp( | 509 DOMHighResTimeStamp PerformanceBase::MonotonicTimeToDOMHighResTimeStamp( |
| 509 double time_origin, | 510 double time_origin, |
| 510 double monotonic_time) { | 511 double monotonic_time, |
| 512 bool allow_negative_value) { |
| 511 // Avoid exposing raw platform timestamps. | 513 // Avoid exposing raw platform timestamps. |
| 512 if (!monotonic_time || !time_origin) | 514 if (!monotonic_time || !time_origin) |
| 513 return 0.0; | 515 return 0.0; |
| 514 | 516 |
| 515 double time_in_seconds = monotonic_time - time_origin; | 517 double time_in_seconds = monotonic_time - time_origin; |
| 516 if (time_in_seconds < 0) | 518 if (time_in_seconds < 0 && !allow_negative_value) |
| 517 return 0.0; | 519 return 0.0; |
| 518 return ConvertSecondsToDOMHighResTimeStamp( | 520 return ConvertSecondsToDOMHighResTimeStamp( |
| 519 ClampTimeResolution(time_in_seconds)); | 521 ClampTimeResolution(time_in_seconds)); |
| 520 } | 522 } |
| 521 | 523 |
| 522 DOMHighResTimeStamp PerformanceBase::MonotonicTimeToDOMHighResTimeStamp( | 524 DOMHighResTimeStamp PerformanceBase::MonotonicTimeToDOMHighResTimeStamp( |
| 523 double monotonic_time) const { | 525 double monotonic_time) const { |
| 524 return MonotonicTimeToDOMHighResTimeStamp(time_origin_, monotonic_time); | 526 return MonotonicTimeToDOMHighResTimeStamp(time_origin_, monotonic_time, |
| 527 false /* allow_negative_value */); |
| 525 } | 528 } |
| 526 | 529 |
| 527 DOMHighResTimeStamp PerformanceBase::now() const { | 530 DOMHighResTimeStamp PerformanceBase::now() const { |
| 528 return MonotonicTimeToDOMHighResTimeStamp(MonotonicallyIncreasingTime()); | 531 return MonotonicTimeToDOMHighResTimeStamp(MonotonicallyIncreasingTime()); |
| 529 } | 532 } |
| 530 | 533 |
| 531 DEFINE_TRACE(PerformanceBase) { | 534 DEFINE_TRACE(PerformanceBase) { |
| 532 visitor->Trace(frame_timing_buffer_); | 535 visitor->Trace(frame_timing_buffer_); |
| 533 visitor->Trace(resource_timing_buffer_); | 536 visitor->Trace(resource_timing_buffer_); |
| 534 visitor->Trace(navigation_timing_); | 537 visitor->Trace(navigation_timing_); |
| 535 visitor->Trace(user_timing_); | 538 visitor->Trace(user_timing_); |
| 536 visitor->Trace(observers_); | 539 visitor->Trace(observers_); |
| 537 visitor->Trace(active_observers_); | 540 visitor->Trace(active_observers_); |
| 538 visitor->Trace(suspended_observers_); | 541 visitor->Trace(suspended_observers_); |
| 539 EventTargetWithInlineData::Trace(visitor); | 542 EventTargetWithInlineData::Trace(visitor); |
| 540 } | 543 } |
| 541 | 544 |
| 542 } // namespace blink | 545 } // namespace blink |
| OLD | NEW |