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

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

Issue 2472583003: Navigation Timing Level 2 (Closed)
Patch Set: Resolved comments 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 // TODO(sunjian): Move this logic into PerformanceBase later?
panicker 2016/11/04 18:55:32 drop the "later?"
sunjian 2016/11/04 22:25:18 Done.
41 static double monotonicTimeToDOMHighResTimeStamp(double timeOrigin,
42 double seconds) {
43 DCHECK(seconds >= 0.0);
44 if (!seconds || !timeOrigin)
45 return 0.0;
46 return PerformanceBase::clampTimeResolution(seconds - timeOrigin) * 1000.0;
47 }
48
49 PerformanceNavigationTiming::PerformanceNavigationTiming(
50 double timeOrigin,
51 double unloadEventStart,
52 double unloadEventEnd,
53 double loadEventStart,
54 double loadEventEnd,
55 unsigned short redirectCount,
56 double domInteractive,
57 double domContentLoadedEventStart,
58 double domContentLoadedEventEnd,
59 double domComplete,
60 AtomicString type,
61 double redirectStart,
62 double redirectEnd,
63 double fetchStart,
64 double responseEnd,
65 bool hasCrossOriginRedirect,
66 bool hasSameOriginAsPreviousDocument,
67 const AtomicString& initiatorType,
68 ResourceLoadTiming* resourceLoadTiming,
69 double lastRedirectEndTime,
70 double finishTime,
71 unsigned long long transferSize,
72 unsigned long long encodedBodyLength,
73 unsigned long long decodedBodyLength,
74 bool didReuseConnection,
75 bool allowTimingDetails,
76 bool allowRedirectDetails,
77 const String& name,
78 const String& entryType,
79 double startTime)
80 : PerformanceResourceTiming(initiatorType,
81 timeOrigin,
82 resourceLoadTiming,
83 lastRedirectEndTime,
84 finishTime,
85 transferSize,
86 encodedBodyLength,
87 decodedBodyLength,
88 didReuseConnection,
89 allowTimingDetails,
90 allowRedirectDetails,
91 name,
92 entryType,
93 startTime),
94 m_timeOrigin(timeOrigin),
95 m_unloadEventStart(unloadEventStart),
96 m_unloadEventEnd(unloadEventEnd),
97 m_loadEventStart(loadEventStart),
98 m_loadEventEnd(loadEventEnd),
99 m_redirectCount(redirectCount),
100 m_domInteractive(domInteractive),
101 m_domContentLoadedEventStart(domContentLoadedEventStart),
102 m_domContentLoadedEventEnd(domContentLoadedEventEnd),
103 m_domComplete(domComplete),
104 m_type(type),
105 m_redirectStart(redirectStart),
106 m_redirectEnd(redirectEnd),
107 m_fetchStart(fetchStart),
108 m_responseEnd(responseEnd),
109 m_hasCrossOriginRedirect(hasCrossOriginRedirect),
110 m_hasSameOriginAsPreviousDocument(hasSameOriginAsPreviousDocument) {}
111
112 PerformanceNavigationTiming::~PerformanceNavigationTiming() {}
113
114 double PerformanceNavigationTiming::unloadEventStart() const {
115 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_unloadEventStart);
116 }
117
118 double PerformanceNavigationTiming::unloadEventEnd() const {
119 if (m_hasCrossOriginRedirect || !m_hasSameOriginAsPreviousDocument)
120 return 0;
121
122 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_unloadEventEnd);
123 }
124
125 double PerformanceNavigationTiming::domInteractive() const {
126 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_domInteractive);
127 }
128
129 double PerformanceNavigationTiming::domContentLoadedEventStart() const {
130 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin,
131 m_domContentLoadedEventStart);
132 }
133
134 double PerformanceNavigationTiming::domContentLoadedEventEnd() const {
135 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin,
136 m_domContentLoadedEventEnd);
137 }
138
139 double PerformanceNavigationTiming::domComplete() const {
140 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_domComplete);
141 }
142
143 double PerformanceNavigationTiming::loadEventStart() const {
144 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadEventStart);
145 }
146
147 double PerformanceNavigationTiming::loadEventEnd() const {
148 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_loadEventEnd);
149 }
150
151 AtomicString PerformanceNavigationTiming::type() const {
152 return m_type;
153 }
154
155 unsigned short PerformanceNavigationTiming::redirectCount() const {
156 if (m_hasCrossOriginRedirect)
157 return 0;
158 return m_redirectCount;
159 }
160
161 // Methods that are overriden from PerformanceResourceTiming
panicker 2016/11/04 19:46:35 Let's not implement methods that need TAO check ye
sunjian 2016/11/04 22:25:18 Then we might not be able to implement any timing-
162 double PerformanceNavigationTiming::fetchStart() const {
163 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_fetchStart);
164 }
165
166 double PerformanceNavigationTiming::redirectStart() const {
167 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_redirectStart);
168 }
169
170 double PerformanceNavigationTiming::redirectEnd() const {
171 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_redirectEnd);
172 }
173
174 double PerformanceNavigationTiming::responseEnd() const {
175 return monotonicTimeToDOMHighResTimeStamp(m_timeOrigin, m_responseEnd);
176 }
177
178 void PerformanceNavigationTiming::buildJSONValue(
179 V8ObjectBuilder& builder) const {
180 PerformanceResourceTiming::buildJSONValue(builder);
181 builder.addNumber("uploadEventStart", unloadEventStart());
panicker 2016/11/04 18:55:32 s/upload/unload/
sunjian 2016/11/04 22:25:19 Done.
182 builder.addNumber("unloadEventEnd", unloadEventEnd());
183 builder.addNumber("domInteractive", domInteractive());
184 builder.addNumber("domContentLoadedEventStart", domContentLoadedEventStart());
185 builder.addNumber("domContentLoadedEventEnd", domContentLoadedEventEnd());
186 builder.addNumber("domComplete", domComplete());
187 builder.addNumber("loadEventStart", loadEventStart());
188 builder.addNumber("loadEventEnd", loadEventEnd());
189 builder.addString("type", type());
190 builder.addNumber("redirectCount", redirectCount());
191 }
192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698