| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/page_load_histograms.h" | 5 #include "chrome/renderer/page_load_histograms.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 bool is_preview, | 235 bool is_preview, |
| 236 URLPattern::SchemeMasks scheme_type) { | 236 URLPattern::SchemeMasks scheme_type) { |
| 237 // This function records new histograms based on the Navigation Timing | 237 // This function records new histograms based on the Navigation Timing |
| 238 // records. As such, the histograms should not depend on the deprecated timing | 238 // records. As such, the histograms should not depend on the deprecated timing |
| 239 // information collected in DocumentState. However, here for some reason we | 239 // information collected in DocumentState. However, here for some reason we |
| 240 // check if document_state->request_time() is null. TODO(ppi): find out why | 240 // check if document_state->request_time() is null. TODO(ppi): find out why |
| 241 // and remove DocumentState from the parameter list. | 241 // and remove DocumentState from the parameter list. |
| 242 Time request = document_state->request_time(); | 242 Time request = document_state->request_time(); |
| 243 | 243 |
| 244 Time navigation_start = Time::FromDoubleT(performance.navigationStart()); | 244 Time navigation_start = Time::FromDoubleT(performance.navigationStart()); |
| 245 Time redirect_start = Time::FromDoubleT(performance.redirectStart()); | |
| 246 Time redirect_end = Time::FromDoubleT(performance.redirectEnd()); | |
| 247 Time fetch_start = Time::FromDoubleT(performance.fetchStart()); | |
| 248 Time domain_lookup_start = Time::FromDoubleT(performance.domainLookupStart()); | 245 Time domain_lookup_start = Time::FromDoubleT(performance.domainLookupStart()); |
| 249 Time domain_lookup_end = Time::FromDoubleT(performance.domainLookupEnd()); | 246 Time domain_lookup_end = Time::FromDoubleT(performance.domainLookupEnd()); |
| 250 Time connect_start = Time::FromDoubleT(performance.connectStart()); | 247 Time connect_start = Time::FromDoubleT(performance.connectStart()); |
| 251 Time connect_end = Time::FromDoubleT(performance.connectEnd()); | 248 Time connect_end = Time::FromDoubleT(performance.connectEnd()); |
| 252 Time request_start = Time::FromDoubleT(performance.requestStart()); | 249 Time request_start = Time::FromDoubleT(performance.requestStart()); |
| 253 Time response_start = Time::FromDoubleT(performance.responseStart()); | 250 Time response_start = Time::FromDoubleT(performance.responseStart()); |
| 254 Time response_end = Time::FromDoubleT(performance.responseEnd()); | |
| 255 Time dom_loading = Time::FromDoubleT(performance.domLoading()); | 251 Time dom_loading = Time::FromDoubleT(performance.domLoading()); |
| 256 Time dom_interactive = Time::FromDoubleT(performance.domInteractive()); | 252 Time dom_interactive = Time::FromDoubleT(performance.domInteractive()); |
| 257 Time dom_content_loaded_start = | 253 Time dom_content_loaded_start = |
| 258 Time::FromDoubleT(performance.domContentLoadedEventStart()); | 254 Time::FromDoubleT(performance.domContentLoadedEventStart()); |
| 259 Time dom_content_loaded_end = | 255 Time dom_content_loaded_end = |
| 260 Time::FromDoubleT(performance.domContentLoadedEventEnd()); | 256 Time::FromDoubleT(performance.domContentLoadedEventEnd()); |
| 261 Time load_event_start = Time::FromDoubleT(performance.loadEventStart()); | 257 Time load_event_start = Time::FromDoubleT(performance.loadEventStart()); |
| 262 Time load_event_end = Time::FromDoubleT(performance.loadEventEnd()); | 258 Time load_event_end = Time::FromDoubleT(performance.loadEventEnd()); |
| 263 Time begin = (request.is_null() ? navigation_start : request_start); | 259 Time begin = (request.is_null() ? navigation_start : request_start); |
| 264 Time first_paint = document_state->first_paint_time(); | 260 Time first_paint = document_state->first_paint_time(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 278 // TODO(dominich): Investigate conditions under which |load_event_start| and | 274 // TODO(dominich): Investigate conditions under which |load_event_start| and |
| 279 // |load_event_end| may be NULL as in the non-PT_ case below. Examples in | 275 // |load_event_end| may be NULL as in the non-PT_ case below. Examples in |
| 280 // http://crbug.com/112006. | 276 // http://crbug.com/112006. |
| 281 // DCHECK(!load_event_start.is_null()); | 277 // DCHECK(!load_event_start.is_null()); |
| 282 // DCHECK(!load_event_end.is_null()); | 278 // DCHECK(!load_event_end.is_null()); |
| 283 | 279 |
| 284 if (document_state->web_timing_histograms_recorded()) | 280 if (document_state->web_timing_histograms_recorded()) |
| 285 return; | 281 return; |
| 286 document_state->set_web_timing_histograms_recorded(true); | 282 document_state->set_web_timing_histograms_recorded(true); |
| 287 | 283 |
| 288 if (!redirect_start.is_null() && !redirect_end.is_null()) { | |
| 289 PLT_HISTOGRAM_DRP("PLT.NT_Redirect", | |
| 290 redirect_end - redirect_start, | |
| 291 data_reduction_proxy_was_used, | |
| 292 scheme_type); | |
| 293 PLT_HISTOGRAM_DRP( | |
| 294 "PLT.NT_DelayBeforeFetchRedirect", | |
| 295 (fetch_start - navigation_start) - (redirect_end - redirect_start), | |
| 296 data_reduction_proxy_was_used, | |
| 297 scheme_type); | |
| 298 } else { | |
| 299 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeFetch", | |
| 300 fetch_start - navigation_start, | |
| 301 data_reduction_proxy_was_used, | |
| 302 scheme_type); | |
| 303 } | |
| 304 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeDomainLookup", | |
| 305 domain_lookup_start - fetch_start, | |
| 306 data_reduction_proxy_was_used, | |
| 307 scheme_type); | |
| 308 PLT_HISTOGRAM_DRP("PLT.NT_DomainLookup", | 284 PLT_HISTOGRAM_DRP("PLT.NT_DomainLookup", |
| 309 domain_lookup_end - domain_lookup_start, | 285 domain_lookup_end - domain_lookup_start, |
| 310 data_reduction_proxy_was_used, | 286 data_reduction_proxy_was_used, |
| 311 scheme_type); | 287 scheme_type); |
| 312 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeConnect", | |
| 313 connect_start - domain_lookup_end, | |
| 314 data_reduction_proxy_was_used, | |
| 315 scheme_type); | |
| 316 PLT_HISTOGRAM_DRP("PLT.NT_Connect", | 288 PLT_HISTOGRAM_DRP("PLT.NT_Connect", |
| 317 connect_end - connect_start, | 289 connect_end - connect_start, |
| 318 data_reduction_proxy_was_used, | 290 data_reduction_proxy_was_used, |
| 319 scheme_type); | 291 scheme_type); |
| 320 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeRequest", | |
| 321 request_start - connect_end, | |
| 322 data_reduction_proxy_was_used, | |
| 323 scheme_type); | |
| 324 PLT_HISTOGRAM_DRP("PLT.NT_Request", | |
| 325 response_start - request_start, | |
| 326 data_reduction_proxy_was_used, | |
| 327 scheme_type); | |
| 328 PLT_HISTOGRAM_DRP("PLT.NT_Response", | |
| 329 response_end - response_start, | |
| 330 data_reduction_proxy_was_used, | |
| 331 scheme_type); | |
| 332 | 292 |
| 333 if (!dom_loading.is_null()) { | |
| 334 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeDomLoading", | |
| 335 dom_loading - response_start, | |
| 336 data_reduction_proxy_was_used, | |
| 337 scheme_type); | |
| 338 } | |
| 339 if (!dom_interactive.is_null() && !dom_loading.is_null()) { | 293 if (!dom_interactive.is_null() && !dom_loading.is_null()) { |
| 340 PLT_HISTOGRAM_DRP("PLT.NT_DomLoading", | 294 PLT_HISTOGRAM_DRP("PLT.NT_DomLoading", |
| 341 dom_interactive - dom_loading, | 295 dom_interactive - dom_loading, |
| 342 data_reduction_proxy_was_used, | 296 data_reduction_proxy_was_used, |
| 343 scheme_type); | 297 scheme_type); |
| 344 } | 298 } |
| 345 if (!dom_content_loaded_start.is_null() && !dom_interactive.is_null()) { | 299 if (!dom_content_loaded_start.is_null() && !dom_interactive.is_null()) { |
| 346 PLT_HISTOGRAM_DRP("PLT.NT_DomInteractive", | 300 PLT_HISTOGRAM_DRP("PLT.NT_DomInteractive", |
| 347 dom_content_loaded_start - dom_interactive, | 301 dom_content_loaded_start - dom_interactive, |
| 348 data_reduction_proxy_was_used, | 302 data_reduction_proxy_was_used, |
| 349 scheme_type); | 303 scheme_type); |
| 350 } | 304 } |
| 351 if (!dom_content_loaded_start.is_null() && | 305 if (!dom_content_loaded_start.is_null() && |
| 352 !dom_content_loaded_end.is_null() ) { | 306 !dom_content_loaded_end.is_null() ) { |
| 353 PLT_HISTOGRAM_DRP("PLT.NT_DomContentLoaded", | 307 PLT_HISTOGRAM_DRP("PLT.NT_DomContentLoaded", |
| 354 dom_content_loaded_end - dom_content_loaded_start, | 308 dom_content_loaded_end - dom_content_loaded_start, |
| 355 data_reduction_proxy_was_used, | 309 data_reduction_proxy_was_used, |
| 356 scheme_type); | 310 scheme_type); |
| 357 } | 311 } |
| 358 if (!dom_content_loaded_end.is_null() && !load_event_start.is_null()) { | |
| 359 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeLoadEvent", | |
| 360 load_event_start - dom_content_loaded_end, | |
| 361 data_reduction_proxy_was_used, | |
| 362 scheme_type); | |
| 363 } | |
| 364 | 312 |
| 365 // TODO(simonjam): There is no way to distinguish between abandonment and | 313 // TODO(simonjam): There is no way to distinguish between abandonment and |
| 366 // intentional Javascript navigation before the load event fires. | 314 // intentional Javascript navigation before the load event fires. |
| 367 // TODO(dominich): Load type breakdown | 315 // TODO(dominich): Load type breakdown |
| 368 if (!load_event_start.is_null()) { | 316 if (!load_event_start.is_null()) { |
| 369 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToFinishDoc", | 317 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToFinishDoc", |
| 370 load_event_start - begin, | 318 load_event_start - begin, |
| 371 came_from_websearch, | 319 came_from_websearch, |
| 372 websearch_chrome_joint_experiment_id, | 320 websearch_chrome_joint_experiment_id, |
| 373 is_preview); | 321 is_preview); |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 Time start = document_state->start_load_time(); | 912 Time start = document_state->start_load_time(); |
| 965 Time finish = document_state->finish_load_time(); | 913 Time finish = document_state->finish_load_time(); |
| 966 // TODO(mbelshe): should we log more stats? | 914 // TODO(mbelshe): should we log more stats? |
| 967 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 915 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
| 968 << url.spec(); | 916 << url.spec(); |
| 969 } | 917 } |
| 970 | 918 |
| 971 void PageLoadHistograms::OnDestruct() { | 919 void PageLoadHistograms::OnDestruct() { |
| 972 delete this; | 920 delete this; |
| 973 } | 921 } |
| OLD | NEW |