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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/debug/alias.h" | 17 #include "base/debug/alias.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
20 #include "base/memory/shared_memory.h" | 20 #include "base/memory/shared_memory.h" |
21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
| 22 #include "base/metrics/field_trial.h" |
22 #include "base/metrics/histogram_macros.h" | 23 #include "base/metrics/histogram_macros.h" |
23 #include "base/metrics/sparse_histogram.h" | 24 #include "base/metrics/sparse_histogram.h" |
24 #include "base/profiler/scoped_tracker.h" | 25 #include "base/profiler/scoped_tracker.h" |
25 #include "base/stl_util.h" | 26 #include "base/stl_util.h" |
| 27 #include "base/strings/string_util.h" |
26 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 28 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
27 #include "base/time/time.h" | 29 #include "base/time/time.h" |
28 #include "content/browser/appcache/appcache_interceptor.h" | 30 #include "content/browser/appcache/appcache_interceptor.h" |
29 #include "content/browser/appcache/chrome_appcache_service.h" | 31 #include "content/browser/appcache/chrome_appcache_service.h" |
30 #include "content/browser/bad_message.h" | 32 #include "content/browser/bad_message.h" |
31 #include "content/browser/cert_store_impl.h" | 33 #include "content/browser/cert_store_impl.h" |
32 #include "content/browser/child_process_security_policy_impl.h" | 34 #include "content/browser/child_process_security_policy_impl.h" |
33 #include "content/browser/download/download_resource_handler.h" | 35 #include "content/browser/download/download_resource_handler.h" |
34 #include "content/browser/download/save_file_manager.h" | 36 #include "content/browser/download/save_file_manager.h" |
35 #include "content/browser/download/save_file_resource_handler.h" | 37 #include "content/browser/download/save_file_resource_handler.h" |
36 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 38 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
37 #include "content/browser/frame_host/navigation_request_info.h" | 39 #include "content/browser/frame_host/navigation_request_info.h" |
38 #include "content/browser/frame_host/navigator.h" | 40 #include "content/browser/frame_host/navigator.h" |
39 #include "content/browser/loader/async_resource_handler.h" | 41 #include "content/browser/loader/async_resource_handler.h" |
| 42 #include "content/browser/loader/async_revalidation_manager.h" |
40 #include "content/browser/loader/cross_site_resource_handler.h" | 43 #include "content/browser/loader/cross_site_resource_handler.h" |
41 #include "content/browser/loader/detachable_resource_handler.h" | 44 #include "content/browser/loader/detachable_resource_handler.h" |
42 #include "content/browser/loader/mime_type_resource_handler.h" | 45 #include "content/browser/loader/mime_type_resource_handler.h" |
43 #include "content/browser/loader/navigation_resource_handler.h" | 46 #include "content/browser/loader/navigation_resource_handler.h" |
44 #include "content/browser/loader/navigation_resource_throttle.h" | 47 #include "content/browser/loader/navigation_resource_throttle.h" |
45 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 48 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
46 #include "content/browser/loader/power_save_block_resource_throttle.h" | 49 #include "content/browser/loader/power_save_block_resource_throttle.h" |
47 #include "content/browser/loader/redirect_to_file_resource_handler.h" | 50 #include "content/browser/loader/redirect_to_file_resource_handler.h" |
48 #include "content/browser/loader/resource_message_filter.h" | 51 #include "content/browser/loader/resource_message_filter.h" |
49 #include "content/browser/loader/resource_request_info_impl.h" | 52 #include "content/browser/loader/resource_request_info_impl.h" |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 ANNOTATE_BENIGN_RACE( | 478 ANNOTATE_BENIGN_RACE( |
476 &last_user_gesture_time_, | 479 &last_user_gesture_time_, |
477 "We don't care about the precise value, see http://crbug.com/92889"); | 480 "We don't care about the precise value, see http://crbug.com/92889"); |
478 | 481 |
479 BrowserThread::PostTask(BrowserThread::IO, | 482 BrowserThread::PostTask(BrowserThread::IO, |
480 FROM_HERE, | 483 FROM_HERE, |
481 base::Bind(&ResourceDispatcherHostImpl::OnInit, | 484 base::Bind(&ResourceDispatcherHostImpl::OnInit, |
482 base::Unretained(this))); | 485 base::Unretained(this))); |
483 | 486 |
484 update_load_states_timer_.reset(new base::RepeatingTimer()); | 487 update_load_states_timer_.reset(new base::RepeatingTimer()); |
| 488 |
| 489 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 490 // This needs to be called to mark the trial as active, even if the result |
| 491 // isn't used. |
| 492 std::string stale_while_revalidate_trial_group = |
| 493 base::FieldTrialList::FindFullName("StaleWhileRevalidate"); |
| 494 // stale-while-revalidate currently doesn't work with browser-side navigation. |
| 495 // Only enable stale-while-revalidate if browser navigation is not enabled. |
| 496 // |
| 497 // TODO(ricea): Make stale-while-revalidate and browser-side navigation work |
| 498 // together. Or disable stale-while-revalidate completely before browser-side |
| 499 // navigation becomes the default. crbug.com/561610 |
| 500 if (!command_line->HasSwitch(switches::kEnableBrowserSideNavigation) && |
| 501 (base::StartsWith(stale_while_revalidate_trial_group, "Enabled", |
| 502 base::CompareCase::SENSITIVE) || |
| 503 command_line->HasSwitch(switches::kEnableStaleWhileRevalidate))) { |
| 504 async_revalidation_manager_.reset(new AsyncRevalidationManager); |
| 505 } |
485 } | 506 } |
486 | 507 |
487 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() { | 508 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() { |
488 DCHECK(outstanding_requests_stats_map_.empty()); | 509 DCHECK(outstanding_requests_stats_map_.empty()); |
489 DCHECK(g_resource_dispatcher_host); | 510 DCHECK(g_resource_dispatcher_host); |
490 g_resource_dispatcher_host = NULL; | 511 g_resource_dispatcher_host = NULL; |
491 } | 512 } |
492 | 513 |
493 // static | 514 // static |
494 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() { | 515 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 (*i)->GetRequestInfo()->is_stream() || | 601 (*i)->GetRequestInfo()->is_stream() || |
581 ((*i)->GetRequestInfo()->detachable_handler() && | 602 ((*i)->GetRequestInfo()->detachable_handler() && |
582 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) || | 603 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) || |
583 (*i)->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER || | 604 (*i)->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER || |
584 (*i)->is_transferring()); | 605 (*i)->is_transferring()); |
585 } | 606 } |
586 #endif | 607 #endif |
587 | 608 |
588 loaders_to_cancel.clear(); | 609 loaders_to_cancel.clear(); |
589 | 610 |
| 611 if (async_revalidation_manager_) { |
| 612 // Cancelling async revalidations should not result in the creation of new |
| 613 // requests. Do it before the CHECKs to ensure this does not happen. |
| 614 async_revalidation_manager_->CancelAsyncRevalidationsForResourceContext( |
| 615 context); |
| 616 } |
| 617 |
590 // Validate that no more requests for this context were added. | 618 // Validate that no more requests for this context were added. |
591 for (LoaderMap::const_iterator i = pending_loaders_.begin(); | 619 for (LoaderMap::const_iterator i = pending_loaders_.begin(); |
592 i != pending_loaders_.end(); ++i) { | 620 i != pending_loaders_.end(); ++i) { |
593 // http://crbug.com/90971 | 621 // http://crbug.com/90971 |
594 CHECK_NE(i->second->GetRequestInfo()->GetContext(), context); | 622 CHECK_NE(i->second->GetRequestInfo()->GetContext(), context); |
595 } | 623 } |
596 | 624 |
597 for (BlockedLoadersMap::const_iterator i = blocked_loaders_map_.begin(); | 625 for (BlockedLoadersMap::const_iterator i = blocked_loaders_map_.begin(); |
598 i != blocked_loaders_map_.end(); ++i) { | 626 i != blocked_loaders_map_.end(); ++i) { |
599 BlockedLoadersList* loaders = i->second; | 627 BlockedLoadersList* loaders = i->second; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 } | 856 } |
829 | 857 |
830 void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader, | 858 void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader, |
831 const GURL& new_url) { | 859 const GURL& new_url) { |
832 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 860 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
833 | 861 |
834 int render_process_id, render_frame_host; | 862 int render_process_id, render_frame_host; |
835 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host)) | 863 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host)) |
836 return; | 864 return; |
837 | 865 |
| 866 net::URLRequest* request = loader->request(); |
| 867 if (request->response_info().async_revalidation_required) { |
| 868 // Async revalidation is only supported for the first redirect leg. |
| 869 DCHECK_EQ(request->url_chain().size(), 1u); |
| 870 DCHECK(async_revalidation_manager_); |
| 871 |
| 872 async_revalidation_manager_->BeginAsyncRevalidation(*request, |
| 873 scheduler_.get()); |
| 874 } |
| 875 |
| 876 // Remove the LOAD_SUPPORT_ASYNC_REVALIDATION flag if it is present. |
| 877 // It is difficult to create a URLRequest with the correct flags and headers |
| 878 // for redirect legs other than the first one. Since stale-while-revalidate in |
| 879 // combination with redirects isn't needed for experimental use, punt on it |
| 880 // for now. |
| 881 // TODO(ricea): Fix this before launching the feature. |
| 882 if (request->load_flags() & net::LOAD_SUPPORT_ASYNC_REVALIDATION) { |
| 883 int new_load_flags = |
| 884 request->load_flags() & ~net::LOAD_SUPPORT_ASYNC_REVALIDATION; |
| 885 request->SetLoadFlags(new_load_flags); |
| 886 } |
| 887 |
838 // Don't notify WebContents observers for requests known to be | 888 // Don't notify WebContents observers for requests known to be |
839 // downloads; they aren't really associated with the Webcontents. | 889 // downloads; they aren't really associated with the Webcontents. |
840 // Note that not all downloads are known before content sniffing. | 890 // Note that not all downloads are known before content sniffing. |
841 if (info->IsDownload()) | 891 if (info->IsDownload()) |
842 return; | 892 return; |
843 | 893 |
844 // Notify the observers on the UI thread. | 894 // Notify the observers on the UI thread. |
845 scoped_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails( | 895 scoped_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails( |
846 loader->request(), | 896 loader->request(), |
847 GetCertID(loader->request(), info->GetChildID()), | 897 GetCertID(loader->request(), info->GetChildID()), |
848 new_url)); | 898 new_url)); |
849 BrowserThread::PostTask( | 899 BrowserThread::PostTask( |
850 BrowserThread::UI, FROM_HERE, | 900 BrowserThread::UI, FROM_HERE, |
851 base::Bind( | 901 base::Bind( |
852 &NotifyRedirectOnUI, | 902 &NotifyRedirectOnUI, |
853 render_process_id, render_frame_host, base::Passed(&detail))); | 903 render_process_id, render_frame_host, base::Passed(&detail))); |
854 } | 904 } |
855 | 905 |
856 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { | 906 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { |
857 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 907 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
858 net::URLRequest* request = loader->request(); | 908 net::URLRequest* request = loader->request(); |
859 if (request->was_fetched_via_proxy() && | 909 if (request->was_fetched_via_proxy() && |
860 request->was_fetched_via_spdy() && | 910 request->was_fetched_via_spdy() && |
861 request->url().SchemeIs(url::kHttpScheme)) { | 911 request->url().SchemeIs(url::kHttpScheme)) { |
862 scheduler_->OnReceivedSpdyProxiedHttpResponse( | 912 scheduler_->OnReceivedSpdyProxiedHttpResponse( |
863 info->GetChildID(), info->GetRouteID()); | 913 info->GetChildID(), info->GetRouteID()); |
864 } | 914 } |
865 | 915 |
| 916 if (request->response_info().async_revalidation_required) { |
| 917 DCHECK(async_revalidation_manager_); |
| 918 async_revalidation_manager_->BeginAsyncRevalidation(*request, |
| 919 scheduler_.get()); |
| 920 } |
| 921 |
866 int render_process_id, render_frame_host; | 922 int render_process_id, render_frame_host; |
867 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host)) | 923 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host)) |
868 return; | 924 return; |
869 | 925 |
870 // Don't notify WebContents observers for requests known to be | 926 // Don't notify WebContents observers for requests known to be |
871 // downloads; they aren't really associated with the Webcontents. | 927 // downloads; they aren't really associated with the Webcontents. |
872 // Note that not all downloads are known before content sniffing. | 928 // Note that not all downloads are known before content sniffing. |
873 if (info->IsDownload()) | 929 if (info->IsDownload()) |
874 return; | 930 return; |
875 | 931 |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 // Only block image loads, as the attack applies largely to the "src" | 1371 // Only block image loads, as the attack applies largely to the "src" |
1316 // property of the <img> tag. It is common for web properties to allow | 1372 // property of the <img> tag. It is common for web properties to allow |
1317 // untrusted values for <img src>; this is considered a fair thing for an | 1373 // untrusted values for <img src>; this is considered a fair thing for an |
1318 // HTML sanitizer to do. Conversely, any HTML sanitizer that didn't | 1374 // HTML sanitizer to do. Conversely, any HTML sanitizer that didn't |
1319 // filter sources for <script>, <link>, <embed>, <object>, <iframe> tags | 1375 // filter sources for <script>, <link>, <embed>, <object>, <iframe> tags |
1320 // would be considered vulnerable in and of itself. | 1376 // would be considered vulnerable in and of itself. |
1321 do_not_prompt_for_login = true; | 1377 do_not_prompt_for_login = true; |
1322 load_flags |= net::LOAD_DO_NOT_USE_EMBEDDED_IDENTITY; | 1378 load_flags |= net::LOAD_DO_NOT_USE_EMBEDDED_IDENTITY; |
1323 } | 1379 } |
1324 | 1380 |
| 1381 bool support_async_revalidation = |
| 1382 !is_sync_load && async_revalidation_manager_ && |
| 1383 AsyncRevalidationManager::QualifiesForAsyncRevalidation(request_data); |
| 1384 |
| 1385 if (support_async_revalidation) |
| 1386 load_flags |= net::LOAD_SUPPORT_ASYNC_REVALIDATION; |
| 1387 |
1325 // Sync loads should have maximum priority and should be the only | 1388 // Sync loads should have maximum priority and should be the only |
1326 // requets that have the ignore limits flag set. | 1389 // requets that have the ignore limits flag set. |
1327 if (is_sync_load) { | 1390 if (is_sync_load) { |
1328 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY); | 1391 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY); |
1329 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0); | 1392 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0); |
1330 } else { | 1393 } else { |
1331 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0); | 1394 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0); |
1332 } | 1395 } |
1333 new_request->SetLoadFlags(load_flags); | 1396 new_request->SetLoadFlags(load_flags); |
1334 | 1397 |
(...skipping 16 matching lines...) Expand all Loading... |
1351 request_data.has_user_gesture, | 1414 request_data.has_user_gesture, |
1352 request_data.enable_load_timing, | 1415 request_data.enable_load_timing, |
1353 request_data.enable_upload_progress, | 1416 request_data.enable_upload_progress, |
1354 do_not_prompt_for_login, | 1417 do_not_prompt_for_login, |
1355 request_data.referrer_policy, | 1418 request_data.referrer_policy, |
1356 request_data.visiblity_state, | 1419 request_data.visiblity_state, |
1357 resource_context, filter_->GetWeakPtr(), | 1420 resource_context, filter_->GetWeakPtr(), |
1358 report_raw_headers, | 1421 report_raw_headers, |
1359 !is_sync_load, | 1422 !is_sync_load, |
1360 IsUsingLoFi(request_data.lofi_state, delegate_, | 1423 IsUsingLoFi(request_data.lofi_state, delegate_, |
1361 *new_request, resource_context)); | 1424 *new_request, resource_context), |
| 1425 support_async_revalidation ? request_data.headers : std::string()); |
1362 // Request takes ownership. | 1426 // Request takes ownership. |
1363 extra_info->AssociateWithRequest(new_request.get()); | 1427 extra_info->AssociateWithRequest(new_request.get()); |
1364 | 1428 |
1365 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 1429 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
1366 // Hang on to a reference to ensure the blob is not released prior | 1430 // Hang on to a reference to ensure the blob is not released prior |
1367 // to the job being started. | 1431 // to the job being started. |
1368 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 1432 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
1369 new_request.get(), | 1433 new_request.get(), |
1370 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL( | 1434 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL( |
1371 new_request->url())); | 1435 new_request->url())); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 false, // has_user_gesture | 1702 false, // has_user_gesture |
1639 false, // enable_load_timing | 1703 false, // enable_load_timing |
1640 false, // enable_upload_progress | 1704 false, // enable_upload_progress |
1641 false, // do_not_prompt_for_login | 1705 false, // do_not_prompt_for_login |
1642 blink::WebReferrerPolicyDefault, | 1706 blink::WebReferrerPolicyDefault, |
1643 blink::WebPageVisibilityStateVisible, | 1707 blink::WebPageVisibilityStateVisible, |
1644 context, | 1708 context, |
1645 base::WeakPtr<ResourceMessageFilter>(), // filter | 1709 base::WeakPtr<ResourceMessageFilter>(), // filter |
1646 false, // report_raw_headers | 1710 false, // report_raw_headers |
1647 true, // is_async | 1711 true, // is_async |
1648 false); // is_using_lofi | 1712 false, // is_using_lofi |
| 1713 std::string()); // original_headers |
1649 } | 1714 } |
1650 | 1715 |
1651 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, | 1716 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, |
1652 int route_id, | 1717 int route_id, |
1653 bool is_visible, | 1718 bool is_visible, |
1654 bool is_audible) { | 1719 bool is_audible) { |
1655 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible); | 1720 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible); |
1656 } | 1721 } |
1657 | 1722 |
1658 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted( | 1723 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted( |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2078 true, // enable_load_timing | 2143 true, // enable_load_timing |
2079 false, // enable_upload_progress | 2144 false, // enable_upload_progress |
2080 false, // do_not_prompt_for_login | 2145 false, // do_not_prompt_for_login |
2081 info.common_params.referrer.policy, | 2146 info.common_params.referrer.policy, |
2082 // TODO(davidben): This is only used for prerenders. Replace | 2147 // TODO(davidben): This is only used for prerenders. Replace |
2083 // is_showing with something for that. Or maybe it just comes from the | 2148 // is_showing with something for that. Or maybe it just comes from the |
2084 // same mechanism as the cookie one. | 2149 // same mechanism as the cookie one. |
2085 blink::WebPageVisibilityStateVisible, resource_context, | 2150 blink::WebPageVisibilityStateVisible, resource_context, |
2086 base::WeakPtr<ResourceMessageFilter>(), // filter | 2151 base::WeakPtr<ResourceMessageFilter>(), // filter |
2087 false, // request_data.report_raw_headers | 2152 false, // request_data.report_raw_headers |
2088 true, | 2153 true, // is_async |
2089 IsUsingLoFi(info.common_params.lofi_state, delegate_, | 2154 IsUsingLoFi(info.common_params.lofi_state, delegate_, |
2090 *new_request, resource_context)); | 2155 *new_request, resource_context), |
| 2156 // The original_headers field is for stale-while-revalidate but the |
| 2157 // feature doesn't work with PlzNavigate, so it's just a placeholder |
| 2158 // here. |
| 2159 // TODO(ricea): Make the feature work with stale-while-revalidate |
| 2160 // and clean this up. |
| 2161 std::string()); // original_headers |
2091 // Request takes ownership. | 2162 // Request takes ownership. |
2092 extra_info->AssociateWithRequest(new_request.get()); | 2163 extra_info->AssociateWithRequest(new_request.get()); |
2093 | 2164 |
2094 if (new_request->url().SchemeIs(url::kBlobScheme)) { | 2165 if (new_request->url().SchemeIs(url::kBlobScheme)) { |
2095 // Hang on to a reference to ensure the blob is not released prior | 2166 // Hang on to a reference to ensure the blob is not released prior |
2096 // to the job being started. | 2167 // to the job being started. |
2097 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 2168 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
2098 new_request.get(), | 2169 new_request.get(), |
2099 blob_context->GetBlobDataFromPublicURL(new_request->url())); | 2170 blob_context->GetBlobDataFromPublicURL(new_request->url())); |
2100 } | 2171 } |
(...skipping 17 matching lines...) Expand all Loading... |
2118 handler = AddStandardHandlers(new_request.get(), resource_type, | 2189 handler = AddStandardHandlers(new_request.get(), resource_type, |
2119 resource_context, | 2190 resource_context, |
2120 nullptr, // appcache_service | 2191 nullptr, // appcache_service |
2121 -1, // child_id | 2192 -1, // child_id |
2122 -1, // route_id | 2193 -1, // route_id |
2123 handler.Pass()); | 2194 handler.Pass()); |
2124 | 2195 |
2125 BeginRequestInternal(new_request.Pass(), handler.Pass()); | 2196 BeginRequestInternal(new_request.Pass(), handler.Pass()); |
2126 } | 2197 } |
2127 | 2198 |
| 2199 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() { |
| 2200 if (!async_revalidation_manager_) |
| 2201 async_revalidation_manager_.reset(new AsyncRevalidationManager); |
| 2202 } |
| 2203 |
2128 // static | 2204 // static |
2129 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( | 2205 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( |
2130 net::URLRequest* request) { | 2206 net::URLRequest* request) { |
2131 // The following fields should be a minor size contribution (experimentally | 2207 // The following fields should be a minor size contribution (experimentally |
2132 // on the order of 100). However since they are variable length, it could | 2208 // on the order of 100). However since they are variable length, it could |
2133 // in theory be a sizeable contribution. | 2209 // in theory be a sizeable contribution. |
2134 int strings_cost = request->extra_request_headers().ToString().size() + | 2210 int strings_cost = request->extra_request_headers().ToString().size() + |
2135 request->original_url().spec().size() + | 2211 request->original_url().spec().size() + |
2136 request->referrer().size() + | 2212 request->referrer().size() + |
2137 request->method().size(); | 2213 request->method().size(); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2440 load_flags |= net::LOAD_PREFETCH; | 2516 load_flags |= net::LOAD_PREFETCH; |
2441 } | 2517 } |
2442 | 2518 |
2443 if (is_sync_load) | 2519 if (is_sync_load) |
2444 load_flags |= net::LOAD_IGNORE_LIMITS; | 2520 load_flags |= net::LOAD_IGNORE_LIMITS; |
2445 | 2521 |
2446 return load_flags; | 2522 return load_flags; |
2447 } | 2523 } |
2448 | 2524 |
2449 } // namespace content | 2525 } // namespace content |
OLD | NEW |