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

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

Issue 481593002: Remove child/route parameters from ShouldBeginRequest and RequestBeginning. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android build Created 6 years, 4 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 | Annotate | Revision Log
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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 prerender_tracker_(prerender_tracker) { 264 prerender_tracker_(prerender_tracker) {
265 } 265 }
266 266
267 ChromeResourceDispatcherHostDelegate::~ChromeResourceDispatcherHostDelegate() { 267 ChromeResourceDispatcherHostDelegate::~ChromeResourceDispatcherHostDelegate() {
268 #if defined(ENABLE_EXTENSIONS) 268 #if defined(ENABLE_EXTENSIONS)
269 CHECK(stream_target_info_.empty()); 269 CHECK(stream_target_info_.empty());
270 #endif 270 #endif
271 } 271 }
272 272
273 bool ChromeResourceDispatcherHostDelegate::ShouldBeginRequest( 273 bool ChromeResourceDispatcherHostDelegate::ShouldBeginRequest(
274 int child_id,
275 int route_id,
276 const std::string& method, 274 const std::string& method,
277 const GURL& url, 275 const GURL& url,
278 ResourceType resource_type, 276 ResourceType resource_type,
279 content::ResourceContext* resource_context) { 277 content::ResourceContext* resource_context) {
280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
281 279
282 // Handle a PREFETCH resource type. If prefetch is disabled, squelch the 280 // Handle a PREFETCH resource type. If prefetch is disabled, squelch the
283 // request. Otherwise, do a normal request to warm the cache. 281 // request. Otherwise, do a normal request to warm the cache.
284 if (resource_type == content::RESOURCE_TYPE_PREFETCH) { 282 if (resource_type == content::RESOURCE_TYPE_PREFETCH) {
285 // All PREFETCH requests should be GETs, but be defensive about it. 283 // All PREFETCH requests should be GETs, but be defensive about it.
286 if (method != "GET") 284 if (method != "GET")
287 return false; 285 return false;
288 286
289 // If prefetch is disabled, kill the request. 287 // If prefetch is disabled, kill the request.
290 if (!prefetch::IsPrefetchEnabled(resource_context)) 288 if (!prefetch::IsPrefetchEnabled(resource_context))
291 return false; 289 return false;
292 } 290 }
293 291
294 return true; 292 return true;
295 } 293 }
296 294
297 void ChromeResourceDispatcherHostDelegate::RequestBeginning( 295 void ChromeResourceDispatcherHostDelegate::RequestBeginning(
298 net::URLRequest* request, 296 net::URLRequest* request,
299 content::ResourceContext* resource_context, 297 content::ResourceContext* resource_context,
300 content::AppCacheService* appcache_service, 298 content::AppCacheService* appcache_service,
301 ResourceType resource_type, 299 ResourceType resource_type,
302 int child_id,
303 int route_id,
304 ScopedVector<content::ResourceThrottle>* throttles) { 300 ScopedVector<content::ResourceThrottle>* throttles) {
305 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 301 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
306 bool is_prerendering = 302 bool is_prerendering =
307 info->GetVisibilityState() == blink::WebPageVisibilityStatePrerender; 303 info->GetVisibilityState() == blink::WebPageVisibilityStatePrerender;
308 if (is_prerendering) { 304 if (is_prerendering) {
309 // Requests with the IGNORE_LIMITS flag set (i.e., sync XHRs) 305 // Requests with the IGNORE_LIMITS flag set (i.e., sync XHRs)
310 // should remain at MAXIMUM_PRIORITY. 306 // should remain at MAXIMUM_PRIORITY.
311 if (request->load_flags() & net::LOAD_IGNORE_LIMITS) { 307 if (request->load_flags() & net::LOAD_IGNORE_LIMITS) {
312 DCHECK_EQ(request->priority(), net::MAXIMUM_PRIORITY); 308 DCHECK_EQ(request->priority(), net::MAXIMUM_PRIORITY);
313 } else { 309 } else {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 #if defined(ENABLE_ONE_CLICK_SIGNIN) 384 #if defined(ENABLE_ONE_CLICK_SIGNIN)
389 AppendChromeSyncGaiaHeader(request, resource_context); 385 AppendChromeSyncGaiaHeader(request, resource_context);
390 #endif 386 #endif
391 387
392 #if defined(ENABLE_CONFIGURATION_POLICY) 388 #if defined(ENABLE_CONFIGURATION_POLICY)
393 if (io_data->policy_header_helper()) 389 if (io_data->policy_header_helper())
394 io_data->policy_header_helper()->AddPolicyHeaders(request->url(), request); 390 io_data->policy_header_helper()->AddPolicyHeaders(request->url(), request);
395 #endif 391 #endif
396 392
397 signin::AppendMirrorRequestHeaderIfPossible( 393 signin::AppendMirrorRequestHeaderIfPossible(
398 request, GURL() /* redirect_url */, 394 request, GURL() /* redirect_url */, io_data);
399 io_data, info->GetChildID(), info->GetRouteID());
400 395
401 AppendStandardResourceThrottles(request, 396 AppendStandardResourceThrottles(request,
402 resource_context, 397 resource_context,
403 resource_type, 398 resource_type,
404 throttles); 399 throttles);
405 if (!is_prerendering) { 400 if (!is_prerendering) {
406 AppendComponentUpdaterThrottles(request, 401 AppendComponentUpdaterThrottles(request,
407 resource_context, 402 resource_context,
408 resource_type, 403 resource_type,
409 throttles); 404 throttles);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 680
686 prerender::URLRequestResponseStarted(request); 681 prerender::URLRequestResponseStarted(request);
687 } 682 }
688 683
689 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( 684 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected(
690 const GURL& redirect_url, 685 const GURL& redirect_url,
691 net::URLRequest* request, 686 net::URLRequest* request,
692 content::ResourceContext* resource_context, 687 content::ResourceContext* resource_context,
693 content::ResourceResponse* response) { 688 content::ResourceResponse* response) {
694 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 689 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
690
691 #if defined(ENABLE_ONE_CLICK_SIGNIN)
695 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 692 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
696 693
697 #if defined(ENABLE_ONE_CLICK_SIGNIN)
698 // See if the response contains the Google-Accounts-SignIn header. If so, 694 // See if the response contains the Google-Accounts-SignIn header. If so,
699 // then the user has just finished signing in, and the server is allowing the 695 // then the user has just finished signing in, and the server is allowing the
700 // browser to suggest connecting the user's profile to the account. 696 // browser to suggest connecting the user's profile to the account.
701 OneClickSigninHelper::ShowInfoBarIfPossible(request, io_data, 697 OneClickSigninHelper::ShowInfoBarIfPossible(request, io_data,
702 info->GetChildID(), 698 info->GetChildID(),
703 info->GetRouteID()); 699 info->GetRouteID());
704 AppendChromeSyncGaiaHeader(request, resource_context); 700 AppendChromeSyncGaiaHeader(request, resource_context);
705 #endif 701 #endif
706 702
707 // In the Mirror world, Chrome should append a X-Chrome-Connected header to 703 // In the Mirror world, Chrome should append a X-Chrome-Connected header to
708 // all Gaia requests from a connected profile so Gaia could return a 204 704 // all Gaia requests from a connected profile so Gaia could return a 204
709 // response and let Chrome handle the action with native UI. The only 705 // response and let Chrome handle the action with native UI. The only
710 // exception is requests from gaia webview, since the native profile 706 // exception is requests from gaia webview, since the native profile
711 // management UI is built on top of it. 707 // management UI is built on top of it.
712 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data, 708 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data);
713 info->GetChildID(), info->GetRouteID());
714 709
715 #if defined(ENABLE_CONFIGURATION_POLICY) 710 #if defined(ENABLE_CONFIGURATION_POLICY)
716 if (io_data->policy_header_helper()) 711 if (io_data->policy_header_helper())
717 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request); 712 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request);
718 #endif 713 #endif
719 } 714 }
720 715
721 // Notification that a request has completed. 716 // Notification that a request has completed.
722 void ChromeResourceDispatcherHostDelegate::RequestComplete( 717 void ChromeResourceDispatcherHostDelegate::RequestComplete(
723 net::URLRequest* url_request) { 718 net::URLRequest* url_request) {
724 // Jump on the UI thread and inform the prerender about the bytes. 719 // Jump on the UI thread and inform the prerender about the bytes.
725 const ResourceRequestInfo* info = 720 const ResourceRequestInfo* info =
726 ResourceRequestInfo::ForRequest(url_request); 721 ResourceRequestInfo::ForRequest(url_request);
727 if (url_request && !url_request->was_cached()) { 722 if (url_request && !url_request->was_cached()) {
728 BrowserThread::PostTask(BrowserThread::UI, 723 BrowserThread::PostTask(BrowserThread::UI,
729 FROM_HERE, 724 FROM_HERE,
730 base::Bind(&UpdatePrerenderNetworkBytesCallback, 725 base::Bind(&UpdatePrerenderNetworkBytesCallback,
731 info->GetChildID(), 726 info->GetChildID(),
732 info->GetRouteID(), 727 info->GetRouteID(),
733 url_request->GetTotalReceivedBytes())); 728 url_request->GetTotalReceivedBytes()));
734 } 729 }
735 } 730 }
736 731
737 // static 732 // static
738 void ChromeResourceDispatcherHostDelegate:: 733 void ChromeResourceDispatcherHostDelegate::
739 SetExternalProtocolHandlerDelegateForTesting( 734 SetExternalProtocolHandlerDelegateForTesting(
740 ExternalProtocolHandler::Delegate* delegate) { 735 ExternalProtocolHandler::Delegate* delegate) {
741 g_external_protocol_handler_delegate = delegate; 736 g_external_protocol_handler_delegate = delegate;
742 } 737 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698