| 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/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 prerender::PrerenderManager* prerender_manager = | 174 prerender::PrerenderManager* prerender_manager = |
| 175 GetPrerenderManager(web_contents); | 175 GetPrerenderManager(web_contents); |
| 176 if (prerender_manager) | 176 if (prerender_manager) |
| 177 prerender_manager->AddProfileNetworkBytesIfEnabled(bytes); | 177 prerender_manager->AddProfileNetworkBytesIfEnabled(bytes); |
| 178 } | 178 } |
| 179 | 179 |
| 180 #if defined(ENABLE_EXTENSIONS) | 180 #if defined(ENABLE_EXTENSIONS) |
| 181 void SendExecuteMimeTypeHandlerEvent( | 181 void SendExecuteMimeTypeHandlerEvent( |
| 182 std::unique_ptr<content::StreamInfo> stream, | 182 std::unique_ptr<content::StreamInfo> stream, |
| 183 int64_t expected_content_size, | 183 int64_t expected_content_size, |
| 184 int render_process_id, | |
| 185 int render_frame_id, | |
| 186 const std::string& extension_id, | 184 const std::string& extension_id, |
| 187 const std::string& view_id, | 185 const std::string& view_id, |
| 188 bool embedded) { | 186 bool embedded, |
| 187 const ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| 188 int frame_tree_node_id, |
| 189 int render_process_id, |
| 190 int render_frame_id) { |
| 189 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 191 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 190 | 192 |
| 191 content::WebContents* web_contents = | 193 content::WebContents* web_contents = web_contents_getter.Run(); |
| 192 tab_util::GetWebContentsByFrameID(render_process_id, render_frame_id); | |
| 193 if (!web_contents) | 194 if (!web_contents) |
| 194 return; | 195 return; |
| 195 | 196 |
| 196 // If the request was for a prerender, abort the prerender and do not | 197 // If the request was for a prerender, abort the prerender and do not |
| 197 // continue. | 198 // continue. |
| 198 prerender::PrerenderContents* prerender_contents = | 199 prerender::PrerenderContents* prerender_contents = |
| 199 prerender::PrerenderContents::FromWebContents(web_contents); | 200 prerender::PrerenderContents::FromWebContents(web_contents); |
| 200 if (prerender_contents) { | 201 if (prerender_contents) { |
| 201 prerender_contents->Destroy(prerender::FINAL_STATUS_DOWNLOAD); | 202 prerender_contents->Destroy(prerender::FINAL_STATUS_DOWNLOAD); |
| 202 return; | 203 return; |
| 203 } | 204 } |
| 204 | 205 |
| 205 Profile* profile = | 206 Profile* profile = |
| 206 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 207 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 207 | 208 |
| 208 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); | 209 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); |
| 209 if (!streams_private) | 210 if (!streams_private) |
| 210 return; | 211 return; |
| 211 streams_private->ExecuteMimeTypeHandler( | 212 streams_private->ExecuteMimeTypeHandler( |
| 212 extension_id, web_contents, std::move(stream), view_id, | 213 extension_id, web_contents, std::move(stream), view_id, |
| 213 expected_content_size, embedded, render_process_id, render_frame_id); | 214 expected_content_size, embedded, frame_tree_node_id, render_process_id, |
| 215 render_frame_id); |
| 214 } | 216 } |
| 215 #endif // !defined(ENABLE_EXTENSIONS) | 217 #endif // !defined(ENABLE_EXTENSIONS) |
| 216 | 218 |
| 217 void LaunchURL( | 219 void LaunchURL( |
| 218 const GURL& url, | 220 const GURL& url, |
| 219 int render_process_id, | 221 int render_process_id, |
| 220 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 222 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| 221 ui::PageTransition page_transition, | 223 ui::PageTransition page_transition, |
| 222 bool has_user_gesture, | 224 bool has_user_gesture, |
| 223 bool is_whitelisted) { | 225 bool is_whitelisted) { |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 std::unique_ptr<content::StreamInfo> stream) { | 717 std::unique_ptr<content::StreamInfo> stream) { |
| 716 #if defined(ENABLE_EXTENSIONS) | 718 #if defined(ENABLE_EXTENSIONS) |
| 717 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 719 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 718 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix = | 720 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix = |
| 719 stream_target_info_.find(request); | 721 stream_target_info_.find(request); |
| 720 CHECK(ix != stream_target_info_.end()); | 722 CHECK(ix != stream_target_info_.end()); |
| 721 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; | 723 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; |
| 722 content::BrowserThread::PostTask( | 724 content::BrowserThread::PostTask( |
| 723 content::BrowserThread::UI, FROM_HERE, | 725 content::BrowserThread::UI, FROM_HERE, |
| 724 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), | 726 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), |
| 725 request->GetExpectedContentSize(), info->GetChildID(), | 727 request->GetExpectedContentSize(), ix->second.extension_id, |
| 726 info->GetRenderFrameID(), ix->second.extension_id, | 728 ix->second.view_id, embedded, |
| 727 ix->second.view_id, embedded)); | 729 info->GetWebContentsGetterForRequest(), |
| 730 info->GetFrameTreeNodeId(), |
| 731 info->GetChildID(), |
| 732 info->GetRenderFrameID())); |
| 728 stream_target_info_.erase(request); | 733 stream_target_info_.erase(request); |
| 729 #endif | 734 #endif |
| 730 } | 735 } |
| 731 | 736 |
| 732 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( | 737 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( |
| 733 net::URLRequest* request, | 738 net::URLRequest* request, |
| 734 content::ResourceContext* resource_context, | 739 content::ResourceContext* resource_context, |
| 735 content::ResourceResponse* response) { | 740 content::ResourceResponse* response) { |
| 736 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 741 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 737 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 742 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 884 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 880 base::Unretained(this), url, request_loading_time)); | 885 base::Unretained(this), url, request_loading_time)); |
| 881 return; | 886 return; |
| 882 } | 887 } |
| 883 | 888 |
| 884 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 889 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 885 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 890 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 886 rappor::SampleDomainAndRegistryFromGURL( | 891 rappor::SampleDomainAndRegistryFromGURL( |
| 887 g_browser_process->rappor_service(), metric_name, url); | 892 g_browser_process->rappor_service(), metric_name, url); |
| 888 } | 893 } |
| OLD | NEW |