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

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

Issue 2615533002: Remove duplicate domHighResTimestamp conversion in NavigationTiming (Closed)
Patch Set: Created 3 years, 11 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 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 } 546 }
547 } 547 }
548 548
549 // static 549 // static
550 double PerformanceBase::clampTimeResolution(double timeSeconds) { 550 double PerformanceBase::clampTimeResolution(double timeSeconds) {
551 const double resolutionSeconds = 0.000005; 551 const double resolutionSeconds = 0.000005;
552 return floor(timeSeconds / resolutionSeconds) * resolutionSeconds; 552 return floor(timeSeconds / resolutionSeconds) * resolutionSeconds;
553 } 553 }
554 554
555 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp( 555 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp(
556 double timeOrigin,
557 double monotonicTime) {
558 // Avoid exposing raw platform timestamps.
559 if (timeOrigin == 0.0)
560 return 0.0;
561
562 double timeInSeconds = monotonicTime - timeOrigin;
563 return convertSecondsToDOMHighResTimeStamp(
564 clampTimeResolution(timeInSeconds));
565 }
566
567 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp(
556 double monotonicTime) const { 568 double monotonicTime) const {
557 // Avoid exposing raw platform timestamps. 569 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, monotonicTime);
558 if (m_timeOrigin == 0.0)
559 return 0.0;
560
561 double timeInSeconds = monotonicTime - m_timeOrigin;
562 return convertSecondsToDOMHighResTimeStamp(
563 clampTimeResolution(timeInSeconds));
564 } 570 }
565 571
566 DOMHighResTimeStamp PerformanceBase::now() const { 572 DOMHighResTimeStamp PerformanceBase::now() const {
567 return monotonicTimeToDOMHighResTimeStamp(monotonicallyIncreasingTime()); 573 return monotonicTimeToDOMHighResTimeStamp(monotonicallyIncreasingTime());
568 } 574 }
569 575
570 DEFINE_TRACE(PerformanceBase) { 576 DEFINE_TRACE(PerformanceBase) {
571 visitor->trace(m_frameTimingBuffer); 577 visitor->trace(m_frameTimingBuffer);
572 visitor->trace(m_resourceTimingBuffer); 578 visitor->trace(m_resourceTimingBuffer);
573 visitor->trace(m_navigationTiming); 579 visitor->trace(m_navigationTiming);
574 visitor->trace(m_userTiming); 580 visitor->trace(m_userTiming);
575 visitor->trace(m_observers); 581 visitor->trace(m_observers);
576 visitor->trace(m_activeObservers); 582 visitor->trace(m_activeObservers);
577 visitor->trace(m_suspendedObservers); 583 visitor->trace(m_suspendedObservers);
578 EventTargetWithInlineData::trace(visitor); 584 EventTargetWithInlineData::trace(visitor);
579 } 585 }
580 586
581 } // namespace blink 587 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698