| 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/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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } else { | 246 } else { |
| 247 ExternalProtocolHandler::LaunchUrlWithDelegate( | 247 ExternalProtocolHandler::LaunchUrlWithDelegate( |
| 248 url, render_process_id, web_contents->GetRoutingID(), page_transition, | 248 url, render_process_id, web_contents->GetRoutingID(), page_transition, |
| 249 has_user_gesture, g_external_protocol_handler_delegate); | 249 has_user_gesture, g_external_protocol_handler_delegate); |
| 250 } | 250 } |
| 251 } | 251 } |
| 252 | 252 |
| 253 #if !defined(DISABLE_NACL) | 253 #if !defined(DISABLE_NACL) |
| 254 void AppendComponentUpdaterThrottles( | 254 void AppendComponentUpdaterThrottles( |
| 255 net::URLRequest* request, | 255 net::URLRequest* request, |
| 256 const ResourceRequestInfo& info, |
| 256 content::ResourceContext* resource_context, | 257 content::ResourceContext* resource_context, |
| 257 ResourceType resource_type, | 258 ResourceType resource_type, |
| 258 ScopedVector<content::ResourceThrottle>* throttles) { | 259 ScopedVector<content::ResourceThrottle>* throttles) { |
| 260 bool is_prerendering = |
| 261 info.GetVisibilityState() == blink::WebPageVisibilityStatePrerender; |
| 262 if (is_prerendering) |
| 263 return; |
| 264 |
| 259 const char* crx_id = NULL; | 265 const char* crx_id = NULL; |
| 260 component_updater::ComponentUpdateService* cus = | 266 component_updater::ComponentUpdateService* cus = |
| 261 g_browser_process->component_updater(); | 267 g_browser_process->component_updater(); |
| 262 if (!cus) | 268 if (!cus) |
| 263 return; | 269 return; |
| 264 // Check for PNaCl pexe request. | 270 // Check for PNaCl pexe request. |
| 265 if (resource_type == content::RESOURCE_TYPE_OBJECT) { | 271 if (resource_type == content::RESOURCE_TYPE_OBJECT) { |
| 266 const net::HttpRequestHeaders& headers = request->extra_request_headers(); | 272 const net::HttpRequestHeaders& headers = request->extra_request_headers(); |
| 267 std::string accept_headers; | 273 std::string accept_headers; |
| 268 if (headers.GetHeader("Accept", &accept_headers)) { | 274 if (headers.GetHeader("Accept", &accept_headers)) { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 void ChromeResourceDispatcherHostDelegate::RequestBeginning( | 421 void ChromeResourceDispatcherHostDelegate::RequestBeginning( |
| 416 net::URLRequest* request, | 422 net::URLRequest* request, |
| 417 content::ResourceContext* resource_context, | 423 content::ResourceContext* resource_context, |
| 418 content::AppCacheService* appcache_service, | 424 content::AppCacheService* appcache_service, |
| 419 ResourceType resource_type, | 425 ResourceType resource_type, |
| 420 ScopedVector<content::ResourceThrottle>* throttles) { | 426 ScopedVector<content::ResourceThrottle>* throttles) { |
| 421 if (safe_browsing_.get()) | 427 if (safe_browsing_.get()) |
| 422 safe_browsing_->OnResourceRequest(request); | 428 safe_browsing_->OnResourceRequest(request); |
| 423 | 429 |
| 424 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 430 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 431 |
| 432 // The lowering of request priority causes issues with scheduling, since |
| 433 // content::ResourceScheduler uses it to delay and throttle requests. This is |
| 434 // disabled only on Android, as the prerenders are not likely to compete with |
| 435 // page loads there. |
| 436 // See https://crbug.com/652746 for details. |
| 437 // TODO(lizeb,droger): Fix the issue on all platforms. |
| 438 #if !defined(OS_ANDROID) |
| 425 bool is_prerendering = | 439 bool is_prerendering = |
| 426 info->GetVisibilityState() == blink::WebPageVisibilityStatePrerender; | 440 info->GetVisibilityState() == blink::WebPageVisibilityStatePrerender; |
| 427 if (is_prerendering) { | 441 if (is_prerendering) { |
| 428 // Requests with the IGNORE_LIMITS flag set (i.e., sync XHRs) | 442 // Requests with the IGNORE_LIMITS flag set (i.e., sync XHRs) |
| 429 // should remain at MAXIMUM_PRIORITY. | 443 // should remain at MAXIMUM_PRIORITY. |
| 430 if (request->load_flags() & net::LOAD_IGNORE_LIMITS) { | 444 if (request->load_flags() & net::LOAD_IGNORE_LIMITS) { |
| 431 DCHECK_EQ(request->priority(), net::MAXIMUM_PRIORITY); | 445 DCHECK_EQ(request->priority(), net::MAXIMUM_PRIORITY); |
| 432 } else { | 446 } else { |
| 433 request->SetPriority(net::IDLE); | 447 request->SetPriority(net::IDLE); |
| 434 } | 448 } |
| 435 } | 449 } |
| 450 #endif // OS_ANDROID |
| 436 | 451 |
| 437 ProfileIOData* io_data = ProfileIOData::FromResourceContext( | 452 ProfileIOData* io_data = ProfileIOData::FromResourceContext( |
| 438 resource_context); | 453 resource_context); |
| 439 | 454 |
| 440 #if defined(OS_ANDROID) | 455 #if defined(OS_ANDROID) |
| 441 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME) | 456 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME) |
| 442 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request); | 457 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request); |
| 443 #endif | 458 #endif |
| 444 | 459 |
| 445 #if defined(OS_CHROMEOS) | 460 #if defined(OS_CHROMEOS) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 475 | 490 |
| 476 signin::FixMirrorRequestHeaderHelper(request, GURL() /* redirect_url */, | 491 signin::FixMirrorRequestHeaderHelper(request, GURL() /* redirect_url */, |
| 477 io_data, info->GetChildID(), | 492 io_data, info->GetChildID(), |
| 478 info->GetRouteID()); | 493 info->GetRouteID()); |
| 479 | 494 |
| 480 AppendStandardResourceThrottles(request, | 495 AppendStandardResourceThrottles(request, |
| 481 resource_context, | 496 resource_context, |
| 482 resource_type, | 497 resource_type, |
| 483 throttles); | 498 throttles); |
| 484 #if !defined(DISABLE_NACL) | 499 #if !defined(DISABLE_NACL) |
| 485 if (!is_prerendering) { | 500 AppendComponentUpdaterThrottles(request, *info, resource_context, |
| 486 AppendComponentUpdaterThrottles(request, | 501 resource_type, throttles); |
| 487 resource_context, | 502 #endif // !defined(DISABLE_NACL) |
| 488 resource_type, | |
| 489 throttles); | |
| 490 } | |
| 491 #endif | |
| 492 | 503 |
| 493 if (io_data->resource_prefetch_predictor_observer()) { | 504 if (io_data->resource_prefetch_predictor_observer()) { |
| 494 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( | 505 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( |
| 495 request, resource_type, info->GetChildID(), info->GetRenderFrameID()); | 506 request, resource_type, info->GetChildID(), info->GetRenderFrameID()); |
| 496 } | 507 } |
| 497 } | 508 } |
| 498 | 509 |
| 499 void ChromeResourceDispatcherHostDelegate::DownloadStarting( | 510 void ChromeResourceDispatcherHostDelegate::DownloadStarting( |
| 500 net::URLRequest* request, | 511 net::URLRequest* request, |
| 501 content::ResourceContext* resource_context, | 512 content::ResourceContext* resource_context, |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 872 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 862 base::Unretained(this), url, request_loading_time)); | 873 base::Unretained(this), url, request_loading_time)); |
| 863 return; | 874 return; |
| 864 } | 875 } |
| 865 | 876 |
| 866 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 877 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 867 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 878 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 868 rappor::SampleDomainAndRegistryFromGURL( | 879 rappor::SampleDomainAndRegistryFromGURL( |
| 869 g_browser_process->rappor_service(), metric_name, url); | 880 g_browser_process->rappor_service(), metric_name, url); |
| 870 } | 881 } |
| OLD | NEW |