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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/histogram_sender.h" | |
10 #include "base/time.h" | 11 #include "base/time.h" |
11 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
12 #include "chrome/common/extensions/url_pattern.h" | 13 #include "chrome/common/extensions/url_pattern.h" |
13 #include "chrome/renderer/chrome_content_renderer_client.h" | 14 #include "chrome/renderer/chrome_content_renderer_client.h" |
14 #include "chrome/renderer/prerender/prerender_helper.h" | 15 #include "chrome/renderer/prerender/prerender_helper.h" |
15 #include "chrome/renderer/renderer_histogram_snapshots.h" | |
16 #include "content/public/renderer/document_state.h" | 16 #include "content/public/renderer/document_state.h" |
17 #include "content/public/renderer/render_view.h" | 17 #include "content/public/renderer/render_view.h" |
18 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPerformance.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPerformance.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h" |
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
24 | 24 |
25 using WebKit::WebDataSource; | 25 using WebKit::WebDataSource; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 FINISH_ALL_LOADS_MISSING = 0x2, | 113 FINISH_ALL_LOADS_MISSING = 0x2, |
114 LOAD_EVENT_START_MISSING = 0x4, | 114 LOAD_EVENT_START_MISSING = 0x4, |
115 LOAD_EVENT_END_MISSING = 0x8, | 115 LOAD_EVENT_END_MISSING = 0x8, |
116 ABANDON_TYPE_MAX = 0x10 | 116 ABANDON_TYPE_MAX = 0x10 |
117 }; | 117 }; |
118 | 118 |
119 } // namespace | 119 } // namespace |
120 | 120 |
121 PageLoadHistograms::PageLoadHistograms( | 121 PageLoadHistograms::PageLoadHistograms( |
122 content::RenderView* render_view, | 122 content::RenderView* render_view, |
123 RendererHistogramSnapshots* histogram_snapshots) | 123 base::HistogramSender* histogram_sender) |
124 : content::RenderViewObserver(render_view), | 124 : content::RenderViewObserver(render_view), |
125 cross_origin_access_count_(0), | 125 cross_origin_access_count_(0), |
126 same_origin_access_count_(0), | 126 same_origin_access_count_(0), |
127 histogram_snapshots_(histogram_snapshots) { | 127 histogram_sender_(histogram_sender) { |
128 } | 128 } |
129 | 129 |
130 void PageLoadHistograms::Dump(WebFrame* frame) { | 130 void PageLoadHistograms::Dump(WebFrame* frame) { |
131 // We only dump histograms for main frames. | 131 // We only dump histograms for main frames. |
132 // In the future, it may be interesting to tag subframes and dump them too. | 132 // In the future, it may be interesting to tag subframes and dump them too. |
133 if (!frame || frame->parent()) | 133 if (!frame || frame->parent()) |
134 return; | 134 return; |
135 | 135 |
136 // Only dump for supported schemes. | 136 // Only dump for supported schemes. |
137 URLPattern::SchemeMasks scheme_type = | 137 URLPattern::SchemeMasks scheme_type = |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 begin_to_finish_all_loads); | 935 begin_to_finish_all_loads); |
936 | 936 |
937 // Since there are currently no guarantees that renderer histograms will be | 937 // Since there are currently no guarantees that renderer histograms will be |
938 // sent to the browser, we initiate a PostTask here to be sure that we send | 938 // sent to the browser, we initiate a PostTask here to be sure that we send |
939 // the histograms we generated. Without this call, pages that don't have an | 939 // the histograms we generated. Without this call, pages that don't have an |
940 // on-close-handler might generate data that is lost when the renderer is | 940 // on-close-handler might generate data that is lost when the renderer is |
941 // shutdown abruptly (perchance because the user closed the tab). | 941 // shutdown abruptly (perchance because the user closed the tab). |
942 // TODO(jar) BUG=33233: This needs to be moved to a PostDelayedTask, and it | 942 // TODO(jar) BUG=33233: This needs to be moved to a PostDelayedTask, and it |
943 // should post when the onload is complete, so that it doesn't interfere with | 943 // should post when the onload is complete, so that it doesn't interfere with |
944 // the next load. | 944 // the next load. |
945 histogram_snapshots_->SendHistograms( | 945 histogram_sender_->SendHistograms( |
jam
2012/06/01 18:23:23
it is a little strange that this class gets a poin
ramant (doing other things)
2012/06/07 02:04:41
Done.
| |
946 chrome::kHistogramSynchronizerReservedSequenceNumber); | 946 chrome::kHistogramSynchronizerReservedSequenceNumber); |
947 } | 947 } |
948 | 948 |
949 void PageLoadHistograms::ResetCrossFramePropertyAccess() { | 949 void PageLoadHistograms::ResetCrossFramePropertyAccess() { |
950 cross_origin_access_count_ = 0; | 950 cross_origin_access_count_ = 0; |
951 same_origin_access_count_ = 0; | 951 same_origin_access_count_ = 0; |
952 } | 952 } |
953 | 953 |
954 void PageLoadHistograms::FrameWillClose(WebFrame* frame) { | 954 void PageLoadHistograms::FrameWillClose(WebFrame* frame) { |
955 Dump(frame); | 955 Dump(frame); |
(...skipping 16 matching lines...) Expand all Loading... | |
972 | 972 |
973 DCHECK(document_state); | 973 DCHECK(document_state); |
974 DCHECK(ds); | 974 DCHECK(ds); |
975 GURL url(ds->request().url()); | 975 GURL url(ds->request().url()); |
976 Time start = document_state->start_load_time(); | 976 Time start = document_state->start_load_time(); |
977 Time finish = document_state->finish_load_time(); | 977 Time finish = document_state->finish_load_time(); |
978 // TODO(mbelshe): should we log more stats? | 978 // TODO(mbelshe): should we log more stats? |
979 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 979 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
980 << url.spec(); | 980 << url.spec(); |
981 } | 981 } |
OLD | NEW |