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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 | 714 |
713 void ChromeResourceDispatcherHostDelegate::OnStreamCreated( | 715 void ChromeResourceDispatcherHostDelegate::OnStreamCreated( |
714 net::URLRequest* request, | 716 net::URLRequest* request, |
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; |
724 // TODO(ananta) | |
725 // We are passing in the frame_tree_node_id which only makes sense in the | |
726 // PlzNavigate case and the render_frame_id and render_process_id which makes | |
727 // sense in the non PlzNavigate case. | |
728 // We need to remove the render_frame_id and render_process_id parameters | |
729 // when PlzNavigate is enabled by default. | |
jam
2016/09/17 00:10:07
ditto: even with plznavigate, i believe the RFIDs
ananta
2016/09/17 00:23:27
Thanks. Removed the comment.
| |
722 content::BrowserThread::PostTask( | 730 content::BrowserThread::PostTask( |
723 content::BrowserThread::UI, FROM_HERE, | 731 content::BrowserThread::UI, FROM_HERE, |
724 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), | 732 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), |
725 request->GetExpectedContentSize(), info->GetChildID(), | 733 request->GetExpectedContentSize(), ix->second.extension_id, |
726 info->GetRenderFrameID(), ix->second.extension_id, | 734 ix->second.view_id, embedded, |
727 ix->second.view_id, embedded)); | 735 info->GetWebContentsGetterForRequest(), |
736 info->GetFrameTreeNodeId(), | |
737 info->GetChildID(), | |
738 info->GetRenderFrameID())); | |
728 stream_target_info_.erase(request); | 739 stream_target_info_.erase(request); |
729 #endif | 740 #endif |
730 } | 741 } |
731 | 742 |
732 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( | 743 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( |
733 net::URLRequest* request, | 744 net::URLRequest* request, |
734 content::ResourceContext* resource_context, | 745 content::ResourceContext* resource_context, |
735 content::ResourceResponse* response) { | 746 content::ResourceResponse* response) { |
736 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 747 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
737 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 748 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, | 890 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
880 base::Unretained(this), url, request_loading_time)); | 891 base::Unretained(this), url, request_loading_time)); |
881 return; | 892 return; |
882 } | 893 } |
883 | 894 |
884 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 895 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
885 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 896 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
886 rappor::SampleDomainAndRegistryFromGURL( | 897 rappor::SampleDomainAndRegistryFromGURL( |
887 g_browser_process->rappor_service(), metric_name, url); | 898 g_browser_process->rappor_service(), metric_name, url); |
888 } | 899 } |
OLD | NEW |