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

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

Issue 2331343005: PlzNavigate: Get StreamPrivate API to work. (Closed)
Patch Set: 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/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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_process_host.h" 59 #include "content/public/browser/render_process_host.h"
60 #include "content/public/browser/render_view_host.h" 60 #include "content/public/browser/render_view_host.h"
61 #include "content/public/browser/resource_context.h" 61 #include "content/public/browser/resource_context.h"
62 #include "content/public/browser/resource_dispatcher_host.h" 62 #include "content/public/browser/resource_dispatcher_host.h"
63 #include "content/public/browser/resource_request_info.h" 63 #include "content/public/browser/resource_request_info.h"
64 #include "content/public/browser/service_worker_context.h" 64 #include "content/public/browser/service_worker_context.h"
65 #include "content/public/browser/stream_info.h" 65 #include "content/public/browser/stream_info.h"
66 #include "content/public/browser/web_contents.h" 66 #include "content/public/browser/web_contents.h"
67 #include "content/public/common/browser_side_navigation_policy.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"
69 #include "net/base/load_timing_info.h" 70 #include "net/base/load_timing_info.h"
70 #include "net/base/request_priority.h" 71 #include "net/base/request_priority.h"
71 #include "net/http/http_response_headers.h" 72 #include "net/http/http_response_headers.h"
72 #include "net/ssl/client_cert_store.h" 73 #include "net/ssl/client_cert_store.h"
73 #include "net/url_request/url_request.h" 74 #include "net/url_request/url_request.h"
74 75
75 #if !defined(DISABLE_NACL) 76 #if !defined(DISABLE_NACL)
76 #include "chrome/browser/component_updater/pnacl_component_installer.h" 77 #include "chrome/browser/component_updater/pnacl_component_installer.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 179 }
179 180
180 #if defined(ENABLE_EXTENSIONS) 181 #if defined(ENABLE_EXTENSIONS)
181 void SendExecuteMimeTypeHandlerEvent( 182 void SendExecuteMimeTypeHandlerEvent(
182 std::unique_ptr<content::StreamInfo> stream, 183 std::unique_ptr<content::StreamInfo> stream,
183 int64_t expected_content_size, 184 int64_t expected_content_size,
184 int render_process_id, 185 int render_process_id,
185 int render_frame_id, 186 int render_frame_id,
186 const std::string& extension_id, 187 const std::string& extension_id,
187 const std::string& view_id, 188 const std::string& view_id,
188 bool embedded) { 189 bool embedded,
190 const ResourceRequestInfo::WebContentsGetter& web_contents_getter) {
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 = nullptr;
192 tab_util::GetWebContentsByFrameID(render_process_id, render_frame_id); 194 if (content::IsBrowserSideNavigationEnabled()) {
195 web_contents = web_contents_getter.Run();
196 } else {
197 web_contents =
198 tab_util::GetWebContentsByFrameID(render_process_id, render_frame_id);
199 }
193 if (!web_contents) 200 if (!web_contents)
194 return; 201 return;
195 202
196 // If the request was for a prerender, abort the prerender and do not 203 // If the request was for a prerender, abort the prerender and do not
197 // continue. 204 // continue.
198 prerender::PrerenderContents* prerender_contents = 205 prerender::PrerenderContents* prerender_contents =
199 prerender::PrerenderContents::FromWebContents(web_contents); 206 prerender::PrerenderContents::FromWebContents(web_contents);
200 if (prerender_contents) { 207 if (prerender_contents) {
201 prerender_contents->Destroy(prerender::FINAL_STATUS_DOWNLOAD); 208 prerender_contents->Destroy(prerender::FINAL_STATUS_DOWNLOAD);
202 return; 209 return;
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 724 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
718 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix = 725 std::map<net::URLRequest*, StreamTargetInfo>::iterator ix =
719 stream_target_info_.find(request); 726 stream_target_info_.find(request);
720 CHECK(ix != stream_target_info_.end()); 727 CHECK(ix != stream_target_info_.end());
721 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME; 728 bool embedded = info->GetResourceType() != content::RESOURCE_TYPE_MAIN_FRAME;
722 content::BrowserThread::PostTask( 729 content::BrowserThread::PostTask(
723 content::BrowserThread::UI, FROM_HERE, 730 content::BrowserThread::UI, FROM_HERE,
724 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream), 731 base::Bind(&SendExecuteMimeTypeHandlerEvent, base::Passed(&stream),
725 request->GetExpectedContentSize(), info->GetChildID(), 732 request->GetExpectedContentSize(), info->GetChildID(),
726 info->GetRenderFrameID(), ix->second.extension_id, 733 info->GetRenderFrameID(), ix->second.extension_id,
727 ix->second.view_id, embedded)); 734 ix->second.view_id, embedded,
735 info->GetWebContentsGetterForRequest()));
jam 2016/09/14 22:49:52 ditto: let's just pass only the WC getter
ananta 2016/09/15 01:49:16 Done.
728 stream_target_info_.erase(request); 736 stream_target_info_.erase(request);
729 #endif 737 #endif
730 } 738 }
731 739
732 void ChromeResourceDispatcherHostDelegate::OnResponseStarted( 740 void ChromeResourceDispatcherHostDelegate::OnResponseStarted(
733 net::URLRequest* request, 741 net::URLRequest* request,
734 content::ResourceContext* resource_context, 742 content::ResourceContext* resource_context,
735 content::ResourceResponse* response) { 743 content::ResourceResponse* response) {
736 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 744 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
737 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 745 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 887 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
880 base::Unretained(this), url, request_loading_time)); 888 base::Unretained(this), url, request_loading_time));
881 return; 889 return;
882 } 890 }
883 891
884 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 892 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
885 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 893 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
886 rappor::SampleDomainAndRegistryFromGURL( 894 rappor::SampleDomainAndRegistryFromGURL(
887 g_browser_process->rappor_service(), metric_name, url); 895 g_browser_process->rappor_service(), metric_name, url);
888 } 896 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698