| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // * printing | 75 // * printing |
| 76 // * theming | 76 // * theming |
| 77 // * views | 77 // * views |
| 78 #include "base/gfx/gdi_util.h" | 78 #include "base/gfx/gdi_util.h" |
| 79 #include "base/gfx/native_theme.h" | 79 #include "base/gfx/native_theme.h" |
| 80 #include "chrome/common/gfx/emf.h" | 80 #include "chrome/common/gfx/emf.h" |
| 81 #include "chrome/views/controls/message_box_view.h" | 81 #include "chrome/views/controls/message_box_view.h" |
| 82 #include "skia/ext/vector_canvas.h" | 82 #include "skia/ext/vector_canvas.h" |
| 83 #endif | 83 #endif |
| 84 | 84 |
| 85 using base::Time; |
| 85 using base::TimeDelta; | 86 using base::TimeDelta; |
| 86 using webkit_glue::WebAccessibility; | 87 using webkit_glue::WebAccessibility; |
| 87 using WebKit::WebConsoleMessage; | 88 using WebKit::WebConsoleMessage; |
| 88 using WebKit::WebScriptSource; | 89 using WebKit::WebScriptSource; |
| 89 | 90 |
| 90 //----------------------------------------------------------------------------- | 91 //----------------------------------------------------------------------------- |
| 91 | 92 |
| 92 // define to write the time necessary for thumbnail/DOM text retrieval, | 93 // define to write the time necessary for thumbnail/DOM text retrieval, |
| 93 // respectively, into the system debug log | 94 // respectively, into the system debug log |
| 94 // #define TIME_BITMAP_RETRIEVAL | 95 // #define TIME_BITMAP_RETRIEVAL |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 "chrome-ui://chromewebdata/"; | 128 "chrome-ui://chromewebdata/"; |
| 128 | 129 |
| 129 static const char* const kBackForwardNavigationScheme = "history"; | 130 static const char* const kBackForwardNavigationScheme = "history"; |
| 130 | 131 |
| 131 namespace { | 132 namespace { |
| 132 | 133 |
| 133 // Associated with browser-initiated navigations to hold tracking data. | 134 // Associated with browser-initiated navigations to hold tracking data. |
| 134 class RenderViewExtraRequestData : public WebRequest::ExtraData { | 135 class RenderViewExtraRequestData : public WebRequest::ExtraData { |
| 135 public: | 136 public: |
| 136 RenderViewExtraRequestData(int32 pending_page_id, | 137 RenderViewExtraRequestData(int32 pending_page_id, |
| 137 PageTransition::Type transition) | 138 PageTransition::Type transition, |
| 139 Time request_time) |
| 138 : transition_type(transition), | 140 : transition_type(transition), |
| 141 request_time(request_time), |
| 139 request_committed(false), | 142 request_committed(false), |
| 140 pending_page_id_(pending_page_id) { | 143 pending_page_id_(pending_page_id) { |
| 141 } | 144 } |
| 142 | 145 |
| 143 // Contains the page_id for this navigation or -1 if there is none yet. | 146 // Contains the page_id for this navigation or -1 if there is none yet. |
| 144 int32 pending_page_id() const { return pending_page_id_; } | 147 int32 pending_page_id() const { return pending_page_id_; } |
| 145 | 148 |
| 146 // Is this a new navigation? | 149 // Is this a new navigation? |
| 147 bool is_new_navigation() const { return pending_page_id_ == -1; } | 150 bool is_new_navigation() const { return pending_page_id_ == -1; } |
| 148 | 151 |
| 149 // Contains the transition type that the browser specified when it | 152 // Contains the transition type that the browser specified when it |
| 150 // initiated the load. | 153 // initiated the load. |
| 151 PageTransition::Type transition_type; | 154 PageTransition::Type transition_type; |
| 155 Time request_time; |
| 152 | 156 |
| 153 // True if we have already processed the "DidCommitLoad" event for this | 157 // True if we have already processed the "DidCommitLoad" event for this |
| 154 // request. Used by session history. | 158 // request. Used by session history. |
| 155 bool request_committed; | 159 bool request_committed; |
| 156 | 160 |
| 157 private: | 161 private: |
| 158 int32 pending_page_id_; | 162 int32 pending_page_id_; |
| 159 | 163 |
| 160 DISALLOW_COPY_AND_ASSIGN(RenderViewExtraRequestData); | 164 DISALLOW_COPY_AND_ASSIGN(RenderViewExtraRequestData); |
| 161 }; | 165 }; |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 cache_policy = WebRequestReloadIgnoringCacheData; | 804 cache_policy = WebRequestReloadIgnoringCacheData; |
| 801 } else if (params.page_id != -1 || main_frame->GetInViewSourceMode()) { | 805 } else if (params.page_id != -1 || main_frame->GetInViewSourceMode()) { |
| 802 cache_policy = WebRequestReturnCacheDataElseLoad; | 806 cache_policy = WebRequestReturnCacheDataElseLoad; |
| 803 } else { | 807 } else { |
| 804 cache_policy = WebRequestUseProtocolCachePolicy; | 808 cache_policy = WebRequestUseProtocolCachePolicy; |
| 805 } | 809 } |
| 806 | 810 |
| 807 scoped_ptr<WebRequest> request(WebRequest::Create(params.url)); | 811 scoped_ptr<WebRequest> request(WebRequest::Create(params.url)); |
| 808 request->SetCachePolicy(cache_policy); | 812 request->SetCachePolicy(cache_policy); |
| 809 request->SetExtraData(new RenderViewExtraRequestData( | 813 request->SetExtraData(new RenderViewExtraRequestData( |
| 810 params.page_id, params.transition)); | 814 params.page_id, params.transition, params.request_time)); |
| 811 | 815 |
| 812 // If we are reloading, then WebKit will use the state of the current page. | 816 // If we are reloading, then WebKit will use the state of the current page. |
| 813 // Otherwise, we give it the state to navigate to. | 817 // Otherwise, we give it the state to navigate to. |
| 814 if (!is_reload) | 818 if (!is_reload) |
| 815 request->SetHistoryState(params.state); | 819 request->SetHistoryState(params.state); |
| 816 | 820 |
| 817 if (params.referrer.is_valid()) { | 821 if (params.referrer.is_valid()) { |
| 818 request->SetHttpHeaderValue("Referer", | 822 request->SetHttpHeaderValue("Referer", |
| 819 params.referrer.spec()); | 823 params.referrer.spec()); |
| 820 } | 824 } |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 WebView* webview, | 1204 WebView* webview, |
| 1201 WebFrame* frame, | 1205 WebFrame* frame, |
| 1202 NavigationGesture gesture) { | 1206 NavigationGesture gesture) { |
| 1203 if (webview->GetMainFrame() == frame) { | 1207 if (webview->GetMainFrame() == frame) { |
| 1204 navigation_gesture_ = gesture; | 1208 navigation_gesture_ = gesture; |
| 1205 | 1209 |
| 1206 // Make sure redirect tracking state is clear for the new load. | 1210 // Make sure redirect tracking state is clear for the new load. |
| 1207 completed_client_redirect_src_ = GURL(); | 1211 completed_client_redirect_src_ = GURL(); |
| 1208 } | 1212 } |
| 1209 | 1213 |
| 1214 WebDataSource* ds = frame->GetProvisionalDataSource(); |
| 1215 if (ds) { |
| 1216 const WebRequest& req = ds->GetRequest(); |
| 1217 RenderViewExtraRequestData* extra_data = |
| 1218 static_cast<RenderViewExtraRequestData*>(req.GetExtraData()); |
| 1219 if (extra_data) { |
| 1220 ds->SetRequestTime(extra_data->request_time); |
| 1221 } |
| 1222 } |
| 1210 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( | 1223 Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( |
| 1211 routing_id_, webview->GetMainFrame() == frame, | 1224 routing_id_, webview->GetMainFrame() == frame, |
| 1212 frame->GetProvisionalDataSource()->GetRequest().GetURL())); | 1225 frame->GetProvisionalDataSource()->GetRequest().GetURL())); |
| 1213 } | 1226 } |
| 1214 | 1227 |
| 1215 bool RenderView::DidLoadResourceFromMemoryCache(WebView* webview, | 1228 bool RenderView::DidLoadResourceFromMemoryCache(WebView* webview, |
| 1216 const WebRequest& request, | 1229 const WebRequest& request, |
| 1217 const WebResponse& response, | 1230 const WebResponse& response, |
| 1218 WebFrame* frame) { | 1231 WebFrame* frame) { |
| 1219 // Let the browser know we loaded a resource from the memory cache. This | 1232 // Let the browser know we loaded a resource from the memory cache. This |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 void RenderView::DidReceiveTitle(WebView* webview, | 1417 void RenderView::DidReceiveTitle(WebView* webview, |
| 1405 const std::wstring& title, | 1418 const std::wstring& title, |
| 1406 WebFrame* frame) { | 1419 WebFrame* frame) { |
| 1407 UpdateTitle(frame, title); | 1420 UpdateTitle(frame, title); |
| 1408 | 1421 |
| 1409 // Also check whether we have new encoding name. | 1422 // Also check whether we have new encoding name. |
| 1410 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); | 1423 UpdateEncoding(frame, webview->GetMainFrameEncodingName()); |
| 1411 } | 1424 } |
| 1412 | 1425 |
| 1413 void RenderView::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { | 1426 void RenderView::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { |
| 1427 if (webview->GetMainFrame() == frame) { |
| 1428 const GURL& url = frame->GetURL(); |
| 1429 if (url.SchemeIs("http") || url.SchemeIs("https")) |
| 1430 DumpLoadHistograms(); |
| 1431 } |
| 1414 } | 1432 } |
| 1415 | 1433 |
| 1416 void RenderView::DidFailLoadWithError(WebView* webview, | 1434 void RenderView::DidFailLoadWithError(WebView* webview, |
| 1417 const WebError& error, | 1435 const WebError& error, |
| 1418 WebFrame* frame) { | 1436 WebFrame* frame) { |
| 1419 } | 1437 } |
| 1420 | 1438 |
| 1421 void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, | 1439 void RenderView::DidFinishDocumentLoadForFrame(WebView* webview, |
| 1422 WebFrame* frame) { | 1440 WebFrame* frame) { |
| 1423 // Check whether we have new encoding name. | 1441 // Check whether we have new encoding name. |
| (...skipping 1557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 void RenderView::OnExtensionResponse(int callback_id, | 2999 void RenderView::OnExtensionResponse(int callback_id, |
| 2982 const std::string& response) { | 3000 const std::string& response) { |
| 2983 WebFrame* web_frame = pending_extension_callbacks_.Lookup(callback_id); | 3001 WebFrame* web_frame = pending_extension_callbacks_.Lookup(callback_id); |
| 2984 if (!web_frame) | 3002 if (!web_frame) |
| 2985 return; // The frame went away. | 3003 return; // The frame went away. |
| 2986 | 3004 |
| 2987 extensions_v8::ExtensionProcessBindings::ExecuteCallbackInFrame( | 3005 extensions_v8::ExtensionProcessBindings::ExecuteCallbackInFrame( |
| 2988 web_frame, callback_id, response); | 3006 web_frame, callback_id, response); |
| 2989 pending_extension_callbacks_.Remove(callback_id); | 3007 pending_extension_callbacks_.Remove(callback_id); |
| 2990 } | 3008 } |
| 3009 |
| 3010 // Dump all load time histograms. We create 2 sets time based histograms, |
| 3011 // one that is specific to the navigation type and one that aggregates all |
| 3012 // navigation types |
| 3013 // |
| 3014 // Each set contains 5 histograms measuring various times. |
| 3015 // The time points we keep are |
| 3016 // request: time document was requested by user |
| 3017 // start: time load of document started |
| 3018 // finishDoc: main document loaded, before onload() |
| 3019 // finish: after onload() and all resources are loaded |
| 3020 // finish_document_load_time and finish_load_time. |
| 3021 // The times that we histogram are |
| 3022 // requestToStart, |
| 3023 // startToFinishDoc, |
| 3024 // finishDocToFinish, |
| 3025 // startToFinish, |
| 3026 // requestToFinish, |
| 3027 // |
| 3028 void RenderView::DumpLoadHistograms() const { |
| 3029 WebFrame* main_frame = webview()->GetMainFrame(); |
| 3030 WebDataSource* ds = main_frame->GetDataSource(); |
| 3031 WebNavigationType nav_type = ds->GetNavigationType(); |
| 3032 Time request_time = ds->GetRequestTime(); |
| 3033 Time start_load_time = ds->GetStartLoadTime(); |
| 3034 Time finish_document_load_time = ds->GetFinishDocumentLoadTime(); |
| 3035 Time finish_load_time = ds->GetFinishLoadTime(); |
| 3036 TimeDelta request_to_start = start_load_time - request_time; |
| 3037 TimeDelta start_to_finish_doc = finish_document_load_time - start_load_time; |
| 3038 TimeDelta finish_doc_to_finish = finish_load_time - finish_document_load_time; |
| 3039 TimeDelta start_to_finish = finish_load_time - start_load_time; |
| 3040 TimeDelta request_to_finish = finish_load_time - start_load_time; |
| 3041 |
| 3042 UMA_HISTOGRAM_TIMES("Renderer.All.RequestToStart", request_to_start); |
| 3043 UMA_HISTOGRAM_TIMES("Renderer.All.StartToFinishDoc", start_to_finish_doc); |
| 3044 UMA_HISTOGRAM_TIMES("Renderer.All.FinishDocToFinish", finish_doc_to_finish); |
| 3045 UMA_HISTOGRAM_TIMES("Renderer.All.StartToFinish", start_to_finish); |
| 3046 UMA_HISTOGRAM_TIMES("Renderer.All.RequestToFinish", request_to_finish); |
| 3047 switch (nav_type) { |
| 3048 case WebNavigationTypeLinkClicked: |
| 3049 UMA_HISTOGRAM_TIMES( |
| 3050 "Renderer.LinkClicked.RequestToStart", request_to_start); |
| 3051 UMA_HISTOGRAM_TIMES( |
| 3052 "Renderer.LinkClicked.StartToFinishDoc", start_to_finish_doc); |
| 3053 UMA_HISTOGRAM_TIMES( |
| 3054 "Renderer.LinkClicked.FinishDocToFinish", finish_doc_to_finish); |
| 3055 UMA_HISTOGRAM_TIMES( |
| 3056 "Renderer.LinkClicked.RequestToFinish", request_to_finish); |
| 3057 UMA_HISTOGRAM_TIMES( |
| 3058 "Renderer.LinkClicked.StartToFinish", start_to_finish); |
| 3059 break; |
| 3060 case WebNavigationTypeFormSubmitted: |
| 3061 UMA_HISTOGRAM_TIMES( |
| 3062 "Renderer.FormSubmitted.RequestToStart", request_to_start); |
| 3063 UMA_HISTOGRAM_TIMES( |
| 3064 "Renderer.FormSubmitted.StartToFinishDoc", start_to_finish_doc); |
| 3065 UMA_HISTOGRAM_TIMES( |
| 3066 "Renderer.FormSubmitted.FinishDocToFinish", finish_doc_to_finish); |
| 3067 UMA_HISTOGRAM_TIMES( |
| 3068 "Renderer.FormSubmitted.RequestToFinish", request_to_finish); |
| 3069 UMA_HISTOGRAM_TIMES( |
| 3070 "Renderer.FormSubmitted.StartToFinish", start_to_finish); |
| 3071 break; |
| 3072 case WebNavigationTypeBackForward: |
| 3073 UMA_HISTOGRAM_TIMES( |
| 3074 "Renderer.BackForward.RequestToStart", request_to_start); |
| 3075 UMA_HISTOGRAM_TIMES( |
| 3076 "Renderer.BackForward.StartToFinishDoc", start_to_finish_doc); |
| 3077 UMA_HISTOGRAM_TIMES( |
| 3078 "Renderer.BackForward.FinishDocToFinish", finish_doc_to_finish); |
| 3079 UMA_HISTOGRAM_TIMES( |
| 3080 "Renderer.BackForward.RequestToFinish", request_to_finish); |
| 3081 UMA_HISTOGRAM_TIMES( |
| 3082 "Renderer.BackForward.StartToFinish", start_to_finish); |
| 3083 break; |
| 3084 case WebNavigationTypeReload: |
| 3085 UMA_HISTOGRAM_TIMES( |
| 3086 "Renderer.Reload.RequestToStart", request_to_start); |
| 3087 UMA_HISTOGRAM_TIMES( |
| 3088 "Renderer.Reload.StartToFinishDoc", start_to_finish_doc); |
| 3089 UMA_HISTOGRAM_TIMES( |
| 3090 "Renderer.Reload.FinishDocToFinish", finish_doc_to_finish); |
| 3091 UMA_HISTOGRAM_TIMES( |
| 3092 "Renderer.Reload.RequestToFinish", request_to_finish); |
| 3093 UMA_HISTOGRAM_TIMES( |
| 3094 "Renderer.Reload.StartToFinish", start_to_finish); |
| 3095 break; |
| 3096 case WebNavigationTypeFormResubmitted: |
| 3097 UMA_HISTOGRAM_TIMES( |
| 3098 "Renderer.FormResubmitted.RequestToStart", request_to_start); |
| 3099 UMA_HISTOGRAM_TIMES( |
| 3100 "Renderer.FormResubmitted.StartToFinishDoc", start_to_finish_doc); |
| 3101 UMA_HISTOGRAM_TIMES( |
| 3102 "Renderer.FormResubmitted.FinishDocToFinish", finish_doc_to_finish); |
| 3103 UMA_HISTOGRAM_TIMES( |
| 3104 "Renderer.FormResubmitted.RequestToFinish", request_to_finish); |
| 3105 UMA_HISTOGRAM_TIMES( |
| 3106 "Renderer.FormResubmitted.StartToFinish", start_to_finish); |
| 3107 break; |
| 3108 case WebNavigationTypeOther: |
| 3109 UMA_HISTOGRAM_TIMES( |
| 3110 "Renderer.Other.RequestToStart", request_to_start); |
| 3111 UMA_HISTOGRAM_TIMES( |
| 3112 "Renderer.Other.StartToFinishDoc", start_to_finish_doc); |
| 3113 UMA_HISTOGRAM_TIMES( |
| 3114 "Renderer.Other.FinishDocToFinish", finish_doc_to_finish); |
| 3115 UMA_HISTOGRAM_TIMES( |
| 3116 "Renderer.Other.RequestToFinish", request_to_finish); |
| 3117 UMA_HISTOGRAM_TIMES( |
| 3118 "Renderer.Other.StartToFinish", start_to_finish); |
| 3119 break; |
| 3120 } |
| 3121 } |
| OLD | NEW |