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

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

Issue 2761113002: Move getNavigationType logic from PerformanceBase to PerformanceNavigationTiming. (Closed)
Patch Set: sync to HEAD Created 3 years, 8 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/timing/PerformanceNavigationTiming.h" 5 #include "core/timing/PerformanceNavigationTiming.h"
6 6
7 #include "bindings/core/v8/V8ObjectBuilder.h" 7 #include "bindings/core/v8/V8ObjectBuilder.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/DocumentTiming.h" 9 #include "core/dom/DocumentTiming.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 unsigned long long PerformanceNavigationTiming::getEncodedBodySize() const { 80 unsigned long long PerformanceNavigationTiming::getEncodedBodySize() const {
81 return m_resourceTimingInfo->finalResponse().encodedBodyLength(); 81 return m_resourceTimingInfo->finalResponse().encodedBodyLength();
82 } 82 }
83 83
84 unsigned long long PerformanceNavigationTiming::getDecodedBodySize() const { 84 unsigned long long PerformanceNavigationTiming::getDecodedBodySize() const {
85 return m_resourceTimingInfo->finalResponse().decodedBodyLength(); 85 return m_resourceTimingInfo->finalResponse().decodedBodyLength();
86 } 86 }
87 87
88 AtomicString PerformanceNavigationTiming::getNavigationType(
89 NavigationType type,
90 const Document* document) {
91 if (document &&
92 document->pageVisibilityState() == PageVisibilityStatePrerender) {
93 return "prerender";
94 }
95 switch (type) {
96 case NavigationTypeReload:
97 return "reload";
98 case NavigationTypeBackForward:
99 return "back_forward";
100 case NavigationTypeLinkClicked:
101 case NavigationTypeFormSubmitted:
102 case NavigationTypeFormResubmitted:
103 case NavigationTypeOther:
104 return "navigate";
105 }
106 NOTREACHED();
107 return "navigate";
108 }
109
88 AtomicString PerformanceNavigationTiming::initiatorType() const { 110 AtomicString PerformanceNavigationTiming::initiatorType() const {
89 return "navigation"; 111 return "navigation";
90 } 112 }
91 113
92 bool PerformanceNavigationTiming::getAllowRedirectDetails() const { 114 bool PerformanceNavigationTiming::getAllowRedirectDetails() const {
93 ExecutionContext* context = frame() ? frame()->document() : nullptr; 115 ExecutionContext* context = frame() ? frame()->document() : nullptr;
94 SecurityOrigin* securityOrigin = nullptr; 116 SecurityOrigin* securityOrigin = nullptr;
95 if (context) 117 if (context)
96 securityOrigin = context->getSecurityOrigin(); 118 securityOrigin = context->getSecurityOrigin();
97 if (!securityOrigin) 119 if (!securityOrigin)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 DOMHighResTimeStamp PerformanceNavigationTiming::loadEventEnd() const { 192 DOMHighResTimeStamp PerformanceNavigationTiming::loadEventEnd() const {
171 DocumentLoadTiming* timing = documentLoadTiming(); 193 DocumentLoadTiming* timing = documentLoadTiming();
172 if (!timing) 194 if (!timing)
173 return 0.0; 195 return 0.0;
174 return PerformanceBase::monotonicTimeToDOMHighResTimeStamp( 196 return PerformanceBase::monotonicTimeToDOMHighResTimeStamp(
175 m_timeOrigin, timing->loadEventEnd()); 197 m_timeOrigin, timing->loadEventEnd());
176 } 198 }
177 199
178 AtomicString PerformanceNavigationTiming::type() const { 200 AtomicString PerformanceNavigationTiming::type() const {
179 DocumentLoader* loader = documentLoader(); 201 DocumentLoader* loader = documentLoader();
180 if (!loader) 202 if (frame() && loader)
181 return "navigate"; 203 return getNavigationType(loader->getNavigationType(), frame()->document());
182 Document* document = frame() ? frame()->document(): nullptr;
183 switch (PerformanceBase::getNavigationType(loader->getNavigationType(),
184 document)) {
185 case NavigationType::Prerender:
186 return "prerender";
187 case NavigationType::Reload:
188 return "reload";
189 case NavigationType::BackForward:
190 return "back_forward";
191 case NavigationType::Navigate:
192 return "navigate";
193 }
194 NOTREACHED();
195 return "navigate"; 204 return "navigate";
196 } 205 }
197 206
198 unsigned short PerformanceNavigationTiming::redirectCount() const { 207 unsigned short PerformanceNavigationTiming::redirectCount() const {
199 bool allowRedirectDetails = getAllowRedirectDetails(); 208 bool allowRedirectDetails = getAllowRedirectDetails();
200 DocumentLoadTiming* timing = documentLoadTiming(); 209 DocumentLoadTiming* timing = documentLoadTiming();
201 if (!allowRedirectDetails || !timing) 210 if (!allowRedirectDetails || !timing)
202 return 0; 211 return 0;
203 return timing->redirectCount(); 212 return timing->redirectCount();
204 } 213 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 builder.addNumber("domInteractive", domInteractive()); 259 builder.addNumber("domInteractive", domInteractive());
251 builder.addNumber("domContentLoadedEventStart", domContentLoadedEventStart()); 260 builder.addNumber("domContentLoadedEventStart", domContentLoadedEventStart());
252 builder.addNumber("domContentLoadedEventEnd", domContentLoadedEventEnd()); 261 builder.addNumber("domContentLoadedEventEnd", domContentLoadedEventEnd());
253 builder.addNumber("domComplete", domComplete()); 262 builder.addNumber("domComplete", domComplete());
254 builder.addNumber("loadEventStart", loadEventStart()); 263 builder.addNumber("loadEventStart", loadEventStart());
255 builder.addNumber("loadEventEnd", loadEventEnd()); 264 builder.addNumber("loadEventEnd", loadEventEnd());
256 builder.addString("type", type()); 265 builder.addString("type", type());
257 builder.addNumber("redirectCount", redirectCount()); 266 builder.addNumber("redirectCount", redirectCount());
258 } 267 }
259 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698