Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc

Issue 2331343005: PlzNavigate: Get StreamPrivate API to work. (Closed)
Patch Set: Fix DCHECK leading to browser test redness Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/loader/chrome_resource_dispatcher_host_delegate.h" 5 #include "chrome/browser/loader/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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "components/google/core/browser/google_util.h" 49 #include "components/google/core/browser/google_util.h"
50 #include "components/policy/core/common/cloud/policy_header_io_helper.h" 50 #include "components/policy/core/common/cloud/policy_header_io_helper.h"
51 #include "components/rappor/rappor_utils.h" 51 #include "components/rappor/rappor_utils.h"
52 #include "components/search_engines/template_url_service.h" 52 #include "components/search_engines/template_url_service.h"
53 #include "components/variations/net/variations_http_headers.h" 53 #include "components/variations/net/variations_http_headers.h"
54 #include "content/public/browser/browser_thread.h" 54 #include "content/public/browser/browser_thread.h"
55 #include "content/public/browser/navigation_data.h" 55 #include "content/public/browser/navigation_data.h"
56 #include "content/public/browser/notification_service.h" 56 #include "content/public/browser/notification_service.h"
57 #include "content/public/browser/plugin_service.h" 57 #include "content/public/browser/plugin_service.h"
58 #include "content/public/browser/plugin_service_filter.h" 58 #include "content/public/browser/plugin_service_filter.h"
59 #include "content/public/browser/render_frame_host.h"
59 #include "content/public/browser/render_process_host.h" 60 #include "content/public/browser/render_process_host.h"
60 #include "content/public/browser/render_view_host.h" 61 #include "content/public/browser/render_view_host.h"
61 #include "content/public/browser/resource_context.h" 62 #include "content/public/browser/resource_context.h"
62 #include "content/public/browser/resource_dispatcher_host.h" 63 #include "content/public/browser/resource_dispatcher_host.h"
63 #include "content/public/browser/resource_request_info.h" 64 #include "content/public/browser/resource_request_info.h"
64 #include "content/public/browser/service_worker_context.h" 65 #include "content/public/browser/service_worker_context.h"
65 #include "content/public/browser/stream_info.h" 66 #include "content/public/browser/stream_info.h"
66 #include "content/public/browser/web_contents.h" 67 #include "content/public/browser/web_contents.h"
67 #include "content/public/common/resource_response.h" 68 #include "content/public/common/resource_response.h"
68 #include "net/base/load_flags.h" 69 #include "net/base/load_flags.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 prerender::PrerenderManager* prerender_manager = 172 prerender::PrerenderManager* prerender_manager =
172 GetPrerenderManager(web_contents); 173 GetPrerenderManager(web_contents);
173 if (prerender_manager) 174 if (prerender_manager)
174 prerender_manager->AddProfileNetworkBytesIfEnabled(bytes); 175 prerender_manager->AddProfileNetworkBytesIfEnabled(bytes);
175 } 176 }
176 177
177 #if defined(ENABLE_EXTENSIONS) 178 #if defined(ENABLE_EXTENSIONS)
178 void SendExecuteMimeTypeHandlerEvent( 179 void SendExecuteMimeTypeHandlerEvent(
179 std::unique_ptr<content::StreamInfo> stream, 180 std::unique_ptr<content::StreamInfo> stream,
180 int64_t expected_content_size, 181 int64_t expected_content_size,
181 int render_process_id,
182 int render_frame_id,
183 const std::string& extension_id, 182 const std::string& extension_id,
184 const std::string& view_id, 183 const std::string& view_id,
185 bool embedded) { 184 bool embedded,
185 int frame_tree_node_id,
186 int render_process_id,
187 int render_frame_id) {
186 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 188 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
187 189
188 content::WebContents* web_contents = 190 content::WebContents* web_contents = nullptr;
189 tab_util::GetWebContentsByFrameID(render_process_id, render_frame_id); 191 if (frame_tree_node_id != -1) {
192 web_contents =
193 content::WebContents::FromFrameTreeNodeId(frame_tree_node_id);
194 } else {
195 web_contents = content::WebContents::FromRenderFrameHost(
196 content::RenderFrameHost::FromID(render_process_id, render_frame_id));
197 }
190 if (!web_contents) 198 if (!web_contents)
191 return; 199 return;
192 200
193 // If the request was for a prerender, abort the prerender and do not 201 // If the request was for a prerender, abort the prerender and do not
194 // continue. 202 // continue.
195 prerender::PrerenderContents* prerender_contents = 203 prerender::PrerenderContents* prerender_contents =
196 prerender::PrerenderContents::FromWebContents(web_contents); 204 prerender::PrerenderContents::FromWebContents(web_contents);
197 if (prerender_contents) { 205 if (prerender_contents) {
198 prerender_contents->Destroy(prerender::FINAL_STATUS_DOWNLOAD); 206 prerender_contents->Destroy(prerender::FINAL_STATUS_DOWNLOAD);
199 return; 207 return;
200 } 208 }
201 209
202 Profile* profile = 210 Profile* profile =
203 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 211 Profile::FromBrowserContext(web_contents->GetBrowserContext());
204 212
205 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile); 213 StreamsPrivateAPI* streams_private = StreamsPrivateAPI::Get(profile);
206 if (!streams_private) 214 if (!streams_private)
207 return; 215 return;
208 streams_private->ExecuteMimeTypeHandler( 216 streams_private->ExecuteMimeTypeHandler(
209 extension_id, web_contents, std::move(stream), view_id, 217 extension_id, std::move(stream), view_id, expected_content_size, embedded,
210 expected_content_size, embedded, render_process_id, render_frame_id); 218 frame_tree_node_id, render_process_id, render_frame_id);
211 } 219 }
212 #endif // !defined(ENABLE_EXTENSIONS) 220 #endif // !defined(ENABLE_EXTENSIONS)
213 221
214 void LaunchURL( 222 void LaunchURL(
215 const GURL& url, 223 const GURL& url,
216 int render_process_id, 224 int render_process_id,
217 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 225 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
218 ui::PageTransition page_transition, 226 ui::PageTransition page_transition,
219 bool has_user_gesture, 227 bool has_user_gesture,
220 bool is_whitelisted) { 228 bool is_whitelisted) {
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 std::unique_ptr<content::StreamInfo> stream) { 719 std::unique_ptr<content::StreamInfo> stream) {
712 #if defined(ENABLE_EXTENSIONS) 720 #if defined(ENABLE_EXTENSIONS)
713 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 721 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
714 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix = 722 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix =
715 stream_target_info_.find(request); 723 stream_target_info_.find(request);
716 CHECK(ix != stream_target_info_.end()); 724 CHECK(ix != stream_target_info_.end());
717 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; 725 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME;
718 content::BrowserThread::PostTask( 726 content::BrowserThread::PostTask(
719 content::BrowserThread::UI, FROM_HERE, 727 content::BrowserThread::UI, FROM_HERE,
720 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), 728 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream),
721 request->GetExpectedContentSize(), info->GetChildID(), 729 request->GetExpectedContentSize(), ix->second.extension_id,
722 info->GetRenderFrameID(), ix->second.extension_id, 730 ix->second.view_id, embedded, info->GetFrameTreeNodeId(),
723 ix->second.view_id, embedded)); 731 info->GetChildID(), info->GetRenderFrameID()));
724 stream_target_info_.erase(request); 732 stream_target_info_.erase(request);
725 #endif 733 #endif
726 } 734 }
727 735
728 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( 736 void ChromeResourceDispatcherHostDelegate::OnResponseStarted(
729 net::URLRequest* request, 737 net::URLRequest* request,
730 content::ResourceContext* resource_context, 738 content::ResourceContext* resource_context,
731 content::ResourceResponse* response) { 739 content::ResourceResponse* response) {
732 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 740 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
733 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 741 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 869 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
862 base::Unretained(this), url, request_loading_time)); 870 base::Unretained(this), url, request_loading_time));
863 return; 871 return;
864 } 872 }
865 873
866 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 874 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
867 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 875 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
868 rappor::SampleDomainAndRegistryFromGURL( 876 rappor::SampleDomainAndRegistryFromGURL(
869 g_browser_process->rappor_service(), metric_name, url); 877 g_browser_process->rappor_service(), metric_name, url);
870 } 878 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698