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

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

Issue 2334603002: Fix SSLUITest.TestBadHTTPSDownload with PlzNavigate. (Closed)
Patch Set: fix android temporarily 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 #endif 125 #endif
126 126
127 #if defined(OS_ANDROID) 127 #if defined(OS_ANDROID)
128 using navigation_interception::InterceptNavigationDelegate; 128 using navigation_interception::InterceptNavigationDelegate;
129 #endif 129 #endif
130 130
131 namespace { 131 namespace {
132 132
133 ExternalProtocolHandler::Delegate* g_external_protocol_handler_delegate = NULL; 133 ExternalProtocolHandler::Delegate* g_external_protocol_handler_delegate = NULL;
134 134
135 void NotifyDownloadInitiatedOnUI(int render_process_id, int render_view_id) { 135 void NotifyDownloadInitiatedOnUI(
136 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, 136 const content::ResourceRequestInfo::WebContentsGetter& wc_getter) {
137 render_view_id); 137 content::WebContents* web_contents = wc_getter.Run();
138 if (!rvh) 138 if (!web_contents)
139 return; 139 return;
140 140
141 content::NotificationService::current()->Notify( 141 content::NotificationService::current()->Notify(
142 chrome::NOTIFICATION_DOWNLOAD_INITIATED, 142 chrome::NOTIFICATION_DOWNLOAD_INITIATED,
143 content::Source<RenderViewHost>(rvh), 143 content::Source<content::WebContents>(web_contents),
144 content::NotificationService::NoDetails()); 144 content::NotificationService::NoDetails());
145 } 145 }
146 146
147 prerender::PrerenderManager* GetPrerenderManager( 147 prerender::PrerenderManager* GetPrerenderManager(
148 content::WebContents* web_contents) { 148 content::WebContents* web_contents) {
149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
150 if (!web_contents) 150 if (!web_contents)
151 return NULL; 151 return NULL;
152 152
153 content::BrowserContext* browser_context = web_contents->GetBrowserContext(); 153 content::BrowserContext* browser_context = web_contents->GetBrowserContext();
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 491
492 if (io_data->resource_prefetch_predictor_observer()) { 492 if (io_data->resource_prefetch_predictor_observer()) {
493 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( 493 io_data->resource_prefetch_predictor_observer()->OnRequestStarted(
494 request, resource_type, info->GetChildID(), info->GetRenderFrameID()); 494 request, resource_type, info->GetChildID(), info->GetRenderFrameID());
495 } 495 }
496 } 496 }
497 497
498 void ChromeResourceDispatcherHostDelegate::DownloadStarting( 498 void ChromeResourceDispatcherHostDelegate::DownloadStarting(
499 net::URLRequest* request, 499 net::URLRequest* request,
500 content::ResourceContext* resource_context, 500 content::ResourceContext* resource_context,
501 int child_id,
502 int route_id,
503 bool is_content_initiated, 501 bool is_content_initiated,
504 bool must_download, 502 bool must_download,
505 ScopedVector<content::ResourceThrottle>* throttles) { 503 ScopedVector<content::ResourceThrottle>* throttles) {
504 const content::ResourceRequestInfo* info =
505 content::ResourceRequestInfo::ForRequest(request);
506 BrowserThread::PostTask( 506 BrowserThread::PostTask(
507 BrowserThread::UI, FROM_HERE, 507 BrowserThread::UI, FROM_HERE,
508 base::Bind(&NotifyDownloadInitiatedOnUI, child_id, route_id)); 508 base::Bind(&NotifyDownloadInitiatedOnUI,
509 info->GetWebContentsGetterForRequest()));
509 510
510 // If it's from the web, we don't trust it, so we push the throttle on. 511 // If it's from the web, we don't trust it, so we push the throttle on.
511 if (is_content_initiated) { 512 if (is_content_initiated) {
512 const content::ResourceRequestInfo* info =
513 content::ResourceRequestInfo::ForRequest(request);
514 throttles->push_back(new DownloadResourceThrottle( 513 throttles->push_back(new DownloadResourceThrottle(
515 download_request_limiter_, info->GetWebContentsGetterForRequest(), 514 download_request_limiter_, info->GetWebContentsGetterForRequest(),
516 request->url(), request->method())); 515 request->url(), request->method()));
517 #if BUILDFLAG(ANDROID_JAVA_UI) 516 #if BUILDFLAG(ANDROID_JAVA_UI)
518 throttles->push_back( 517 throttles->push_back(
519 new chrome::InterceptDownloadResourceThrottle( 518 new chrome::InterceptDownloadResourceThrottle(
520 request, child_id, route_id, must_download)); 519 request, info->GetWebContentsGetterForRequest(), must_download));
521 #endif 520 #endif
522 } 521 }
523 522
524 // If this isn't a new request, we've seen this before and added the standard 523 // If this isn't a new request, we've seen this before and added the standard
525 // resource throttles already so no need to add it again. 524 // resource throttles already so no need to add it again.
526 if (!request->is_pending()) { 525 if (!request->is_pending()) {
527 AppendStandardResourceThrottles(request, 526 AppendStandardResourceThrottles(request,
528 resource_context, 527 resource_context,
529 content::RESOURCE_TYPE_MAIN_FRAME, 528 content::RESOURCE_TYPE_MAIN_FRAME,
530 throttles); 529 throttles);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 878 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
880 base::Unretained(this), url, request_loading_time)); 879 base::Unretained(this), url, request_loading_time));
881 return; 880 return;
882 } 881 }
883 882
884 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 883 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
885 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 884 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
886 rappor::SampleDomainAndRegistryFromGURL( 885 rappor::SampleDomainAndRegistryFromGURL(
887 g_browser_process->rappor_service(), metric_name, url); 886 g_browser_process->rappor_service(), metric_name, url);
888 } 887 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698