| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 name, websearch_chrome_joint_experiment_id); \ | 103 name, websearch_chrome_joint_experiment_id); \ |
| 104 PltHistogramWithNoMacroCaching(name_with_experiment_id, sample); \ | 104 PltHistogramWithNoMacroCaching(name_with_experiment_id, sample); \ |
| 105 } \ | 105 } \ |
| 106 } \ | 106 } \ |
| 107 PltHistogramWithGwsPreview(name, sample, is_preview, \ | 107 PltHistogramWithGwsPreview(name, sample, is_preview, \ |
| 108 websearch_chrome_joint_experiment_id); \ | 108 websearch_chrome_joint_experiment_id); \ |
| 109 } | 109 } |
| 110 | 110 |
| 111 // In addition to PLT_HISTOGRAM, add the *_DataReductionProxy variant | 111 // In addition to PLT_HISTOGRAM, add the *_DataReductionProxy variant |
| 112 // conditionally. This macro runs only in one thread. | 112 // conditionally. This macro runs only in one thread. |
| 113 #define PLT_HISTOGRAM_DRP(name, sample, data_reduction_proxy_was_used) \ | 113 #define PLT_HISTOGRAM_DRP( \ |
| 114 name, sample, data_reduction_proxy_was_used, scheme_type) \ |
| 114 do { \ | 115 do { \ |
| 115 static base::HistogramBase* counter(NULL); \ | 116 static base::HistogramBase* counter(NULL); \ |
| 116 static base::HistogramBase* drp_counter(NULL); \ | 117 static base::HistogramBase* drp_counter(NULL); \ |
| 118 static base::HistogramBase* https_drp_counter(NULL); \ |
| 117 if (!counter) { \ | 119 if (!counter) { \ |
| 118 DCHECK(drp_counter == NULL); \ | 120 DCHECK(drp_counter == NULL); \ |
| 121 DCHECK(https_drp_counter == NULL); \ |
| 119 counter = base::Histogram::FactoryTimeGet( \ | 122 counter = base::Histogram::FactoryTimeGet( \ |
| 120 name, kPLTMin(), kPLTMax(), kPLTCount, \ | 123 name, kPLTMin(), kPLTMax(), kPLTCount, \ |
| 121 base::Histogram::kUmaTargetedHistogramFlag); \ | 124 base::Histogram::kUmaTargetedHistogramFlag); \ |
| 122 } \ | 125 } \ |
| 123 counter->AddTime(sample); \ | 126 counter->AddTime(sample); \ |
| 124 if (!data_reduction_proxy_was_used) break; \ | 127 if (!data_reduction_proxy_was_used) break; \ |
| 125 if (!drp_counter) { \ | 128 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { \ |
| 126 drp_counter = base::Histogram::FactoryTimeGet( \ | 129 if (!https_drp_counter) { \ |
| 127 std::string(name) + "_DataReductionProxy", \ | 130 https_drp_counter = base::Histogram::FactoryTimeGet( \ |
| 128 kPLTMin(), kPLTMax(), kPLTCount, \ | 131 std::string(name) + "_DataReductionProxy", \ |
| 129 base::Histogram::kUmaTargetedHistogramFlag); \ | 132 kPLTMin(), kPLTMax(), kPLTCount, \ |
| 133 base::Histogram::kUmaTargetedHistogramFlag); \ |
| 134 } \ |
| 135 https_drp_counter->AddTime(sample); \ |
| 136 } else { \ |
| 137 if (!drp_counter) { \ |
| 138 drp_counter = base::Histogram::FactoryTimeGet( \ |
| 139 std::string(name) + "_HTTPS_DataReductionProxy", \ |
| 140 kPLTMin(), kPLTMax(), kPLTCount, \ |
| 141 base::Histogram::kUmaTargetedHistogramFlag); \ |
| 142 } \ |
| 143 drp_counter->AddTime(sample); \ |
| 130 } \ | 144 } \ |
| 131 drp_counter->AddTime(sample); \ | |
| 132 } while (0) | 145 } while (0) |
| 133 | 146 |
| 134 // Returns the scheme type of the given URL if its type is one for which we | 147 // Returns the scheme type of the given URL if its type is one for which we |
| 135 // dump page load histograms. Otherwise returns NULL. | 148 // dump page load histograms. Otherwise returns NULL. |
| 136 URLPattern::SchemeMasks GetSupportedSchemeType(const GURL& url) { | 149 URLPattern::SchemeMasks GetSupportedSchemeType(const GURL& url) { |
| 137 if (url.SchemeIs("http")) | 150 if (url.SchemeIs("http")) |
| 138 return URLPattern::SCHEME_HTTP; | 151 return URLPattern::SCHEME_HTTP; |
| 139 else if (url.SchemeIs("https")) | 152 else if (url.SchemeIs("https")) |
| 140 return URLPattern::SCHEME_HTTPS; | 153 return URLPattern::SCHEME_HTTPS; |
| 141 return static_cast<URLPattern::SchemeMasks>(0); | 154 return static_cast<URLPattern::SchemeMasks>(0); |
| 142 } | 155 } |
| 143 | 156 |
| 144 // Helper function to check for string in 'via' header. Returns true if | 157 // Helper function to check for string in 'via' header. Returns true if |
| 145 // |via_value| is one of the values listed in the Via header. | 158 // |via_value| is one of the values listed in the Via header. |
| 146 bool ViaHeaderContains(WebFrame* frame, const std::string& via_value) { | 159 bool ViaHeaderContains(WebFrame* frame, const std::string& via_value) { |
| 147 const char kViaHeaderName[] = "Via"; | 160 const char kViaHeaderName[] = "Via"; |
| 148 std::vector<std::string> values; | 161 std::vector<std::string> values; |
| 149 // Multiple via headers have already been coalesced and hence each value | 162 // Multiple via headers have already been coalesced and hence each value |
| 150 // separated by a comma corresponds to a proxy. The value added by a proxy is | 163 // separated by a comma corresponds to a proxy. The value added by a proxy is |
| 151 // not expected to contain any commas. | 164 // not expected to contain any commas. |
| 152 // Example., Via: 1.0 Compression proxy, 1.1 Google Instant Proxy Preview | 165 // Example., Via: 1.0 Compression proxy, 1.1 Google Instant Proxy Preview |
| 153 base::SplitString( | 166 base::SplitString( |
| 154 frame->dataSource()->response().httpHeaderField(kViaHeaderName).utf8(), | 167 frame->dataSource()->response().httpHeaderField(kViaHeaderName).utf8(), |
| 155 ',', &values); | 168 ',', &values); |
| 156 return std::find(values.begin(), values.end(), via_value) != values.end(); | 169 return std::find(values.begin(), values.end(), via_value) != values.end(); |
| 157 } | 170 } |
| 158 | 171 |
| 159 // Returns true if the data reduction proxy was used. Note, this function will | |
| 160 // produce a false positive if a page is fetched using SPDY and using a proxy, | |
| 161 // and the data reduction proxy's via value is added to the Via header. | |
| 162 // TODO(bengr): Plumb the hostname of the proxy and check if it matches | |
| 163 // |SPDY_PROXY_AUTH_ORIGIN|. | |
| 164 bool DataReductionProxyWasUsed(WebFrame* frame) { | |
| 165 DocumentState* document_state = | |
| 166 DocumentState::FromDataSource(frame->dataSource()); | |
| 167 if (!document_state->was_fetched_via_proxy()) | |
| 168 return false; | |
| 169 | |
| 170 std::string via_header = | |
| 171 base::UTF16ToUTF8(frame->dataSource()->response().httpHeaderField("Via")); | |
| 172 | |
| 173 if (via_header.empty()) | |
| 174 return false; | |
| 175 std::string headers = "HTTP/1.1 200 OK\nVia: " + via_header + "\n\n"; | |
| 176 // Produce raw headers, expected by the |HttpResponseHeaders| constructor. | |
| 177 std::replace(headers.begin(), headers.end(), '\n', '\0'); | |
| 178 scoped_refptr<net::HttpResponseHeaders> response_headers( | |
| 179 new net::HttpResponseHeaders(headers)); | |
| 180 return data_reduction_proxy::HasDataReductionProxyViaHeader( | |
| 181 response_headers.get(), NULL); | |
| 182 } | |
| 183 | |
| 184 // Returns true if the provided URL is a referrer string that came from | 172 // Returns true if the provided URL is a referrer string that came from |
| 185 // a Google Web Search results page. This is a little non-deterministic | 173 // a Google Web Search results page. This is a little non-deterministic |
| 186 // because desktop and mobile websearch differ and sometimes just provide | 174 // because desktop and mobile websearch differ and sometimes just provide |
| 187 // http://www.google.com/ as the referrer. In the case of /url we can be sure | 175 // http://www.google.com/ as the referrer. In the case of /url we can be sure |
| 188 // that it came from websearch but we will be generous and allow for cases | 176 // that it came from websearch but we will be generous and allow for cases |
| 189 // where a non-Google URL was provided a bare Google URL as a referrer. | 177 // where a non-Google URL was provided a bare Google URL as a referrer. |
| 190 // The domain validation matches the code used by the prerenderer for similar | 178 // The domain validation matches the code used by the prerenderer for similar |
| 191 // purposes. | 179 // purposes. |
| 192 // TODO(pmeenan): Remove the fuzzy logic when the referrer is reliable | 180 // TODO(pmeenan): Remove the fuzzy logic when the referrer is reliable |
| 193 bool IsFromGoogleSearchResult(const GURL& url, const GURL& referrer) { | 181 bool IsFromGoogleSearchResult(const GURL& url, const GURL& referrer) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 220 if (0 < experiment_id && experiment_id <= kMaxExperimentID) | 208 if (0 < experiment_id && experiment_id <= kMaxExperimentID) |
| 221 return experiment_id; | 209 return experiment_id; |
| 222 return kNoExperiment; | 210 return kNoExperiment; |
| 223 } | 211 } |
| 224 | 212 |
| 225 void DumpHistograms(const WebPerformance& performance, | 213 void DumpHistograms(const WebPerformance& performance, |
| 226 DocumentState* document_state, | 214 DocumentState* document_state, |
| 227 bool data_reduction_proxy_was_used, | 215 bool data_reduction_proxy_was_used, |
| 228 bool came_from_websearch, | 216 bool came_from_websearch, |
| 229 int websearch_chrome_joint_experiment_id, | 217 int websearch_chrome_joint_experiment_id, |
| 230 bool is_preview) { | 218 bool is_preview, |
| 219 URLPattern::SchemeMasks scheme_type) { |
| 231 // This function records new histograms based on the Navigation Timing | 220 // This function records new histograms based on the Navigation Timing |
| 232 // records. As such, the histograms should not depend on the deprecated timing | 221 // records. As such, the histograms should not depend on the deprecated timing |
| 233 // information collected in DocumentState. However, here for some reason we | 222 // information collected in DocumentState. However, here for some reason we |
| 234 // check if document_state->request_time() is null. TODO(ppi): find out why | 223 // check if document_state->request_time() is null. TODO(ppi): find out why |
| 235 // and remove DocumentState from the parameter list. | 224 // and remove DocumentState from the parameter list. |
| 236 Time request = document_state->request_time(); | 225 Time request = document_state->request_time(); |
| 237 | 226 |
| 238 Time navigation_start = Time::FromDoubleT(performance.navigationStart()); | 227 Time navigation_start = Time::FromDoubleT(performance.navigationStart()); |
| 239 Time redirect_start = Time::FromDoubleT(performance.redirectStart()); | 228 Time redirect_start = Time::FromDoubleT(performance.redirectStart()); |
| 240 Time redirect_end = Time::FromDoubleT(performance.redirectEnd()); | 229 Time redirect_end = Time::FromDoubleT(performance.redirectEnd()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 // |load_event_end| may be NULL as in the non-PT_ case below. Examples in | 261 // |load_event_end| may be NULL as in the non-PT_ case below. Examples in |
| 273 // http://crbug.com/112006. | 262 // http://crbug.com/112006. |
| 274 // DCHECK(!load_event_start.is_null()); | 263 // DCHECK(!load_event_start.is_null()); |
| 275 // DCHECK(!load_event_end.is_null()); | 264 // DCHECK(!load_event_end.is_null()); |
| 276 | 265 |
| 277 if (document_state->web_timing_histograms_recorded()) | 266 if (document_state->web_timing_histograms_recorded()) |
| 278 return; | 267 return; |
| 279 document_state->set_web_timing_histograms_recorded(true); | 268 document_state->set_web_timing_histograms_recorded(true); |
| 280 | 269 |
| 281 if (!redirect_start.is_null() && !redirect_end.is_null()) { | 270 if (!redirect_start.is_null() && !redirect_end.is_null()) { |
| 282 PLT_HISTOGRAM_DRP("PLT.NT_Redirect", redirect_end - redirect_start, | 271 PLT_HISTOGRAM_DRP("PLT.NT_Redirect", |
| 283 data_reduction_proxy_was_used); | 272 redirect_end - redirect_start, |
| 273 data_reduction_proxy_was_used, |
| 274 scheme_type); |
| 284 PLT_HISTOGRAM_DRP( | 275 PLT_HISTOGRAM_DRP( |
| 285 "PLT.NT_DelayBeforeFetchRedirect", | 276 "PLT.NT_DelayBeforeFetchRedirect", |
| 286 (fetch_start - navigation_start) - (redirect_end - redirect_start), | 277 (fetch_start - navigation_start) - (redirect_end - redirect_start), |
| 287 data_reduction_proxy_was_used); | 278 data_reduction_proxy_was_used, |
| 279 scheme_type); |
| 288 } else { | 280 } else { |
| 289 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeFetch", | 281 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeFetch", |
| 290 fetch_start - navigation_start, | 282 fetch_start - navigation_start, |
| 291 data_reduction_proxy_was_used); | 283 data_reduction_proxy_was_used, |
| 284 scheme_type); |
| 292 } | 285 } |
| 293 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeDomainLookup", | 286 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeDomainLookup", |
| 294 domain_lookup_start - fetch_start, | 287 domain_lookup_start - fetch_start, |
| 295 data_reduction_proxy_was_used); | 288 data_reduction_proxy_was_used, |
| 289 scheme_type); |
| 296 PLT_HISTOGRAM_DRP("PLT.NT_DomainLookup", | 290 PLT_HISTOGRAM_DRP("PLT.NT_DomainLookup", |
| 297 domain_lookup_end - domain_lookup_start, | 291 domain_lookup_end - domain_lookup_start, |
| 298 data_reduction_proxy_was_used); | 292 data_reduction_proxy_was_used, |
| 293 scheme_type); |
| 299 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeConnect", | 294 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeConnect", |
| 300 connect_start - domain_lookup_end, | 295 connect_start - domain_lookup_end, |
| 301 data_reduction_proxy_was_used); | 296 data_reduction_proxy_was_used, |
| 302 PLT_HISTOGRAM_DRP("PLT.NT_Connect", connect_end - connect_start, | 297 scheme_type); |
| 303 data_reduction_proxy_was_used); | 298 PLT_HISTOGRAM_DRP("PLT.NT_Connect", |
| 299 connect_end - connect_start, |
| 300 data_reduction_proxy_was_used, |
| 301 scheme_type); |
| 304 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeRequest", | 302 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeRequest", |
| 305 request_start - connect_end, | 303 request_start - connect_end, |
| 306 data_reduction_proxy_was_used); | 304 data_reduction_proxy_was_used, |
| 307 PLT_HISTOGRAM_DRP("PLT.NT_Request", response_start - request_start, | 305 scheme_type); |
| 308 data_reduction_proxy_was_used); | 306 PLT_HISTOGRAM_DRP("PLT.NT_Request", |
| 309 PLT_HISTOGRAM_DRP("PLT.NT_Response", response_end - response_start, | 307 response_start - request_start, |
| 310 data_reduction_proxy_was_used); | 308 data_reduction_proxy_was_used, |
| 309 scheme_type); |
| 310 PLT_HISTOGRAM_DRP("PLT.NT_Response", |
| 311 response_end - response_start, |
| 312 data_reduction_proxy_was_used, |
| 313 scheme_type); |
| 311 | 314 |
| 312 if (!dom_loading.is_null()) { | 315 if (!dom_loading.is_null()) { |
| 313 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeDomLoading", | 316 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeDomLoading", |
| 314 dom_loading - response_start, | 317 dom_loading - response_start, |
| 315 data_reduction_proxy_was_used); | 318 data_reduction_proxy_was_used, |
| 319 scheme_type); |
| 316 } | 320 } |
| 317 if (!dom_interactive.is_null() && !dom_loading.is_null()) { | 321 if (!dom_interactive.is_null() && !dom_loading.is_null()) { |
| 318 PLT_HISTOGRAM_DRP("PLT.NT_DomLoading", | 322 PLT_HISTOGRAM_DRP("PLT.NT_DomLoading", |
| 319 dom_interactive - dom_loading, | 323 dom_interactive - dom_loading, |
| 320 data_reduction_proxy_was_used); | 324 data_reduction_proxy_was_used, |
| 325 scheme_type); |
| 321 } | 326 } |
| 322 if (!dom_content_loaded_start.is_null() && !dom_interactive.is_null()) { | 327 if (!dom_content_loaded_start.is_null() && !dom_interactive.is_null()) { |
| 323 PLT_HISTOGRAM_DRP("PLT.NT_DomInteractive", | 328 PLT_HISTOGRAM_DRP("PLT.NT_DomInteractive", |
| 324 dom_content_loaded_start - dom_interactive, | 329 dom_content_loaded_start - dom_interactive, |
| 325 data_reduction_proxy_was_used); | 330 data_reduction_proxy_was_used, |
| 331 scheme_type); |
| 326 } | 332 } |
| 327 if (!dom_content_loaded_start.is_null() && | 333 if (!dom_content_loaded_start.is_null() && |
| 328 !dom_content_loaded_end.is_null() ) { | 334 !dom_content_loaded_end.is_null() ) { |
| 329 PLT_HISTOGRAM_DRP("PLT.NT_DomContentLoaded", | 335 PLT_HISTOGRAM_DRP("PLT.NT_DomContentLoaded", |
| 330 dom_content_loaded_end - dom_content_loaded_start, | 336 dom_content_loaded_end - dom_content_loaded_start, |
| 331 data_reduction_proxy_was_used); | 337 data_reduction_proxy_was_used, |
| 338 scheme_type); |
| 332 } | 339 } |
| 333 if (!dom_content_loaded_end.is_null() && !load_event_start.is_null()) { | 340 if (!dom_content_loaded_end.is_null() && !load_event_start.is_null()) { |
| 334 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeLoadEvent", | 341 PLT_HISTOGRAM_DRP("PLT.NT_DelayBeforeLoadEvent", |
| 335 load_event_start - dom_content_loaded_end, | 342 load_event_start - dom_content_loaded_end, |
| 336 data_reduction_proxy_was_used); | 343 data_reduction_proxy_was_used, |
| 344 scheme_type); |
| 337 } | 345 } |
| 338 | 346 |
| 339 // TODO(simonjam): There is no way to distinguish between abandonment and | 347 // TODO(simonjam): There is no way to distinguish between abandonment and |
| 340 // intentional Javascript navigation before the load event fires. | 348 // intentional Javascript navigation before the load event fires. |
| 341 // TODO(dominich): Load type breakdown | 349 // TODO(dominich): Load type breakdown |
| 342 if (!load_event_start.is_null()) { | 350 if (!load_event_start.is_null()) { |
| 343 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToFinishDoc", | 351 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToFinishDoc", |
| 344 load_event_start - begin, | 352 load_event_start - begin, |
| 345 came_from_websearch, | 353 came_from_websearch, |
| 346 websearch_chrome_joint_experiment_id, | 354 websearch_chrome_joint_experiment_id, |
| 347 is_preview); | 355 is_preview); |
| 348 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_CommitToFinishDoc", | 356 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_CommitToFinishDoc", |
| 349 load_event_start - response_start, | 357 load_event_start - response_start, |
| 350 came_from_websearch, | 358 came_from_websearch, |
| 351 websearch_chrome_joint_experiment_id, | 359 websearch_chrome_joint_experiment_id, |
| 352 is_preview); | 360 is_preview); |
| 353 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToFinishDoc", | 361 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToFinishDoc", |
| 354 load_event_start - navigation_start, | 362 load_event_start - navigation_start, |
| 355 came_from_websearch, | 363 came_from_websearch, |
| 356 websearch_chrome_joint_experiment_id, | 364 websearch_chrome_joint_experiment_id, |
| 357 is_preview); | 365 is_preview); |
| 358 if (data_reduction_proxy_was_used) { | 366 if (data_reduction_proxy_was_used) { |
| 359 PLT_HISTOGRAM("PLT.PT_BeginToFinishDoc_DataReductionProxy", | 367 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { |
| 360 load_event_start - begin); | 368 PLT_HISTOGRAM("PLT.PT_BeginToFinishDoc_DataReductionProxy", |
| 361 PLT_HISTOGRAM("PLT.PT_CommitToFinishDoc_DataReductionProxy", | 369 load_event_start - begin); |
| 362 load_event_start - response_start); | 370 PLT_HISTOGRAM("PLT.PT_CommitToFinishDoc_DataReductionProxy", |
| 363 PLT_HISTOGRAM("PLT.PT_RequestToFinishDoc_DataReductionProxy", | 371 load_event_start - response_start); |
| 364 load_event_start - navigation_start); | 372 PLT_HISTOGRAM("PLT.PT_RequestToFinishDoc_DataReductionProxy", |
| 373 load_event_start - navigation_start); |
| 374 } else { |
| 375 PLT_HISTOGRAM("PLT.PT_BeginToFinishDoc_HTTPS_DataReductionProxy", |
| 376 load_event_start - begin); |
| 377 PLT_HISTOGRAM("PLT.PT_CommitToFinishDoc_HTTPS_DataReductionProxy", |
| 378 load_event_start - response_start); |
| 379 PLT_HISTOGRAM("PLT.PT_RequestToFinishDoc_HTTPS_DataReductionProxy", |
| 380 load_event_start - navigation_start); |
| 381 } |
| 365 } | 382 } |
| 366 } | 383 } |
| 367 if (!load_event_end.is_null()) { | 384 if (!load_event_end.is_null()) { |
| 368 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToFinish", | 385 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToFinish", |
| 369 load_event_end - begin, | 386 load_event_end - begin, |
| 370 came_from_websearch, | 387 came_from_websearch, |
| 371 websearch_chrome_joint_experiment_id, | 388 websearch_chrome_joint_experiment_id, |
| 372 is_preview); | 389 is_preview); |
| 373 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_CommitToFinish", | 390 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_CommitToFinish", |
| 374 load_event_end - response_start, | 391 load_event_end - response_start, |
| 375 came_from_websearch, | 392 came_from_websearch, |
| 376 websearch_chrome_joint_experiment_id, | 393 websearch_chrome_joint_experiment_id, |
| 377 is_preview); | 394 is_preview); |
| 378 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToFinish", | 395 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToFinish", |
| 379 load_event_end - navigation_start, | 396 load_event_end - navigation_start, |
| 380 came_from_websearch, | 397 came_from_websearch, |
| 381 websearch_chrome_joint_experiment_id, | 398 websearch_chrome_joint_experiment_id, |
| 382 is_preview); | 399 is_preview); |
| 383 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_StartToFinish", | 400 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_StartToFinish", |
| 384 load_event_end - request_start, | 401 load_event_end - request_start, |
| 385 came_from_websearch, | 402 came_from_websearch, |
| 386 websearch_chrome_joint_experiment_id, | 403 websearch_chrome_joint_experiment_id, |
| 387 is_preview); | 404 is_preview); |
| 388 if (data_reduction_proxy_was_used) { | 405 if (data_reduction_proxy_was_used) { |
| 389 PLT_HISTOGRAM("PLT.PT_BeginToFinish_DataReductionProxy", | 406 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { |
| 390 load_event_end - begin); | 407 PLT_HISTOGRAM("PLT.PT_BeginToFinish_DataReductionProxy", |
| 391 PLT_HISTOGRAM("PLT.PT_CommitToFinish_DataReductionProxy", | 408 load_event_end - begin); |
| 392 load_event_end - response_start); | 409 PLT_HISTOGRAM("PLT.PT_CommitToFinish_DataReductionProxy", |
| 393 PLT_HISTOGRAM("PLT.PT_RequestToFinish_DataReductionProxy", | 410 load_event_end - response_start); |
| 394 load_event_end - navigation_start); | 411 PLT_HISTOGRAM("PLT.PT_RequestToFinish_DataReductionProxy", |
| 395 PLT_HISTOGRAM("PLT.PT_StartToFinish_DataReductionProxy", | 412 load_event_end - navigation_start); |
| 396 load_event_end - request_start); | 413 PLT_HISTOGRAM("PLT.PT_StartToFinish_DataReductionProxy", |
| 414 load_event_end - request_start); |
| 415 } else { |
| 416 PLT_HISTOGRAM("PLT.PT_BeginToFinish_HTTPS_DataReductionProxy", |
| 417 load_event_end - begin); |
| 418 PLT_HISTOGRAM("PLT.PT_CommitToFinish_HTTPS_DataReductionProxy", |
| 419 load_event_end - response_start); |
| 420 PLT_HISTOGRAM("PLT.PT_RequestToFinish_HTTPS_DataReductionProxy", |
| 421 load_event_end - navigation_start); |
| 422 PLT_HISTOGRAM("PLT.PT_StartToFinish_HTTPS_DataReductionProxy", |
| 423 load_event_end - request_start); |
| 424 } |
| 397 } | 425 } |
| 398 } | 426 } |
| 399 if (!load_event_start.is_null() && !load_event_end.is_null()) { | 427 if (!load_event_start.is_null() && !load_event_end.is_null()) { |
| 400 PLT_HISTOGRAM("PLT.PT_FinishDocToFinish", | 428 PLT_HISTOGRAM("PLT.PT_FinishDocToFinish", |
| 401 load_event_end - load_event_start); | 429 load_event_end - load_event_start); |
| 402 PLT_HISTOGRAM_DRP("PLT.NT_LoadEvent", | 430 PLT_HISTOGRAM_DRP("PLT.NT_LoadEvent", |
| 403 load_event_end - load_event_start, | 431 load_event_end - load_event_start, |
| 404 data_reduction_proxy_was_used); | 432 data_reduction_proxy_was_used, |
| 433 scheme_type); |
| 405 | 434 |
| 406 if (data_reduction_proxy_was_used) | 435 if (data_reduction_proxy_was_used) { |
| 407 PLT_HISTOGRAM("PLT.PT_FinishDocToFinish_DataReductionProxy", | 436 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { |
| 408 load_event_end - load_event_start); | 437 PLT_HISTOGRAM("PLT.PT_FinishDocToFinish_DataReductionProxy", |
| 438 load_event_end - load_event_start); |
| 439 } else { |
| 440 PLT_HISTOGRAM("PLT.PT_FinishDocToFinish_HTTPS_DataReductionProxy", |
| 441 load_event_end - load_event_start); |
| 442 } |
| 443 } |
| 409 } | 444 } |
| 410 if (!dom_content_loaded_start.is_null()) { | 445 if (!dom_content_loaded_start.is_null()) { |
| 411 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToDomContentLoaded", | 446 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToDomContentLoaded", |
| 412 dom_content_loaded_start - navigation_start, | 447 dom_content_loaded_start - navigation_start, |
| 413 came_from_websearch, | 448 came_from_websearch, |
| 414 websearch_chrome_joint_experiment_id, | 449 websearch_chrome_joint_experiment_id, |
| 415 is_preview); | 450 is_preview); |
| 416 if (data_reduction_proxy_was_used) | 451 if (data_reduction_proxy_was_used) { |
| 417 PLT_HISTOGRAM("PLT.PT_RequestToDomContentLoaded_DataReductionProxy", | 452 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { |
| 418 dom_content_loaded_start - navigation_start); | 453 PLT_HISTOGRAM("PLT.PT_RequestToDomContentLoaded_DataReductionProxy", |
| 454 dom_content_loaded_start - navigation_start); |
| 455 } else { |
| 456 PLT_HISTOGRAM( |
| 457 "PLT.PT_RequestToDomContentLoaded_HTTPS_DataReductionProxy", |
| 458 dom_content_loaded_start - navigation_start); |
| 459 } |
| 460 } |
| 419 } | 461 } |
| 420 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToCommit", | 462 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToCommit", |
| 421 response_start - begin, | 463 response_start - begin, |
| 422 came_from_websearch, | 464 came_from_websearch, |
| 423 websearch_chrome_joint_experiment_id, | 465 websearch_chrome_joint_experiment_id, |
| 424 is_preview); | 466 is_preview); |
| 425 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToStart", | 467 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToStart", |
| 426 request_start - navigation_start, | 468 request_start - navigation_start, |
| 427 came_from_websearch, | 469 came_from_websearch, |
| 428 websearch_chrome_joint_experiment_id, | 470 websearch_chrome_joint_experiment_id, |
| 429 is_preview); | 471 is_preview); |
| 430 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_StartToCommit", | 472 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_StartToCommit", |
| 431 response_start - request_start, | 473 response_start - request_start, |
| 432 came_from_websearch, | 474 came_from_websearch, |
| 433 websearch_chrome_joint_experiment_id, | 475 websearch_chrome_joint_experiment_id, |
| 434 is_preview); | 476 is_preview); |
| 435 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToCommit", | 477 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToCommit", |
| 436 response_start - navigation_start, | 478 response_start - navigation_start, |
| 437 came_from_websearch, | 479 came_from_websearch, |
| 438 websearch_chrome_joint_experiment_id, | 480 websearch_chrome_joint_experiment_id, |
| 439 is_preview); | 481 is_preview); |
| 440 if (data_reduction_proxy_was_used) { | 482 if (data_reduction_proxy_was_used) { |
| 441 PLT_HISTOGRAM("PLT.PT_BeginToCommit_DataReductionProxy", | 483 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { |
| 442 response_start - begin); | 484 PLT_HISTOGRAM("PLT.PT_BeginToCommit_DataReductionProxy", |
| 443 PLT_HISTOGRAM("PLT.PT_RequestToStart_DataReductionProxy", | 485 response_start - begin); |
| 444 request_start - navigation_start); | 486 PLT_HISTOGRAM("PLT.PT_RequestToStart_DataReductionProxy", |
| 445 PLT_HISTOGRAM("PLT.PT_StartToCommit_DataReductionProxy", | 487 request_start - navigation_start); |
| 446 response_start - request_start); | 488 PLT_HISTOGRAM("PLT.PT_StartToCommit_DataReductionProxy", |
| 447 PLT_HISTOGRAM("PLT.PT_RequestToCommit_DataReductionProxy", | 489 response_start - request_start); |
| 448 response_start - navigation_start); | 490 PLT_HISTOGRAM("PLT.PT_RequestToCommit_DataReductionProxy", |
| 491 response_start - navigation_start); |
| 492 } else { |
| 493 PLT_HISTOGRAM("PLT.PT_BeginToCommit_HTTPS_DataReductionProxy", |
| 494 response_start - begin); |
| 495 PLT_HISTOGRAM("PLT.PT_RequestToStart_HTTPS_DataReductionProxy", |
| 496 request_start - navigation_start); |
| 497 PLT_HISTOGRAM("PLT.PT_StartToCommit_HTTPS_DataReductionProxy", |
| 498 response_start - request_start); |
| 499 PLT_HISTOGRAM("PLT.PT_RequestToCommit_HTTPS_DataReductionProxy", |
| 500 response_start - navigation_start); |
| 501 } |
| 449 } | 502 } |
| 450 } | 503 } |
| 451 | 504 |
| 452 // These histograms are based on the timing information collected in | 505 // These histograms are based on the timing information collected in |
| 453 // DocumentState. They should be transitioned to equivalents based on the | 506 // DocumentState. They should be transitioned to equivalents based on the |
| 454 // Navigation Timing records (see DumpPerformanceTiming()) or dropped if not | 507 // Navigation Timing records (see DumpPerformanceTiming()) or dropped if not |
| 455 // needed. Please do not add new metrics based on DocumentState. | 508 // needed. Please do not add new metrics based on DocumentState. |
| 456 void DumpDeprecatedHistograms(const WebPerformance& performance, | 509 void DumpDeprecatedHistograms(const WebPerformance& performance, |
| 457 DocumentState* document_state, | 510 DocumentState* document_state, |
| 458 bool data_reduction_proxy_was_used, | 511 bool data_reduction_proxy_was_used, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 break; | 717 break; |
| 665 default: | 718 default: |
| 666 break; | 719 break; |
| 667 } | 720 } |
| 668 } | 721 } |
| 669 } | 722 } |
| 670 | 723 |
| 671 } // namespace | 724 } // namespace |
| 672 | 725 |
| 673 PageLoadHistograms::PageLoadHistograms(content::RenderView* render_view) | 726 PageLoadHistograms::PageLoadHistograms(content::RenderView* render_view) |
| 674 : content::RenderViewObserver(render_view) { | 727 : content::RenderViewObserver(render_view), |
| 728 data_reduction_proxy_params_( |
| 729 data_reduction_proxy::DataReductionProxyParams::kAllowed | |
| 730 data_reduction_proxy::DataReductionProxyParams::kFallbackAllowed | |
| 731 data_reduction_proxy::DataReductionProxyParams::kAlternativeAllowed) { |
| 675 } | 732 } |
| 676 | 733 |
| 677 void PageLoadHistograms::Dump(WebFrame* frame) { | 734 void PageLoadHistograms::Dump(WebFrame* frame) { |
| 678 // We only dump histograms for main frames. | 735 // We only dump histograms for main frames. |
| 679 // In the future, it may be interesting to tag subframes and dump them too. | 736 // In the future, it may be interesting to tag subframes and dump them too. |
| 680 if (!frame || frame->parent()) | 737 if (!frame || frame->parent()) |
| 681 return; | 738 return; |
| 682 | 739 |
| 683 // Only dump for supported schemes. | 740 // Only dump for supported schemes. |
| 684 URLPattern::SchemeMasks scheme_type = | 741 URLPattern::SchemeMasks scheme_type = |
| 685 GetSupportedSchemeType(frame->document().url()); | 742 GetSupportedSchemeType(frame->document().url()); |
| 686 if (scheme_type == 0) | 743 if (scheme_type == 0) |
| 687 return; | 744 return; |
| 688 | 745 |
| 689 // Ignore multipart requests. | 746 // Ignore multipart requests. |
| 690 if (frame->dataSource()->response().isMultipartPayload()) | 747 if (frame->dataSource()->response().isMultipartPayload()) |
| 691 return; | 748 return; |
| 692 | 749 |
| 693 DocumentState* document_state = | 750 DocumentState* document_state = |
| 694 DocumentState::FromDataSource(frame->dataSource()); | 751 DocumentState::FromDataSource(frame->dataSource()); |
| 695 | 752 |
| 696 bool data_reduction_proxy_was_used = DataReductionProxyWasUsed(frame); | 753 bool data_reduction_proxy_was_used = |
| 754 data_reduction_proxy_params_.IsDataReductionProxy( |
| 755 document_state->proxy_server(), NULL); |
| 697 bool came_from_websearch = | 756 bool came_from_websearch = |
| 698 IsFromGoogleSearchResult(frame->document().url(), | 757 IsFromGoogleSearchResult(frame->document().url(), |
| 699 GURL(frame->document().referrer())); | 758 GURL(frame->document().referrer())); |
| 700 int websearch_chrome_joint_experiment_id = kNoExperiment; | 759 int websearch_chrome_joint_experiment_id = kNoExperiment; |
| 701 bool is_preview = false; | 760 bool is_preview = false; |
| 702 if (came_from_websearch) { | 761 if (came_from_websearch) { |
| 703 websearch_chrome_joint_experiment_id = | 762 websearch_chrome_joint_experiment_id = |
| 704 GetQueryStringBasedExperiment(GURL(frame->document().referrer())); | 763 GetQueryStringBasedExperiment(GURL(frame->document().referrer())); |
| 705 is_preview = ViaHeaderContains(frame, "1.1 Google Instant Proxy Preview"); | 764 is_preview = ViaHeaderContains(frame, "1.1 Google Instant Proxy Preview"); |
| 706 } | 765 } |
| 707 | 766 |
| 708 // Metrics based on the timing information recorded for the Navigation Timing | 767 // Metrics based on the timing information recorded for the Navigation Timing |
| 709 // API - http://www.w3.org/TR/navigation-timing/. | 768 // API - http://www.w3.org/TR/navigation-timing/. |
| 710 DumpHistograms(frame->performance(), document_state, | 769 DumpHistograms(frame->performance(), document_state, |
| 711 data_reduction_proxy_was_used, | 770 data_reduction_proxy_was_used, |
| 712 came_from_websearch, | 771 came_from_websearch, |
| 713 websearch_chrome_joint_experiment_id, | 772 websearch_chrome_joint_experiment_id, |
| 714 is_preview); | 773 is_preview, |
| 774 scheme_type); |
| 715 | 775 |
| 716 // Old metrics based on the timing information stored in DocumentState. These | 776 // Old metrics based on the timing information stored in DocumentState. These |
| 717 // are deprecated and should go away. | 777 // are deprecated and should go away. |
| 718 DumpDeprecatedHistograms(frame->performance(), document_state, | 778 DumpDeprecatedHistograms(frame->performance(), document_state, |
| 719 data_reduction_proxy_was_used, | 779 data_reduction_proxy_was_used, |
| 720 came_from_websearch, | 780 came_from_websearch, |
| 721 websearch_chrome_joint_experiment_id, | 781 websearch_chrome_joint_experiment_id, |
| 722 is_preview, | 782 is_preview, |
| 723 scheme_type); | 783 scheme_type); |
| 724 | 784 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 | 817 |
| 758 DCHECK(document_state); | 818 DCHECK(document_state); |
| 759 DCHECK(ds); | 819 DCHECK(ds); |
| 760 GURL url(ds->request().url()); | 820 GURL url(ds->request().url()); |
| 761 Time start = document_state->start_load_time(); | 821 Time start = document_state->start_load_time(); |
| 762 Time finish = document_state->finish_load_time(); | 822 Time finish = document_state->finish_load_time(); |
| 763 // TODO(mbelshe): should we log more stats? | 823 // TODO(mbelshe): should we log more stats? |
| 764 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 824 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
| 765 << url.spec(); | 825 << url.spec(); |
| 766 } | 826 } |
| OLD | NEW |