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

Side by Side Diff: chrome/renderer/page_load_histograms.cc

Issue 1394283003: Move more extensions code into ChromeExtensionsRendererClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU Created 5 years, 2 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
OLDNEW
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/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/renderer/chrome_content_renderer_client.h"
22 #include "chrome/renderer/searchbox/search_bouncer.h" 21 #include "chrome/renderer/searchbox/search_bouncer.h"
23 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me ssages.h" 22 #include "components/data_reduction_proxy/content/common/data_reduction_proxy_me ssages.h"
24 #include "content/public/common/content_constants.h" 23 #include "content/public/common/content_constants.h"
25 #include "content/public/renderer/document_state.h" 24 #include "content/public/renderer/document_state.h"
26 #include "content/public/renderer/render_thread.h" 25 #include "content/public/renderer/render_thread.h"
27 #include "content/public/renderer/render_view.h" 26 #include "content/public/renderer/render_view.h"
28 #include "extensions/common/url_pattern.h" 27 #include "extensions/common/url_pattern.h"
29 #include "net/base/url_util.h" 28 #include "net/base/url_util.h"
30 #include "net/http/http_response_headers.h" 29 #include "net/http/http_response_headers.h"
31 #include "third_party/WebKit/public/platform/WebURLRequest.h" 30 #include "third_party/WebKit/public/platform/WebURLRequest.h"
32 #include "third_party/WebKit/public/platform/WebURLResponse.h" 31 #include "third_party/WebKit/public/platform/WebURLResponse.h"
33 #include "third_party/WebKit/public/web/WebDocument.h" 32 #include "third_party/WebKit/public/web/WebDocument.h"
34 #include "third_party/WebKit/public/web/WebFrame.h" 33 #include "third_party/WebKit/public/web/WebFrame.h"
35 #include "third_party/WebKit/public/web/WebPerformance.h" 34 #include "third_party/WebKit/public/web/WebPerformance.h"
36 #include "third_party/WebKit/public/web/WebView.h" 35 #include "third_party/WebKit/public/web/WebView.h"
37 #include "url/gurl.h" 36 #include "url/gurl.h"
38 37
38 #if defined(ENABLE_EXTENSIONS)
39 #include "chrome/renderer/extensions/chrome_extensions_renderer_client.h"
40 #include "extensions/renderer/dispatcher.h"
41 #endif
42
39 using blink::WebDataSource; 43 using blink::WebDataSource;
40 using blink::WebFrame; 44 using blink::WebFrame;
41 using blink::WebPerformance; 45 using blink::WebPerformance;
42 using blink::WebString; 46 using blink::WebString;
43 using base::Time; 47 using base::Time;
44 using base::TimeDelta; 48 using base::TimeDelta;
45 using content::DocumentState; 49 using content::DocumentState;
46 50
47 const size_t kPLTCount = 100; 51 const size_t kPLTCount = 100;
48 52
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 PLT_HISTOGRAM("PLT.PT_RequestToStart_HTTPS_DataReductionProxy", 596 PLT_HISTOGRAM("PLT.PT_RequestToStart_HTTPS_DataReductionProxy",
593 request_start - navigation_start); 597 request_start - navigation_start);
594 PLT_HISTOGRAM("PLT.PT_StartToCommit_HTTPS_DataReductionProxy", 598 PLT_HISTOGRAM("PLT.PT_StartToCommit_HTTPS_DataReductionProxy",
595 response_start - request_start); 599 response_start - request_start);
596 PLT_HISTOGRAM("PLT.PT_RequestToCommit_HTTPS_DataReductionProxy", 600 PLT_HISTOGRAM("PLT.PT_RequestToCommit_HTTPS_DataReductionProxy",
597 response_start - navigation_start); 601 response_start - navigation_start);
598 } 602 }
599 } 603 }
600 } 604 }
601 605
606 bool WasWebRequestUsedBySomeExtensions() {
607 #if defined(ENABLE_EXTENSIONS)
608 return ChromeExtensionsRendererClient::GetInstance()->extension_dispatcher()
609 ->WasWebRequestUsedBySomeExtensions();
610 #else
611 return false;
612 #endif
613 }
614
602 // These histograms are based on the timing information collected in 615 // These histograms are based on the timing information collected in
603 // DocumentState. They should be transitioned to equivalents based on the 616 // DocumentState. They should be transitioned to equivalents based on the
604 // Navigation Timing records (see DumpPerformanceTiming()) or dropped if not 617 // Navigation Timing records (see DumpPerformanceTiming()) or dropped if not
605 // needed. Please do not add new metrics based on DocumentState. 618 // needed. Please do not add new metrics based on DocumentState.
606 void DumpDeprecatedHistograms(const WebPerformance& performance, 619 void DumpDeprecatedHistograms(const WebPerformance& performance,
607 DocumentState* document_state, 620 DocumentState* document_state,
608 bool data_reduction_proxy_was_used, 621 bool data_reduction_proxy_was_used,
609 bool came_from_websearch, 622 bool came_from_websearch,
610 int websearch_chrome_joint_experiment_id, 623 int websearch_chrome_joint_experiment_id,
611 bool is_preview, 624 bool is_preview,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 PLT_HISTOGRAM("PLT.BeginToFinish_ContentPrefetcher", 802 PLT_HISTOGRAM("PLT.BeginToFinish_ContentPrefetcher",
790 begin_to_finish_all_loads); 803 begin_to_finish_all_loads);
791 } 804 }
792 if (document_state->was_referred_by_prefetcher()) { 805 if (document_state->was_referred_by_prefetcher()) {
793 PLT_HISTOGRAM("PLT.BeginToFinishDoc_ContentPrefetcherReferrer", 806 PLT_HISTOGRAM("PLT.BeginToFinishDoc_ContentPrefetcherReferrer",
794 begin_to_finish_doc); 807 begin_to_finish_doc);
795 PLT_HISTOGRAM("PLT.BeginToFinish_ContentPrefetcherReferrer", 808 PLT_HISTOGRAM("PLT.BeginToFinish_ContentPrefetcherReferrer",
796 begin_to_finish_all_loads); 809 begin_to_finish_all_loads);
797 } 810 }
798 811
799 const bool use_webrequest_histogram = 812 const bool use_webrequest_histogram = WasWebRequestUsedBySomeExtensions();
800 ChromeContentRendererClient::WasWebRequestUsedBySomeExtensions();
801 if (use_webrequest_histogram) { 813 if (use_webrequest_histogram) {
802 switch (load_type) { 814 switch (load_type) {
803 case DocumentState::NORMAL_LOAD: 815 case DocumentState::NORMAL_LOAD:
804 PLT_HISTOGRAM( 816 PLT_HISTOGRAM(
805 "PLT.BeginToFinish_NormalLoad_ExtensionWebRequest", 817 "PLT.BeginToFinish_NormalLoad_ExtensionWebRequest",
806 begin_to_finish_all_loads); 818 begin_to_finish_all_loads);
807 break; 819 break;
808 case DocumentState::LINK_LOAD_NORMAL: 820 case DocumentState::LINK_LOAD_NORMAL:
809 PLT_HISTOGRAM( 821 PLT_HISTOGRAM(
810 "PLT.BeginToFinish_LinkLoadNormal_ExtensionWebRequest", 822 "PLT.BeginToFinish_LinkLoadNormal_ExtensionWebRequest",
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 1032
1021 DCHECK(document_state); 1033 DCHECK(document_state);
1022 DCHECK(ds); 1034 DCHECK(ds);
1023 GURL url(ds->request().url()); 1035 GURL url(ds->request().url());
1024 Time start = document_state->start_load_time(); 1036 Time start = document_state->start_load_time();
1025 Time finish = document_state->finish_load_time(); 1037 Time finish = document_state->finish_load_time();
1026 // TODO(mbelshe): should we log more stats? 1038 // TODO(mbelshe): should we log more stats?
1027 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " 1039 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms "
1028 << url.spec(); 1040 << url.spec();
1029 } 1041 }
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/chrome_extensions_renderer_client.cc ('k') | chrome/test/base/chrome_render_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698