Chromium Code Reviews| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 if (!base::StringToInt(value, &experiment_id)) | 206 if (!base::StringToInt(value, &experiment_id)) |
| 207 return kNoExperiment; | 207 return kNoExperiment; |
| 208 if (0 < experiment_id && experiment_id <= kMaxExperimentID) | 208 if (0 < experiment_id && experiment_id <= kMaxExperimentID) |
| 209 return experiment_id; | 209 return experiment_id; |
| 210 return kNoExperiment; | 210 return kNoExperiment; |
| 211 } | 211 } |
| 212 | 212 |
| 213 void DumpHistograms(const WebPerformance& performance, | 213 void DumpHistograms(const WebPerformance& performance, |
| 214 DocumentState* document_state, | 214 DocumentState* document_state, |
| 215 bool data_reduction_proxy_was_used, | 215 bool data_reduction_proxy_was_used, |
| 216 bool lofi_enabled, | |
| 217 bool lofi_control, | |
| 216 bool came_from_websearch, | 218 bool came_from_websearch, |
| 217 int websearch_chrome_joint_experiment_id, | 219 int websearch_chrome_joint_experiment_id, |
| 218 bool is_preview, | 220 bool is_preview, |
| 219 URLPattern::SchemeMasks scheme_type) { | 221 URLPattern::SchemeMasks scheme_type) { |
| 220 // This function records new histograms based on the Navigation Timing | 222 // This function records new histograms based on the Navigation Timing |
| 221 // records. As such, the histograms should not depend on the deprecated timing | 223 // records. As such, the histograms should not depend on the deprecated timing |
| 222 // information collected in DocumentState. However, here for some reason we | 224 // information collected in DocumentState. However, here for some reason we |
| 223 // check if document_state->request_time() is null. TODO(ppi): find out why | 225 // check if document_state->request_time() is null. TODO(ppi): find out why |
| 224 // and remove DocumentState from the parameter list. | 226 // and remove DocumentState from the parameter list. |
| 225 Time request = document_state->request_time(); | 227 Time request = document_state->request_time(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 if (data_reduction_proxy_was_used) { | 407 if (data_reduction_proxy_was_used) { |
| 406 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { | 408 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { |
| 407 PLT_HISTOGRAM("PLT.PT_BeginToFinish_DataReductionProxy", | 409 PLT_HISTOGRAM("PLT.PT_BeginToFinish_DataReductionProxy", |
| 408 load_event_end - begin); | 410 load_event_end - begin); |
| 409 PLT_HISTOGRAM("PLT.PT_CommitToFinish_DataReductionProxy", | 411 PLT_HISTOGRAM("PLT.PT_CommitToFinish_DataReductionProxy", |
| 410 load_event_end - response_start); | 412 load_event_end - response_start); |
| 411 PLT_HISTOGRAM("PLT.PT_RequestToFinish_DataReductionProxy", | 413 PLT_HISTOGRAM("PLT.PT_RequestToFinish_DataReductionProxy", |
| 412 load_event_end - navigation_start); | 414 load_event_end - navigation_start); |
| 413 PLT_HISTOGRAM("PLT.PT_StartToFinish_DataReductionProxy", | 415 PLT_HISTOGRAM("PLT.PT_StartToFinish_DataReductionProxy", |
| 414 load_event_end - request_start); | 416 load_event_end - request_start); |
| 417 if (lofi_enabled) { | |
| 418 PLT_HISTOGRAM("PLT.PT_BeginToFinish_DataReductionProxy_LoFiOn", | |
| 419 load_event_end - begin); | |
| 420 PLT_HISTOGRAM("PLT.PT_CommitToFinish_DataReductionProxy_LoFiOn", | |
| 421 load_event_end - response_start); | |
| 422 PLT_HISTOGRAM("PLT.PT_RequestToFinish_DataReductionProxy_LoFiOn", | |
| 423 load_event_end - navigation_start); | |
| 424 PLT_HISTOGRAM("PLT.PT_StartToFinish_DataReductionProxy_LoFiOn", | |
| 425 load_event_end - request_start); | |
| 426 } | |
| 427 if (lofi_control) { | |
| 428 PLT_HISTOGRAM("PLT.PT_BeginToFinish_DataReductionProxy_LoFiOff", | |
| 429 load_event_end - begin); | |
| 430 PLT_HISTOGRAM("PLT.PT_CommitToFinish_DataReductionProxy_LoFiOff", | |
| 431 load_event_end - response_start); | |
| 432 PLT_HISTOGRAM("PLT.PT_RequestToFinish_DataReductionProxy_LoFiOff", | |
| 433 load_event_end - navigation_start); | |
| 434 PLT_HISTOGRAM("PLT.PT_StartToFinish_DataReductionProxy_LoFiOff", | |
| 435 load_event_end - request_start); | |
| 436 } | |
| 415 } else { | 437 } else { |
| 416 PLT_HISTOGRAM("PLT.PT_BeginToFinish_HTTPS_DataReductionProxy", | 438 PLT_HISTOGRAM("PLT.PT_BeginToFinish_HTTPS_DataReductionProxy", |
| 417 load_event_end - begin); | 439 load_event_end - begin); |
| 418 PLT_HISTOGRAM("PLT.PT_CommitToFinish_HTTPS_DataReductionProxy", | 440 PLT_HISTOGRAM("PLT.PT_CommitToFinish_HTTPS_DataReductionProxy", |
| 419 load_event_end - response_start); | 441 load_event_end - response_start); |
| 420 PLT_HISTOGRAM("PLT.PT_RequestToFinish_HTTPS_DataReductionProxy", | 442 PLT_HISTOGRAM("PLT.PT_RequestToFinish_HTTPS_DataReductionProxy", |
| 421 load_event_end - navigation_start); | 443 load_event_end - navigation_start); |
| 422 PLT_HISTOGRAM("PLT.PT_StartToFinish_HTTPS_DataReductionProxy", | 444 PLT_HISTOGRAM("PLT.PT_StartToFinish_HTTPS_DataReductionProxy", |
| 423 load_event_end - request_start); | 445 load_event_end - request_start); |
| 446 if (lofi_enabled) { | |
| 447 PLT_HISTOGRAM("PLT.PT_BeginToFinish_HTTPS_DataReductionProxy_LoFiOn", | |
| 448 load_event_end - begin); | |
| 449 PLT_HISTOGRAM("PLT.PT_CommitToFinish_HTTPS_DataReductionProxy_LoFiOn", | |
| 450 load_event_end - response_start); | |
| 451 PLT_HISTOGRAM( | |
| 452 "PLT.PT_RequestToFinish_HTTPS_DataReductionProxy_LoFiOn", | |
| 453 load_event_end - navigation_start); | |
| 454 PLT_HISTOGRAM("PLT.PT_StartToFinish_HTTPS_DataReductionProxy_LoFiOn", | |
| 455 load_event_end - request_start); | |
| 456 } | |
| 457 if (lofi_control) { | |
| 458 PLT_HISTOGRAM("PLT.PT_BeginToFinish_HTTPS_DataReductionProxy_LoFiOff", | |
| 459 load_event_end - begin); | |
| 460 PLT_HISTOGRAM( | |
| 461 "PLT.PT_CommitToFinish_HTTPS_DataReductionProxy_LoFiOff", | |
| 462 load_event_end - response_start); | |
| 463 PLT_HISTOGRAM( | |
| 464 "PLT.PT_RequestToFinish_HTTPS_DataReductionProxy_LoFiOff", | |
| 465 load_event_end - navigation_start); | |
| 466 PLT_HISTOGRAM("PLT.PT_StartToFinish_HTTPS_DataReductionProxy_LoFiOff", | |
| 467 load_event_end - request_start); | |
| 468 } | |
| 424 } | 469 } |
| 425 } | 470 } |
| 426 } | 471 } |
| 427 if (!load_event_start.is_null() && !load_event_end.is_null()) { | 472 if (!load_event_start.is_null() && !load_event_end.is_null()) { |
| 428 PLT_HISTOGRAM("PLT.PT_FinishDocToFinish", | 473 PLT_HISTOGRAM("PLT.PT_FinishDocToFinish", |
| 429 load_event_end - load_event_start); | 474 load_event_end - load_event_start); |
| 430 PLT_HISTOGRAM_DRP("PLT.NT_LoadEvent", | 475 PLT_HISTOGRAM_DRP("PLT.NT_LoadEvent", |
| 431 load_event_end - load_event_start, | 476 load_event_end - load_event_start, |
| 432 data_reduction_proxy_was_used, | 477 data_reduction_proxy_was_used, |
| 433 scheme_type); | 478 scheme_type); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 445 if (!dom_content_loaded_start.is_null()) { | 490 if (!dom_content_loaded_start.is_null()) { |
| 446 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToDomContentLoaded", | 491 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToDomContentLoaded", |
| 447 dom_content_loaded_start - navigation_start, | 492 dom_content_loaded_start - navigation_start, |
| 448 came_from_websearch, | 493 came_from_websearch, |
| 449 websearch_chrome_joint_experiment_id, | 494 websearch_chrome_joint_experiment_id, |
| 450 is_preview); | 495 is_preview); |
| 451 if (data_reduction_proxy_was_used) { | 496 if (data_reduction_proxy_was_used) { |
| 452 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { | 497 if ((scheme_type & URLPattern::SCHEME_HTTPS) == 0) { |
| 453 PLT_HISTOGRAM("PLT.PT_RequestToDomContentLoaded_DataReductionProxy", | 498 PLT_HISTOGRAM("PLT.PT_RequestToDomContentLoaded_DataReductionProxy", |
| 454 dom_content_loaded_start - navigation_start); | 499 dom_content_loaded_start - navigation_start); |
| 500 if (lofi_enabled) { | |
| 501 PLT_HISTOGRAM( | |
| 502 "PLT.PT_RequestToDomContentLoaded_DataReductionProxy_LoFiOn", | |
| 503 dom_content_loaded_start - navigation_start); | |
| 504 } | |
| 505 if (lofi_control) { | |
| 506 PLT_HISTOGRAM( | |
| 507 "PLT.PT_RequestToDomContentLoaded_DataReductionProxy_LoFiOff", | |
| 508 dom_content_loaded_start - navigation_start); | |
| 509 } | |
| 455 } else { | 510 } else { |
| 456 PLT_HISTOGRAM( | 511 PLT_HISTOGRAM( |
| 457 "PLT.PT_RequestToDomContentLoaded_HTTPS_DataReductionProxy", | 512 "PLT.PT_RequestToDomContentLoaded_HTTPS_DataReductionProxy", |
| 458 dom_content_loaded_start - navigation_start); | 513 dom_content_loaded_start - navigation_start); |
| 514 if (lofi_enabled) { | |
| 515 PLT_HISTOGRAM( | |
| 516 "PLT.PT_RequestToDomContentLoaded_HTTPS_DataReductionProxy_" | |
| 517 "LoFiOn", | |
| 518 dom_content_loaded_start - navigation_start); | |
| 519 } | |
| 520 if (lofi_control) { | |
| 521 PLT_HISTOGRAM( | |
| 522 "PLT.PT_RequestToDomContentLoaded_HTTPS_DataReductionProxy_" | |
| 523 "LoFiOff", | |
| 524 dom_content_loaded_start - navigation_start); | |
| 525 } | |
| 459 } | 526 } |
| 460 } | 527 } |
| 461 } | 528 } |
| 462 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToCommit", | 529 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_BeginToCommit", |
| 463 response_start - begin, | 530 response_start - begin, |
| 464 came_from_websearch, | 531 came_from_websearch, |
| 465 websearch_chrome_joint_experiment_id, | 532 websearch_chrome_joint_experiment_id, |
| 466 is_preview); | 533 is_preview); |
| 467 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToStart", | 534 PLT_HISTOGRAM_WITH_GWS_VARIANT("PLT.PT_RequestToStart", |
| 468 request_start - navigation_start, | 535 request_start - navigation_start, |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 return; | 812 return; |
| 746 | 813 |
| 747 // Ignore multipart requests. | 814 // Ignore multipart requests. |
| 748 if (frame->dataSource()->response().isMultipartPayload()) | 815 if (frame->dataSource()->response().isMultipartPayload()) |
| 749 return; | 816 return; |
| 750 | 817 |
| 751 DocumentState* document_state = | 818 DocumentState* document_state = |
| 752 DocumentState::FromDataSource(frame->dataSource()); | 819 DocumentState::FromDataSource(frame->dataSource()); |
| 753 | 820 |
| 754 bool data_reduction_proxy_was_used = false; | 821 bool data_reduction_proxy_was_used = false; |
| 822 bool lofi_enabled = false; | |
| 823 bool lofi_control = false; | |
| 755 if (!document_state->proxy_server().IsEmpty()) { | 824 if (!document_state->proxy_server().IsEmpty()) { |
| 756 Send(new DataReductionProxyViewHostMsg_IsDataReductionProxy( | 825 Send(new DataReductionProxyViewHostMsg_DataReductionProxyStatus( |
| 757 document_state->proxy_server(), &data_reduction_proxy_was_used)); | 826 document_state->proxy_server(), &data_reduction_proxy_was_used, |
| 827 &lofi_enabled, &lofi_control)); | |
| 758 } | 828 } |
| 829 // At most one of |lofi_enabled| and |lofi_control| can be true. | |
| 830 DCHECK(!(lofi_enabled && lofi_control)); | |
|
jeremyim
2015/05/11 17:30:21
Shouldn't this just be an enum if it's a tri-state
tbansal1
2015/05/11 21:22:53
Done.
| |
| 759 | 831 |
| 760 bool came_from_websearch = | 832 bool came_from_websearch = |
| 761 IsFromGoogleSearchResult(frame->document().url(), | 833 IsFromGoogleSearchResult(frame->document().url(), |
| 762 GURL(frame->document().referrer())); | 834 GURL(frame->document().referrer())); |
| 763 int websearch_chrome_joint_experiment_id = kNoExperiment; | 835 int websearch_chrome_joint_experiment_id = kNoExperiment; |
| 764 bool is_preview = false; | 836 bool is_preview = false; |
| 765 if (came_from_websearch) { | 837 if (came_from_websearch) { |
| 766 websearch_chrome_joint_experiment_id = | 838 websearch_chrome_joint_experiment_id = |
| 767 GetQueryStringBasedExperiment(GURL(frame->document().referrer())); | 839 GetQueryStringBasedExperiment(GURL(frame->document().referrer())); |
| 768 is_preview = ViaHeaderContains(frame, "1.1 Google Instant Proxy Preview"); | 840 is_preview = ViaHeaderContains(frame, "1.1 Google Instant Proxy Preview"); |
| 769 } | 841 } |
| 770 | 842 |
| 771 // Metrics based on the timing information recorded for the Navigation Timing | 843 // Metrics based on the timing information recorded for the Navigation Timing |
| 772 // API - http://www.w3.org/TR/navigation-timing/. | 844 // API - http://www.w3.org/TR/navigation-timing/. |
| 773 DumpHistograms(frame->performance(), document_state, | 845 DumpHistograms(frame->performance(), document_state, |
| 774 data_reduction_proxy_was_used, | 846 data_reduction_proxy_was_used, lofi_enabled, lofi_control, |
| 775 came_from_websearch, | 847 came_from_websearch, websearch_chrome_joint_experiment_id, |
| 776 websearch_chrome_joint_experiment_id, | 848 is_preview, scheme_type); |
| 777 is_preview, | |
| 778 scheme_type); | |
| 779 | 849 |
| 780 // Old metrics based on the timing information stored in DocumentState. These | 850 // Old metrics based on the timing information stored in DocumentState. These |
| 781 // are deprecated and should go away. | 851 // are deprecated and should go away. |
| 782 DumpDeprecatedHistograms(frame->performance(), document_state, | 852 DumpDeprecatedHistograms(frame->performance(), document_state, |
| 783 data_reduction_proxy_was_used, | 853 data_reduction_proxy_was_used, |
| 784 came_from_websearch, | 854 came_from_websearch, |
| 785 websearch_chrome_joint_experiment_id, | 855 websearch_chrome_joint_experiment_id, |
| 786 is_preview, | 856 is_preview, |
| 787 scheme_type); | 857 scheme_type); |
| 788 | 858 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 | 891 |
| 822 DCHECK(document_state); | 892 DCHECK(document_state); |
| 823 DCHECK(ds); | 893 DCHECK(ds); |
| 824 GURL url(ds->request().url()); | 894 GURL url(ds->request().url()); |
| 825 Time start = document_state->start_load_time(); | 895 Time start = document_state->start_load_time(); |
| 826 Time finish = document_state->finish_load_time(); | 896 Time finish = document_state->finish_load_time(); |
| 827 // TODO(mbelshe): should we log more stats? | 897 // TODO(mbelshe): should we log more stats? |
| 828 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 898 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
| 829 << url.spec(); | 899 << url.spec(); |
| 830 } | 900 } |
| OLD | NEW |