| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | 11 #include "chrome/common/chrome_constants.h" |
| 12 #include "chrome/common/extensions/url_pattern.h" | 12 #include "chrome/common/extensions/url_pattern.h" |
| 13 #include "chrome/renderer/prerender/prerender_helper.h" | 13 #include "chrome/renderer/prerender/prerender_helper.h" |
| 14 #include "chrome/renderer/renderer_histogram_snapshots.h" | 14 #include "chrome/renderer/renderer_histogram_snapshots.h" |
| 15 #include "content/common/view_messages.h" | |
| 16 #include "content/public/renderer/navigation_state.h" | 15 #include "content/public/renderer/navigation_state.h" |
| 17 #include "content/public/renderer/render_view.h" | 16 #include "content/public/renderer/render_view.h" |
| 18 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPerformance.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPerformance.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 24 | 23 |
| 25 using WebKit::WebDataSource; | 24 using WebKit::WebDataSource; |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 | 769 |
| 771 void PageLoadHistograms::ResetCrossFramePropertyAccess() { | 770 void PageLoadHistograms::ResetCrossFramePropertyAccess() { |
| 772 cross_origin_access_count_ = 0; | 771 cross_origin_access_count_ = 0; |
| 773 same_origin_access_count_ = 0; | 772 same_origin_access_count_ = 0; |
| 774 } | 773 } |
| 775 | 774 |
| 776 void PageLoadHistograms::FrameWillClose(WebFrame* frame) { | 775 void PageLoadHistograms::FrameWillClose(WebFrame* frame) { |
| 777 Dump(frame); | 776 Dump(frame); |
| 778 } | 777 } |
| 779 | 778 |
| 780 bool PageLoadHistograms::OnMessageReceived(const IPC::Message& message) { | 779 void PageLoadHistograms::ClosePage() { |
| 781 if (message.type() == ViewMsg_ClosePage::ID) { | 780 // TODO(davemoore) This code should be removed once willClose() gets |
| 782 // TODO(davemoore) This code should be removed once willClose() gets | 781 // called when a page is destroyed. page_load_histograms_.Dump() is safe |
| 783 // called when a page is destroyed. page_load_histograms_.Dump() is safe | 782 // to call multiple times for the same frame, but it will simplify things. |
| 784 // to call multiple times for the same frame, but it will simplify things. | 783 Dump(render_view()->GetWebView()->mainFrame()); |
| 785 Dump(render_view()->GetWebView()->mainFrame()); | 784 ResetCrossFramePropertyAccess(); |
| 786 ResetCrossFramePropertyAccess(); | |
| 787 } | |
| 788 return false; | |
| 789 } | 785 } |
| 790 | 786 |
| 791 void PageLoadHistograms::LogPageLoadTime(const NavigationState* state, | 787 void PageLoadHistograms::LogPageLoadTime(const NavigationState* state, |
| 792 const WebDataSource* ds) const { | 788 const WebDataSource* ds) const { |
| 793 // Because this function gets called on every page load, | 789 // Because this function gets called on every page load, |
| 794 // take extra care to optimize it away if logging is turned off. | 790 // take extra care to optimize it away if logging is turned off. |
| 795 if (logging::LOG_INFO < logging::GetMinLogLevel()) | 791 if (logging::LOG_INFO < logging::GetMinLogLevel()) |
| 796 return; | 792 return; |
| 797 | 793 |
| 798 DCHECK(state); | 794 DCHECK(state); |
| 799 DCHECK(ds); | 795 DCHECK(ds); |
| 800 GURL url(ds->request().url()); | 796 GURL url(ds->request().url()); |
| 801 Time start = state->start_load_time(); | 797 Time start = state->start_load_time(); |
| 802 Time finish = state->finish_load_time(); | 798 Time finish = state->finish_load_time(); |
| 803 // TODO(mbelshe): should we log more stats? | 799 // TODO(mbelshe): should we log more stats? |
| 804 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " | 800 VLOG(1) << "PLT: " << (finish - start).InMilliseconds() << "ms " |
| 805 << url.spec(); | 801 << url.spec(); |
| 806 } | 802 } |
| OLD | NEW |