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

Unified Diff: third_party/WebKit/Source/core/timing/PerformanceNavigationTiming.cpp

Issue 2472583003: Navigation Timing Level 2 (Closed)
Patch Set: First working version Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/timing/PerformanceNavigationTiming.cpp
diff --git a/third_party/WebKit/Source/core/timing/PerformanceNavigationTiming.cpp b/third_party/WebKit/Source/core/timing/PerformanceNavigationTiming.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6896912c66869884ae3f3cbf6e7f02a5d4d31ecd
--- /dev/null
+++ b/third_party/WebKit/Source/core/timing/PerformanceNavigationTiming.cpp
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2016 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "core/timing/PerformanceNavigationTiming.h"
+
+#include "bindings/core/v8/V8ObjectBuilder.h"
+#include "core/dom/DocumentTiming.h"
+#include "core/loader/DocumentLoadTiming.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/timing/PerformanceBase.h"
+
+namespace blink {
+
+static double monotonicTimeToDOMHighResTimeStamp(double timeOrigin,
panicker 2016/11/02 20:12:37 Isn't this the same code as ResouceTiming? violate
sunjian 2016/11/04 01:12:39 Will work on moving this logic into PerformanceBas
+ double seconds) {
+ DCHECK(seconds >= 0.0);
+ if (!seconds || !timeOrigin)
+ return 0.0;
+ return PerformanceBase::clampTimeResolution(seconds - timeOrigin) * 1000.0;
+}
+
+PerformanceNavigationTiming::PerformanceNavigationTiming(
+ double timeOrigin,
+ double unloadEventStart,
+ double unloadEventEnd,
+ double loadEventStart,
+ double loadEventEnd,
+ unsigned short redirectCount,
+ double domInteractive,
+ double domContentLoadedEventStart,
+ double domContentLoadedEventEnd,
+ double domComplete,
+ AtomicString type,
+ double redirectStart,
+ double redirectEnd,
+ double fetchStart,
+ double responseEnd,
+ bool hasCrossOriginRedirect,
+ bool hasSameOriginAsPreviousDocument,
+ const AtomicString& initiatorType,
+ ResourceLoadTiming* resourceLoadTiming,
+ double lastRedirectEndTime,
+ double finishTime,
+ unsigned long long transferSize,
+ unsigned long long encodedBodyLength,
+ unsigned long long decodedBodyLength,
+ bool didReuseConnection,
+ bool allowTimingDetails,
+ bool allowRedirectDetails,
+ const String& name,
+ const String& entryType,
+ double startTime)
+ : PerformanceResourceTiming(initiatorType,
+ timeOrigin,
+ resourceLoadTiming,
+ lastRedirectEndTime,
+ finishTime,
+ transferSize,
+ encodedBodyLength,
+ decodedBodyLength,
+ didReuseConnection,
+ allowTimingDetails,
+ allowRedirectDetails,
+ name,
+ entryType,
+ startTime),
+ m_timeOrigin(timeOrigin),
+ m_unloadEventStart(unloadEventStart),
+ m_unloadEventEnd(unloadEventEnd),
+ m_loadEventStart(loadEventStart),
+ m_loadEventEnd(loadEventEnd),
+ m_redirectCount(redirectCount),
+ m_domInteractive(domInteractive),
+ m_domContentLoadedEventStart(domContentLoadedEventStart),
+ m_domContentLoadedEventEnd(domContentLoadedEventEnd),
+ m_domComplete(domComplete),
+ m_type(type),
+ m_redirectStart(redirectStart),
+ m_redirectEnd(redirectEnd),
+ m_fetchStart(fetchStart),
+ m_responseEnd(responseEnd),
+ m_hasCrossOriginRedirect(hasCrossOriginRedirect),
+ m_hasSameOriginAsPreviousDocument(hasSameOriginAsPreviousDocument) {}
+
+PerformanceNavigationTiming::~PerformanceNavigationTiming() {}
+
+double PerformanceNavigationTiming::unloadEventStart() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_unloadEventStart);
+}
+
+double PerformanceNavigationTiming::unloadEventEnd() const {
+ if (m_hasCrossOriginRedirect || !m_hasSameOriginAsPreviousDocument)
+ return 0;
+
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_unloadEventEnd);
+}
+
+double PerformanceNavigationTiming::domInteractive() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_domInteractive);
+}
+
+double PerformanceNavigationTiming::domContentLoadedEventStart() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin,
+ m_domContentLoadedEventStart);
+}
+
+double PerformanceNavigationTiming::domContentLoadedEventEnd() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin,
+ m_domContentLoadedEventEnd);
+}
+
+double PerformanceNavigationTiming::domComplete() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_domComplete);
+}
+
+double PerformanceNavigationTiming::loadEventStart() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadEventStart);
+}
+
+double PerformanceNavigationTiming::loadEventEnd() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadEventEnd);
+}
+
+AtomicString PerformanceNavigationTiming::type() const {
+ return m_type;
+}
+
+unsigned short PerformanceNavigationTiming::redirectCount() const {
+ if (m_hasCrossOriginRedirect)
+ return 0;
+ return m_redirectCount;
+}
+
+// Methods that are overriden from PerformanceResourceTiming
+double PerformanceNavigationTiming::fetchStart() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_fetchStart);
+}
+
+double PerformanceNavigationTiming::redirectStart() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_redirectStart);
+}
+
+double PerformanceNavigationTiming::redirectEnd() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_redirectEnd);
+}
+
+double PerformanceNavigationTiming::responseEnd() const {
+ return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_responseEnd);
+}
+
+void PerformanceNavigationTiming::buildJSONValue(
+ V8ObjectBuilder& builder) const {
+ PerformanceResourceTiming::buildJSONValue(builder);
+ builder.addNumber("uploadEventStart", unloadEventStart());
+ builder.addNumber("unloadEventEnd", unloadEventEnd());
+ builder.addNumber("domInteractive", domInteractive());
+ builder.addNumber("domContentLoadedEventStart", domContentLoadedEventStart());
+ builder.addNumber("domContentLoadedEventEnd", domContentLoadedEventEnd());
+ builder.addNumber("domComplete", domComplete());
+ builder.addNumber("loadEventStart", loadEventStart());
+ builder.addNumber("loadEventEnd", loadEventEnd());
+ builder.addString("type", type());
+ builder.addNumber("redirectCount", redirectCount());
+}
+}

Powered by Google App Engine
This is Rietveld 408576698