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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 void ChromeResourceDispatcherHostDelegate::RequestBeginning( | 436 void ChromeResourceDispatcherHostDelegate::RequestBeginning( |
437 net::URLRequest* request, | 437 net::URLRequest* request, |
438 content::ResourceContext* resource_context, | 438 content::ResourceContext* resource_context, |
439 content::AppCacheService* appcache_service, | 439 content::AppCacheService* appcache_service, |
440 ResourceType resource_type, | 440 ResourceType resource_type, |
441 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) { | 441 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) { |
442 if (safe_browsing_.get()) | 442 if (safe_browsing_.get()) |
443 safe_browsing_->OnResourceRequest(request); | 443 safe_browsing_->OnResourceRequest(request); |
444 | 444 |
445 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 445 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| 446 |
| 447 // The lowering of request priority causes issues with scheduling, since |
| 448 // content::ResourceScheduler uses it to delay and throttle requests. This is |
| 449 // disabled only on Android, as the prerenders are not likely to compete with |
| 450 // page loads there. |
| 451 // See https://crbug.com/652746 for details. |
| 452 // TODO(lizeb,droger): Fix the issue on all platforms. |
| 453 #if !defined(OS_ANDROID) |
| 454 bool is_prerendering = |
| 455 info->GetVisibilityState() == blink::kWebPageVisibilityStatePrerender; |
| 456 if (is_prerendering) { |
| 457 // Requests with the IGNORE_LIMITS flag set (i.e., sync XHRs) |
| 458 // should remain at MAXIMUM_PRIORITY. |
| 459 if (request->load_flags() & net::LOAD_IGNORE_LIMITS) { |
| 460 DCHECK_EQ(request->priority(), net::MAXIMUM_PRIORITY); |
| 461 } else { |
| 462 request->SetPriority(net::IDLE); |
| 463 } |
| 464 } |
| 465 #endif // OS_ANDROID |
| 466 |
446 ProfileIOData* io_data = ProfileIOData::FromResourceContext( | 467 ProfileIOData* io_data = ProfileIOData::FromResourceContext( |
447 resource_context); | 468 resource_context); |
448 | 469 |
449 #if defined(OS_ANDROID) | 470 #if defined(OS_ANDROID) |
450 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME) | 471 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME) |
451 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request); | 472 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request); |
452 #endif | 473 #endif |
453 | 474 |
454 #if defined(OS_CHROMEOS) | 475 #if defined(OS_CHROMEOS) |
455 // Check if we need to add merge session throttle. This throttle will postpone | 476 // Check if we need to add merge session throttle. This throttle will postpone |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 933 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
913 base::Unretained(this), url, request_loading_time)); | 934 base::Unretained(this), url, request_loading_time)); |
914 return; | 935 return; |
915 } | 936 } |
916 | 937 |
917 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 938 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
918 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 939 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
919 rappor::SampleDomainAndRegistryFromGURL( | 940 rappor::SampleDomainAndRegistryFromGURL( |
920 g_browser_process->rappor_service(), metric_name, url); | 941 g_browser_process->rappor_service(), metric_name, url); |
921 } | 942 } |
OLD | NEW |