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/time.h" | 10 #include "base/time.h" |
11 #include "chrome/common/chrome_constants.h" | |
12 #include "chrome/common/extensions/url_pattern.h" | 11 #include "chrome/common/extensions/url_pattern.h" |
13 #include "chrome/renderer/chrome_content_renderer_client.h" | 12 #include "chrome/renderer/chrome_content_renderer_client.h" |
14 #include "chrome/renderer/prerender/prerender_helper.h" | 13 #include "chrome/renderer/prerender/prerender_helper.h" |
15 #include "chrome/renderer/renderer_histogram_snapshots.h" | 14 #include "content/public/common/content_constants.h" |
16 #include "content/public/renderer/document_state.h" | 15 #include "content/public/renderer/document_state.h" |
16 #include "content/public/renderer/render_thread.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; |
26 using WebKit::WebFrame; | 26 using WebKit::WebFrame; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 enum AbandonType { | 111 enum AbandonType { |
112 FINISH_DOC_MISSING = 0x1, | 112 FINISH_DOC_MISSING = 0x1, |
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(content::RenderView* render_view) |
122 content::RenderView* render_view, | |
123 RendererHistogramSnapshots* histogram_snapshots) | |
124 : content::RenderViewObserver(render_view), | 122 : content::RenderViewObserver(render_view), |
125 cross_origin_access_count_(0), | 123 cross_origin_access_count_(0), |
126 same_origin_access_count_(0), | 124 same_origin_access_count_(0) { |
127 histogram_snapshots_(histogram_snapshots) { | |
128 } | 125 } |
129 | 126 |
130 void PageLoadHistograms::Dump(WebFrame* frame) { | 127 void PageLoadHistograms::Dump(WebFrame* frame) { |
131 // We only dump histograms for main frames. | 128 // We only dump histograms for main frames. |
132 // In the future, it may be interesting to tag subframes and dump them too. | 129 // In the future, it may be interesting to tag subframes and dump them too. |
133 if (!frame || frame->parent()) | 130 if (!frame || frame->parent()) |
134 return; | 131 return; |
135 | 132 |
136 // Only dump for supported schemes. | 133 // Only dump for supported schemes. |
137 URLPattern::SchemeMasks scheme_type = | 134 URLPattern::SchemeMasks scheme_type = |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 begin_to_finish_all_loads); | 932 begin_to_finish_all_loads); |
936 | 933 |
937 // Since there are currently no guarantees that renderer histograms will be | 934 // 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 | 935 // 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 | 936 // 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 | 937 // on-close-handler might generate data that is lost when the renderer is |
941 // shutdown abruptly (perchance because the user closed the tab). | 938 // shutdown abruptly (perchance because the user closed the tab). |
942 // TODO(jar) BUG=33233: This needs to be moved to a PostDelayedTask, and it | 939 // 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 | 940 // should post when the onload is complete, so that it doesn't interfere with |
944 // the next load. | 941 // the next load. |
945 histogram_snapshots_->SendHistograms( | 942 content::RenderThread::Get()->UpdateHistograms( |
jar (doing other things)
2012/07/09 23:04:12
IF GPU goes away... we'll lose data. Do we want t
ramant (doing other things)
2012/07/11 23:52:54
Created issue 136892.
Done.
| |
946 chrome::kHistogramSynchronizerReservedSequenceNumber); | 943 content::kHistogramSynchronizerReservedSequenceNumber); |
947 } | 944 } |
948 | 945 |
949 void PageLoadHistograms::ResetCrossFramePropertyAccess() { | 946 void PageLoadHistograms::ResetCrossFramePropertyAccess() { |
950 cross_origin_access_count_ = 0; | 947 cross_origin_access_count_ = 0; |
951 same_origin_access_count_ = 0; | 948 same_origin_access_count_ = 0; |
952 } | 949 } |
953 | 950 |
954 void PageLoadHistograms::FrameWillClose(WebFrame* frame) { | 951 void PageLoadHistograms::FrameWillClose(WebFrame* frame) { |
955 Dump(frame); | 952 Dump(frame); |
956 } | 953 } |
(...skipping 15 matching lines...) Expand all Loading... | |
972 | 969 |
973 DCHECK(document_state); | 970 DCHECK(document_state); |
974 DCHECK(ds); | 971 DCHECK(ds); |
975 GURL url(ds->request().url()); | 972 GURL url(ds->request().url()); |
976 Time start = document_state->start_load_time(); | 973 Time start = document_state->start_load_time(); |
977 Time finish = document_state->finish_load_time(); | 974 Time finish = document_state->finish_load_time(); |
978 // TODO(mbelshe): should we log more stats? | 975 // TODO(mbelshe): should we log more stats? |
979 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 976 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
980 << url.spec(); | 977 << url.spec(); |
981 } | 978 } |
OLD | NEW |