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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2016 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 #include "core/timing/PerformanceNavigationTiming.h"
31
32 #include "bindings/core/v8/V8ObjectBuilder.h"
33 #include "core/dom/DocumentTiming.h"
34 #include "core/loader/DocumentLoadTiming.h"
35 #include "core/loader/DocumentLoader.h"
36 #include "core/timing/PerformanceBase.h"
37
38 namespace blink {
39
40 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
41 double seconds) {
42 DCHECK(seconds >= 0.0);
43 if (!seconds || !timeOrigin)
44 return 0.0;
45 return PerformanceBase::clampTimeResolution(seconds - timeOrigin) * 1000.0;
46 }
47
48 PerformanceNavigationTiming::PerformanceNavigationTiming(
49 double timeOrigin,
50 double unloadEventStart,
51 double unloadEventEnd,
52 double loadEventStart,
53 double loadEventEnd,
54 unsigned short redirectCount,
55 double domInteractive,
56 double domContentLoadedEventStart,
57 double domContentLoadedEventEnd,
58 double domComplete,
59 AtomicString type,
60 double redirectStart,
61 double redirectEnd,
62 double fetchStart,
63 double responseEnd,
64 bool hasCrossOriginRedirect,
65 bool hasSameOriginAsPreviousDocument,
66 const AtomicString& initiatorType,
67 ResourceLoadTiming* resourceLoadTiming,
68 double lastRedirectEndTime,
69 double finishTime,
70 unsigned long long transferSize,
71 unsigned long long encodedBodyLength,
72 unsigned long long decodedBodyLength,
73 bool didReuseConnection,
74 bool allowTimingDetails,
75 bool allowRedirectDetails,
76 const String& name,
77 const String& entryType,
78 double startTime)
79 : PerformanceResourceTiming(initiatorType,
80 timeOrigin,
81 resourceLoadTiming,
82 lastRedirectEndTime,
83 finishTime,
84 transferSize,
85 encodedBodyLength,
86 decodedBodyLength,
87 didReuseConnection,
88 allowTimingDetails,
89 allowRedirectDetails,
90 name,
91 entryType,
92 startTime),
93 m_timeOrigin(timeOrigin),
94 m_unloadEventStart(unloadEventStart),
95 m_unloadEventEnd(unloadEventEnd),
96 m_loadEventStart(loadEventStart),
97 m_loadEventEnd(loadEventEnd),
98 m_redirectCount(redirectCount),
99 m_domInteractive(domInteractive),
100 m_domContentLoadedEventStart(domContentLoadedEventStart),
101 m_domContentLoadedEventEnd(domContentLoadedEventEnd),
102 m_domComplete(domComplete),
103 m_type(type),
104 m_redirectStart(redirectStart),
105 m_redirectEnd(redirectEnd),
106 m_fetchStart(fetchStart),
107 m_responseEnd(responseEnd),
108 m_hasCrossOriginRedirect(hasCrossOriginRedirect),
109 m_hasSameOriginAsPreviousDocument(hasSameOriginAsPreviousDocument) {}
110
111 PerformanceNavigationTiming::~PerformanceNavigationTiming() {}
112
113 double PerformanceNavigationTiming::unloadEventStart() const {
114 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_unloadEventStart);
115 }
116
117 double PerformanceNavigationTiming::unloadEventEnd() const {
118 if (m_hasCrossOriginRedirect || !m_hasSameOriginAsPreviousDocument)
119 return 0;
120
121 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_unloadEventEnd);
122 }
123
124 double PerformanceNavigationTiming::domInteractive() const {
125 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_domInteractive);
126 }
127
128 double PerformanceNavigationTiming::domContentLoadedEventStart() const {
129 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin,
130 m_domContentLoadedEventStart);
131 }
132
133 double PerformanceNavigationTiming::domContentLoadedEventEnd() const {
134 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin,
135 m_domContentLoadedEventEnd);
136 }
137
138 double PerformanceNavigationTiming::domComplete() const {
139 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_domComplete);
140 }
141
142 double PerformanceNavigationTiming::loadEventStart() const {
143 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadEventStart);
144 }
145
146 double PerformanceNavigationTiming::loadEventEnd() const {
147 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadEventEnd);
148 }
149
150 AtomicString PerformanceNavigationTiming::type() const {
151 return m_type;
152 }
153
154 unsigned short PerformanceNavigationTiming::redirectCount() const {
155 if (m_hasCrossOriginRedirect)
156 return 0;
157 return m_redirectCount;
158 }
159
160 // Methods that are overriden from PerformanceResourceTiming
161 double PerformanceNavigationTiming::fetchStart() const {
162 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_fetchStart);
163 }
164
165 double PerformanceNavigationTiming::redirectStart() const {
166 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_redirectStart);
167 }
168
169 double PerformanceNavigationTiming::redirectEnd() const {
170 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_redirectEnd);
171 }
172
173 double PerformanceNavigationTiming::responseEnd() const {
174 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_responseEnd);
175 }
176
177 void PerformanceNavigationTiming::buildJSONValue(
178 V8ObjectBuilder& builder) const {
179 PerformanceResourceTiming::buildJSONValue(builder);
180 builder.addNumber("uploadEventStart", unloadEventStart());
181 builder.addNumber("unloadEventEnd", unloadEventEnd());
182 builder.addNumber("domInteractive", domInteractive());
183 builder.addNumber("domContentLoadedEventStart", domContentLoadedEventStart());
184 builder.addNumber("domContentLoadedEventEnd", domContentLoadedEventEnd());
185 builder.addNumber("domComplete", domComplete());
186 builder.addNumber("loadEventStart", loadEventStart());
187 builder.addNumber("loadEventEnd", loadEventEnd());
188 builder.addString("type", type());
189 builder.addNumber("redirectCount", redirectCount());
190 }
191 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698