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 2615533002: Remove duplicate domHighResTimestamp conversion in NavigationTiming (Closed)
Patch Set: fixed layout test failures 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } 549 }
550 } 550 }
551 551
552 // static 552 // static
553 double PerformanceBase::clampTimeResolution(double timeSeconds) { 553 double PerformanceBase::clampTimeResolution(double timeSeconds) {
554 const double resolutionSeconds = 0.000005; 554 const double resolutionSeconds = 0.000005;
555 return floor(timeSeconds / resolutionSeconds) * resolutionSeconds; 555 return floor(timeSeconds / resolutionSeconds) * resolutionSeconds;
556 } 556 }
557 557
558 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp( 558 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp(
559 double timeOrigin,
560 double monotonicTime) {
561 // Avoid exposing raw platform timestamps.
562 if (!monotonicTime || !timeOrigin)
563 return 0.0;
564
565 double timeInSeconds = monotonicTime - timeOrigin;
566 DCHECK_GE(timeInSeconds, 0);
567 return convertSecondsToDOMHighResTimeStamp(
568 clampTimeResolution(timeInSeconds));
569 }
570
571 DOMHighResTimeStamp PerformanceBase::monotonicTimeToDOMHighResTimeStamp(
559 double monotonicTime) const { 572 double monotonicTime) const {
560 // Avoid exposing raw platform timestamps. 573 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, monotonicTime);
561 if (m_timeOrigin == 0.0)
562 return 0.0;
563
564 double timeInSeconds = monotonicTime - m_timeOrigin;
565 return convertSecondsToDOMHighResTimeStamp(
566 clampTimeResolution(timeInSeconds));
567 } 574 }
568 575
569 DOMHighResTimeStamp PerformanceBase::now() const { 576 DOMHighResTimeStamp PerformanceBase::now() const {
570 return monotonicTimeToDOMHighResTimeStamp(monotonicallyIncreasingTime()); 577 return monotonicTimeToDOMHighResTimeStamp(monotonicallyIncreasingTime());
571 } 578 }
572 579
573 DEFINE_TRACE(PerformanceBase) { 580 DEFINE_TRACE(PerformanceBase) {
574 visitor->trace(m_frameTimingBuffer); 581 visitor->trace(m_frameTimingBuffer);
575 visitor->trace(m_resourceTimingBuffer); 582 visitor->trace(m_resourceTimingBuffer);
576 visitor->trace(m_navigationTiming); 583 visitor->trace(m_navigationTiming);
577 visitor->trace(m_userTiming); 584 visitor->trace(m_userTiming);
578 visitor->trace(m_observers); 585 visitor->trace(m_observers);
579 visitor->trace(m_activeObservers); 586 visitor->trace(m_activeObservers);
580 visitor->trace(m_suspendedObservers); 587 visitor->trace(m_suspendedObservers);
581 EventTargetWithInlineData::trace(visitor); 588 EventTargetWithInlineData::trace(visitor);
582 } 589 }
583 590
584 } // namespace blink 591 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/timing/PerformanceBase.h ('k') | third_party/WebKit/Source/core/timing/PerformanceEntry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698