| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 249 } |
| 250 | 250 |
| 251 void ChromeResourceDispatcherHostDelegate::RequestBeginning( | 251 void ChromeResourceDispatcherHostDelegate::RequestBeginning( |
| 252 net::URLRequest* request, | 252 net::URLRequest* request, |
| 253 content::ResourceContext* resource_context, | 253 content::ResourceContext* resource_context, |
| 254 appcache::AppCacheService* appcache_service, | 254 appcache::AppCacheService* appcache_service, |
| 255 ResourceType::Type resource_type, | 255 ResourceType::Type resource_type, |
| 256 int child_id, | 256 int child_id, |
| 257 int route_id, | 257 int route_id, |
| 258 ScopedVector<content::ResourceThrottle>* throttles) { | 258 ScopedVector<content::ResourceThrottle>* throttles) { |
| 259 bool is_prerendering = prerender_tracker_->IsPrerenderingOnIOThread( | 259 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 260 child_id, route_id); | 260 bool is_prerendering = |
| 261 info->GetVisibilityState() == blink::WebPageVisibilityStatePrerender; |
| 261 if (is_prerendering) { | 262 if (is_prerendering) { |
| 262 // Requests with the IGNORE_LIMITS flag set (i.e., sync XHRs) | 263 // Requests with the IGNORE_LIMITS flag set (i.e., sync XHRs) |
| 263 // should remain at MAXIMUM_PRIORITY. | 264 // should remain at MAXIMUM_PRIORITY. |
| 264 if (request->load_flags() & net::LOAD_IGNORE_LIMITS) { | 265 if (request->load_flags() & net::LOAD_IGNORE_LIMITS) { |
| 265 DCHECK_EQ(request->priority(), net::MAXIMUM_PRIORITY); | 266 DCHECK_EQ(request->priority(), net::MAXIMUM_PRIORITY); |
| 266 } else { | 267 } else { |
| 267 request->SetPriority(net::IDLE); | 268 request->SetPriority(net::IDLE); |
| 268 } | 269 } |
| 269 } | 270 } |
| 270 | 271 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 327 |
| 327 #if defined(ENABLE_ONE_CLICK_SIGNIN) | 328 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 328 AppendChromeSyncGaiaHeader(request, resource_context); | 329 AppendChromeSyncGaiaHeader(request, resource_context); |
| 329 #endif | 330 #endif |
| 330 | 331 |
| 331 #if defined(ENABLE_CONFIGURATION_POLICY) | 332 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 332 if (io_data->policy_header_helper()) | 333 if (io_data->policy_header_helper()) |
| 333 io_data->policy_header_helper()->AddPolicyHeaders(request); | 334 io_data->policy_header_helper()->AddPolicyHeaders(request); |
| 334 #endif | 335 #endif |
| 335 | 336 |
| 336 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | |
| 337 signin::AppendMirrorRequestHeaderIfPossible( | 337 signin::AppendMirrorRequestHeaderIfPossible( |
| 338 request, GURL() /* redirect_url */, | 338 request, GURL() /* redirect_url */, |
| 339 io_data, info->GetChildID(), info->GetRouteID()); | 339 io_data, info->GetChildID(), info->GetRouteID()); |
| 340 | 340 |
| 341 AppendStandardResourceThrottles(request, | 341 AppendStandardResourceThrottles(request, |
| 342 resource_context, | 342 resource_context, |
| 343 resource_type, | 343 resource_type, |
| 344 throttles); | 344 throttles); |
| 345 if (!is_prerendering) { | 345 if (!is_prerendering) { |
| 346 AppendComponentUpdaterThrottles(request, | 346 AppendComponentUpdaterThrottles(request, |
| 347 resource_context, | 347 resource_context, |
| 348 resource_type, | 348 resource_type, |
| 349 throttles); | 349 throttles); |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 void ChromeResourceDispatcherHostDelegate::WillTransferRequestToNewProcess( | |
| 354 int old_child_id, | |
| 355 int old_route_id, | |
| 356 int old_request_id, | |
| 357 int new_child_id, | |
| 358 int new_route_id, | |
| 359 int new_request_id) { | |
| 360 // If a prerender, it have should been aborted on cross-process | |
| 361 // navigation in PrerenderContents::WebContentsImpl::OpenURLFromTab. | |
| 362 DCHECK(!prerender_tracker_->IsPrerenderingOnIOThread(old_child_id, | |
| 363 old_route_id)); | |
| 364 } | |
| 365 | |
| 366 void ChromeResourceDispatcherHostDelegate::DownloadStarting( | 353 void ChromeResourceDispatcherHostDelegate::DownloadStarting( |
| 367 net::URLRequest* request, | 354 net::URLRequest* request, |
| 368 content::ResourceContext* resource_context, | 355 content::ResourceContext* resource_context, |
| 369 int child_id, | 356 int child_id, |
| 370 int route_id, | 357 int route_id, |
| 371 int request_id, | 358 int request_id, |
| 372 bool is_content_initiated, | 359 bool is_content_initiated, |
| 373 bool must_download, | 360 bool must_download, |
| 374 ScopedVector<content::ResourceThrottle>* throttles) { | 361 ScopedVector<content::ResourceThrottle>* throttles) { |
| 375 BrowserThread::PostTask( | 362 BrowserThread::PostTask( |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 io_data->managed_mode_url_filter())); | 443 io_data->managed_mode_url_filter())); |
| 457 #endif | 444 #endif |
| 458 | 445 |
| 459 content::ResourceThrottle* throttle = | 446 content::ResourceThrottle* throttle = |
| 460 user_script_listener_->CreateResourceThrottle(request->url(), | 447 user_script_listener_->CreateResourceThrottle(request->url(), |
| 461 resource_type); | 448 resource_type); |
| 462 if (throttle) | 449 if (throttle) |
| 463 throttles->push_back(throttle); | 450 throttles->push_back(throttle); |
| 464 | 451 |
| 465 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 452 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 466 if (prerender_tracker_->IsPrerenderingOnIOThread(info->GetChildID(), | 453 if (info->GetVisibilityState() == blink::WebPageVisibilityStatePrerender) { |
| 467 info->GetRouteID())) { | |
| 468 throttles->push_back(new prerender::PrerenderResourceThrottle( | 454 throttles->push_back(new prerender::PrerenderResourceThrottle( |
| 469 request, prerender_tracker_)); | 455 request, prerender_tracker_)); |
| 470 } | 456 } |
| 471 if (prerender_tracker_->IsPendingSwapRequestOnIOThread( | 457 if (prerender_tracker_->IsPendingSwapRequestOnIOThread( |
| 472 info->GetChildID(), info->GetRenderFrameID(), request->url())) { | 458 info->GetChildID(), info->GetRenderFrameID(), request->url())) { |
| 473 throttles->push_back(new prerender::PrerenderPendingSwapThrottle( | 459 throttles->push_back(new prerender::PrerenderPendingSwapThrottle( |
| 474 request, prerender_tracker_)); | 460 request, prerender_tracker_)); |
| 475 } | 461 } |
| 476 } | 462 } |
| 477 | 463 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data, | 613 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data, |
| 628 info->GetChildID(), info->GetRouteID()); | 614 info->GetChildID(), info->GetRouteID()); |
| 629 } | 615 } |
| 630 | 616 |
| 631 // static | 617 // static |
| 632 void ChromeResourceDispatcherHostDelegate:: | 618 void ChromeResourceDispatcherHostDelegate:: |
| 633 SetExternalProtocolHandlerDelegateForTesting( | 619 SetExternalProtocolHandlerDelegateForTesting( |
| 634 ExternalProtocolHandler::Delegate* delegate) { | 620 ExternalProtocolHandler::Delegate* delegate) { |
| 635 g_external_protocol_handler_delegate = delegate; | 621 g_external_protocol_handler_delegate = delegate; |
| 636 } | 622 } |
| OLD | NEW |