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

Side by Side Diff: Source/core/page/PerformanceTiming.cpp

Issue 15863002: Fix ResourceLoadTiming Resolution Issue 3rd step - remove old fields (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 7 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
« no previous file with comments | « Source/core/page/PerformanceTiming.h ('k') | Source/core/platform/network/ResourceLoadTiming.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 return monotonicTimeToIntegerMilliseconds(timing->fetchStart()); 121 return monotonicTimeToIntegerMilliseconds(timing->fetchStart());
122 } 122 }
123 123
124 unsigned long long PerformanceTiming::domainLookupStart() const 124 unsigned long long PerformanceTiming::domainLookupStart() const
125 { 125 {
126 ResourceLoadTiming* timing = resourceLoadTiming(); 126 ResourceLoadTiming* timing = resourceLoadTiming();
127 if (!timing) 127 if (!timing)
128 return fetchStart(); 128 return fetchStart();
129 129
130 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING
131 // This will be zero when a DNS request is not performed. 130 // This will be zero when a DNS request is not performed.
132 // Rather than exposing a special value that indicates no DNS, we "backfill" with fetchStart. 131 // Rather than exposing a special value that indicates no DNS, we "backfill" with fetchStart.
133 double dnsStart = timing->dnsStart; 132 double dnsStart = timing->dnsStart;
134 if (dnsStart == 0.0) 133 if (dnsStart == 0.0)
135 return fetchStart(); 134 return fetchStart();
136 135
137 return monotonicTimeToIntegerMilliseconds(dnsStart); 136 return monotonicTimeToIntegerMilliseconds(dnsStart);
138 #else
139 // This will be -1 when a DNS request is not performed.
140 // Rather than exposing a special value that indicates no DNS, we "backfill" with fetchStart.
141 int dnsStart = timing->dnsStart;
142 if (dnsStart < 0)
143 return fetchStart();
144
145 return resourceLoadTimeRelativeToAbsolute(dnsStart);
146 #endif
147 } 137 }
148 138
149 unsigned long long PerformanceTiming::domainLookupEnd() const 139 unsigned long long PerformanceTiming::domainLookupEnd() const
150 { 140 {
151 ResourceLoadTiming* timing = resourceLoadTiming(); 141 ResourceLoadTiming* timing = resourceLoadTiming();
152 if (!timing) 142 if (!timing)
153 return domainLookupStart(); 143 return domainLookupStart();
154 144
155 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING
156 // This will be zero when a DNS request is not performed. 145 // This will be zero when a DNS request is not performed.
157 // Rather than exposing a special value that indicates no DNS, we "backfill" with domainLookupStart. 146 // Rather than exposing a special value that indicates no DNS, we "backfill" with domainLookupStart.
158 double dnsEnd = timing->dnsEnd; 147 double dnsEnd = timing->dnsEnd;
159 if (dnsEnd == 0.0) 148 if (dnsEnd == 0.0)
160 return domainLookupStart(); 149 return domainLookupStart();
161 150
162 return monotonicTimeToIntegerMilliseconds(dnsEnd); 151 return monotonicTimeToIntegerMilliseconds(dnsEnd);
163 #else
164 // This will be -1 when a DNS request is not performed.
165 // Rather than exposing a special value that indicates no DNS, we "backfill" with domainLookupStart.
166 int dnsEnd = timing->dnsEnd;
167 if (dnsEnd < 0)
168 return domainLookupStart();
169
170 return resourceLoadTimeRelativeToAbsolute(dnsEnd);
171 #endif
172 } 152 }
173 153
174 unsigned long long PerformanceTiming::connectStart() const 154 unsigned long long PerformanceTiming::connectStart() const
175 { 155 {
176 DocumentLoader* loader = documentLoader(); 156 DocumentLoader* loader = documentLoader();
177 if (!loader) 157 if (!loader)
178 return domainLookupEnd(); 158 return domainLookupEnd();
179 159
180 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); 160 ResourceLoadTiming* timing = loader->response().resourceLoadTiming();
181 if (!timing) 161 if (!timing)
182 return domainLookupEnd(); 162 return domainLookupEnd();
183 163
184 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING
185 // connectStart will be zero when a network request is not made. 164 // connectStart will be zero when a network request is not made.
186 // Rather than exposing a special value that indicates no new connection, we "backfill" with domainLookupEnd. 165 // Rather than exposing a special value that indicates no new connection, we "backfill" with domainLookupEnd.
187 double connectStart = timing->connectStart; 166 double connectStart = timing->connectStart;
188 if (connectStart == 0.0 || loader->response().connectionReused()) 167 if (connectStart == 0.0 || loader->response().connectionReused())
189 return domainLookupEnd(); 168 return domainLookupEnd();
190 169
191 // ResourceLoadTiming's connect phase includes DNS, however Navigation Timin g's 170 // ResourceLoadTiming's connect phase includes DNS, however Navigation Timin g's
192 // connect phase should not. So if there is DNS time, trim it from the start . 171 // connect phase should not. So if there is DNS time, trim it from the start .
193 if (timing->dnsEnd > 0.0 && timing->dnsEnd > connectStart) 172 if (timing->dnsEnd > 0.0 && timing->dnsEnd > connectStart)
194 connectStart = timing->dnsEnd; 173 connectStart = timing->dnsEnd;
195 174
196 return monotonicTimeToIntegerMilliseconds(connectStart); 175 return monotonicTimeToIntegerMilliseconds(connectStart);
197 #else
198 // connectStart will be -1 when a network request is not made.
199 // Rather than exposing a special value that indicates no new connection, we "backfill" with domainLookupEnd.
200 int connectStart = timing->connectStart;
201 if (connectStart < 0 || loader->response().connectionReused())
202 return domainLookupEnd();
203
204 // ResourceLoadTiming's connect phase includes DNS, however Navigation Timin g's
205 // connect phase should not. So if there is DNS time, trim it from the start .
206 if (timing->dnsEnd >= 0 && timing->dnsEnd > connectStart)
207 connectStart = timing->dnsEnd;
208
209 return resourceLoadTimeRelativeToAbsolute(connectStart);
210 #endif
211 } 176 }
212 177
213 unsigned long long PerformanceTiming::connectEnd() const 178 unsigned long long PerformanceTiming::connectEnd() const
214 { 179 {
215 DocumentLoader* loader = documentLoader(); 180 DocumentLoader* loader = documentLoader();
216 if (!loader) 181 if (!loader)
217 return connectStart(); 182 return connectStart();
218 183
219 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); 184 ResourceLoadTiming* timing = loader->response().resourceLoadTiming();
220 if (!timing) 185 if (!timing)
221 return connectStart(); 186 return connectStart();
222 187
223 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING
224 // connectEnd will be zero when a network request is not made. 188 // connectEnd will be zero when a network request is not made.
225 // Rather than exposing a special value that indicates no new connection, we "backfill" with connectStart. 189 // Rather than exposing a special value that indicates no new connection, we "backfill" with connectStart.
226 double connectEnd = timing->connectEnd; 190 double connectEnd = timing->connectEnd;
227 if (connectEnd == 0.0 || loader->response().connectionReused()) 191 if (connectEnd == 0.0 || loader->response().connectionReused())
228 return connectStart(); 192 return connectStart();
229 193
230 return monotonicTimeToIntegerMilliseconds(connectEnd); 194 return monotonicTimeToIntegerMilliseconds(connectEnd);
231 #else
232 // connectEnd will be -1 when a network request is not made.
233 // Rather than exposing a special value that indicates no new connection, we "backfill" with connectStart.
234 int connectEnd = timing->connectEnd;
235 if (connectEnd < 0 || loader->response().connectionReused())
236 return connectStart();
237
238 return resourceLoadTimeRelativeToAbsolute(connectEnd);
239 #endif
240 } 195 }
241 196
242 unsigned long long PerformanceTiming::secureConnectionStart() const 197 unsigned long long PerformanceTiming::secureConnectionStart() const
243 { 198 {
244 DocumentLoader* loader = documentLoader(); 199 DocumentLoader* loader = documentLoader();
245 if (!loader) 200 if (!loader)
246 return 0; 201 return 0;
247 202
248 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); 203 ResourceLoadTiming* timing = loader->response().resourceLoadTiming();
249 if (!timing) 204 if (!timing)
250 return 0; 205 return 0;
251 206
252 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING
253 double sslStart = timing->sslStart; 207 double sslStart = timing->sslStart;
254 if (sslStart == 0.0) 208 if (sslStart == 0.0)
255 return 0; 209 return 0;
256 210
257 return monotonicTimeToIntegerMilliseconds(sslStart); 211 return monotonicTimeToIntegerMilliseconds(sslStart);
258 #else
259 int sslStart = timing->sslStart;
260 if (sslStart < 0)
261 return 0;
262
263 return resourceLoadTimeRelativeToAbsolute(sslStart);
264 #endif
265 } 212 }
266 213
267 unsigned long long PerformanceTiming::requestStart() const 214 unsigned long long PerformanceTiming::requestStart() const
268 { 215 {
269 ResourceLoadTiming* timing = resourceLoadTiming(); 216 ResourceLoadTiming* timing = resourceLoadTiming();
270 217
271 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING
272 if (!timing || timing->sendStart == 0.0) 218 if (!timing || timing->sendStart == 0.0)
273 return connectEnd(); 219 return connectEnd();
274 220
275 return monotonicTimeToIntegerMilliseconds(timing->sendStart); 221 return monotonicTimeToIntegerMilliseconds(timing->sendStart);
276 #else
277 if (!timing || timing->sendStart < 0)
278 return connectEnd();
279
280 return resourceLoadTimeRelativeToAbsolute(timing->sendStart);
281 #endif
282 } 222 }
283 223
284 unsigned long long PerformanceTiming::responseStart() const 224 unsigned long long PerformanceTiming::responseStart() const
285 { 225 {
286 ResourceLoadTiming* timing = resourceLoadTiming(); 226 ResourceLoadTiming* timing = resourceLoadTiming();
287 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING
288 if (!timing || timing->receiveHeadersEnd == 0.0) 227 if (!timing || timing->receiveHeadersEnd == 0.0)
289 return requestStart(); 228 return requestStart();
290 #else 229
291 if (!timing || timing->receiveHeadersEnd < 0)
292 return requestStart();
293 #endif
294 // FIXME: Response start needs to be the time of the first received byte. 230 // FIXME: Response start needs to be the time of the first received byte.
295 // However, the ResourceLoadTiming API currently only supports the time 231 // However, the ResourceLoadTiming API currently only supports the time
296 // the last header byte was received. For many responses with reasonable 232 // the last header byte was received. For many responses with reasonable
297 // sized cookies, the HTTP headers fit into a single packet so this time 233 // sized cookies, the HTTP headers fit into a single packet so this time
298 // is basically equivalent. But for some responses, particularly those with 234 // is basically equivalent. But for some responses, particularly those with
299 // headers larger than a single packet, this time will be too late. 235 // headers larger than a single packet, this time will be too late.
300 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING
301 return monotonicTimeToIntegerMilliseconds(timing->receiveHeadersEnd); 236 return monotonicTimeToIntegerMilliseconds(timing->receiveHeadersEnd);
302 #else
303 return resourceLoadTimeRelativeToAbsolute(timing->receiveHeadersEnd);
304 #endif
305 } 237 }
306 238
307 unsigned long long PerformanceTiming::responseEnd() const 239 unsigned long long PerformanceTiming::responseEnd() const
308 { 240 {
309 DocumentLoadTiming* timing = documentLoadTiming(); 241 DocumentLoadTiming* timing = documentLoadTiming();
310 if (!timing) 242 if (!timing)
311 return 0; 243 return 0;
312 244
313 return monotonicTimeToIntegerMilliseconds(timing->responseEnd()); 245 return monotonicTimeToIntegerMilliseconds(timing->responseEnd());
314 } 246 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 339
408 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const 340 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const
409 { 341 {
410 DocumentLoader* loader = documentLoader(); 342 DocumentLoader* loader = documentLoader();
411 if (!loader) 343 if (!loader)
412 return 0; 344 return 0;
413 345
414 return loader->response().resourceLoadTiming(); 346 return loader->response().resourceLoadTiming();
415 } 347 }
416 348
417 #ifndef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING
418 unsigned long long PerformanceTiming::resourceLoadTimeRelativeToAbsolute(int rel ativeMilliseconds) const
419 {
420 ASSERT(relativeMilliseconds >= 0);
421 ResourceLoadTiming* resourceTiming = resourceLoadTiming();
422 ASSERT(resourceTiming);
423 return monotonicTimeToIntegerMilliseconds(resourceTiming->convertResourceLoa dTimeToMonotonicTime(relativeMilliseconds));
424 }
425 #endif
426
427 unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(double monotonicSeconds) const 349 unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(double monotonicSeconds) const
428 { 350 {
429 ASSERT(monotonicSeconds >= 0); 351 ASSERT(monotonicSeconds >= 0);
430 const DocumentLoadTiming* timing = documentLoadTiming(); 352 const DocumentLoadTiming* timing = documentLoadTiming();
431 ASSERT(timing); 353 ASSERT(timing);
432 return toIntegerMilliseconds(timing->monotonicTimeToPseudoWallTime(monotonic Seconds)); 354 return toIntegerMilliseconds(timing->monotonicTimeToPseudoWallTime(monotonic Seconds));
433 } 355 }
434 356
435 } // namespace WebCore 357 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/PerformanceTiming.h ('k') | Source/core/platform/network/ResourceLoadTiming.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698