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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 1041993004: content::ResourceDispatcherHostImpl changes for stale-while-revalidate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@s-w-r-yhirano-patch
Patch Set: Use histograms instead of user actions. Created 5 years 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
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 // 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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 ANNOTATE_BENIGN_RACE( 479 ANNOTATE_BENIGN_RACE(
477 &last_user_gesture_time_, 480 &last_user_gesture_time_,
478 "We don't care about the precise value, see http://crbug.com/92889"); 481 "We don't care about the precise value, see http://crbug.com/92889");
479 482
480 BrowserThread::PostTask(BrowserThread::IO, 483 BrowserThread::PostTask(BrowserThread::IO,
481 FROM_HERE, 484 FROM_HERE,
482 base::Bind(&ResourceDispatcherHostImpl::OnInit, 485 base::Bind(&ResourceDispatcherHostImpl::OnInit,
483 base::Unretained(this))); 486 base::Unretained(this)));
484 487
485 update_load_states_timer_.reset(new base::RepeatingTimer()); 488 update_load_states_timer_.reset(new base::RepeatingTimer());
489
490 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
491 // This needs to be called to mark the trial as active, even if the result
492 // isn't used.
493 std::string stale_while_revalidate_trial_group =
494 base::FieldTrialList::FindFullName("StaleWhileRevalidate");
495 // stale-while-revalidate currently doesn't work with browser-side navigation.
496 // Only enable stale-while-revalidate if browser navigation is not enabled.
497 //
498 // TODO(ricea): Make stale-while-revalidate and browser-side navigation work
499 // together. Or disable stale-while-revalidate completely before browser-side
500 // navigation becomes the default. crbug.com/561610
501 if (!command_line->HasSwitch(switches::kEnableBrowserSideNavigation) &&
502 (base::StartsWith(stale_while_revalidate_trial_group, "Enabled",
503 base::CompareCase::SENSITIVE) ||
504 command_line->HasSwitch(switches::kEnableStaleWhileRevalidate))) {
505 async_revalidation_manager_.reset(new AsyncRevalidationManager);
506 }
486 } 507 }
487 508
488 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() { 509 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() {
489 DCHECK(outstanding_requests_stats_map_.empty()); 510 DCHECK(outstanding_requests_stats_map_.empty());
490 DCHECK(g_resource_dispatcher_host); 511 DCHECK(g_resource_dispatcher_host);
491 g_resource_dispatcher_host = NULL; 512 g_resource_dispatcher_host = NULL;
492 } 513 }
493 514
494 // static 515 // static
495 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() { 516 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 (*i)->GetRequestInfo()->is_stream() || 602 (*i)->GetRequestInfo()->is_stream() ||
582 ((*i)->GetRequestInfo()->detachable_handler() && 603 ((*i)->GetRequestInfo()->detachable_handler() &&
583 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) || 604 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) ||
584 (*i)->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER || 605 (*i)->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER ||
585 (*i)->is_transferring()); 606 (*i)->is_transferring());
586 } 607 }
587 #endif 608 #endif
588 609
589 loaders_to_cancel.clear(); 610 loaders_to_cancel.clear();
590 611
612 if (async_revalidation_manager_) {
613 // Cancelling async revalidations should not result in the creation of new
614 // requests. Do it before the CHECKs to ensure this does not happen.
615 async_revalidation_manager_->CancelAsyncRevalidationsForResourceContext(
616 context);
617 }
618
591 // Validate that no more requests for this context were added. 619 // Validate that no more requests for this context were added.
592 for (LoaderMap::const_iterator i = pending_loaders_.begin(); 620 for (LoaderMap::const_iterator i = pending_loaders_.begin();
593 i != pending_loaders_.end(); ++i) { 621 i != pending_loaders_.end(); ++i) {
594 // http://crbug.com/90971 622 // http://crbug.com/90971
595 CHECK_NE(i->second->GetRequestInfo()->GetContext(), context); 623 CHECK_NE(i->second->GetRequestInfo()->GetContext(), context);
596 } 624 }
597 625
598 for (BlockedLoadersMap::const_iterator i = blocked_loaders_map_.begin(); 626 for (BlockedLoadersMap::const_iterator i = blocked_loaders_map_.begin();
599 i != blocked_loaders_map_.end(); ++i) { 627 i != blocked_loaders_map_.end(); ++i) {
600 BlockedLoadersList* loaders = i->second; 628 BlockedLoadersList* loaders = i->second;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 } 857 }
830 858
831 void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader, 859 void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader,
832 const GURL& new_url) { 860 const GURL& new_url) {
833 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 861 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
834 862
835 int render_process_id, render_frame_host; 863 int render_process_id, render_frame_host;
836 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host)) 864 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host))
837 return; 865 return;
838 866
867 net::URLRequest* request = loader->request();
868 if (request->response_info().async_revalidation_required) {
869 // Async revalidation is only supported for the first redirect leg.
870 DCHECK_EQ(request->url_chain().size(), 1u);
871 DCHECK(async_revalidation_manager_);
872
873 async_revalidation_manager_->BeginAsyncRevalidation(*request,
874 scheduler_.get());
875 }
876
877 // Remove the LOAD_SUPPORT_ASYNC_REVALIDATION flag if it is present.
878 // It is difficult to create a URLRequest with the correct flags and headers
879 // for redirect legs other than the first one. Since stale-while-revalidate in
880 // combination with redirects isn't needed for experimental use, punt on it
881 // for now.
882 // TODO(ricea): Fix this before launching the feature.
883 if (request->load_flags() & net::LOAD_SUPPORT_ASYNC_REVALIDATION) {
884 int new_load_flags =
885 request->load_flags() & ~net::LOAD_SUPPORT_ASYNC_REVALIDATION;
886 request->SetLoadFlags(new_load_flags);
887 }
888
839 // Don't notify WebContents observers for requests known to be 889 // Don't notify WebContents observers for requests known to be
840 // downloads; they aren't really associated with the Webcontents. 890 // downloads; they aren't really associated with the Webcontents.
841 // Note that not all downloads are known before content sniffing. 891 // Note that not all downloads are known before content sniffing.
842 if (info->IsDownload()) 892 if (info->IsDownload())
843 return; 893 return;
844 894
845 // Notify the observers on the UI thread. 895 // Notify the observers on the UI thread.
846 scoped_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails( 896 scoped_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails(
847 loader->request(), 897 loader->request(),
848 GetCertID(loader->request(), info->GetChildID()), 898 GetCertID(loader->request(), info->GetChildID()),
849 new_url)); 899 new_url));
850 BrowserThread::PostTask( 900 BrowserThread::PostTask(
851 BrowserThread::UI, FROM_HERE, 901 BrowserThread::UI, FROM_HERE,
852 base::Bind( 902 base::Bind(
853 &NotifyRedirectOnUI, 903 &NotifyRedirectOnUI,
854 render_process_id, render_frame_host, base::Passed(&detail))); 904 render_process_id, render_frame_host, base::Passed(&detail)));
855 } 905 }
856 906
857 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { 907 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) {
858 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 908 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
859 net::URLRequest* request = loader->request(); 909 net::URLRequest* request = loader->request();
860 if (request->was_fetched_via_proxy() && 910 if (request->was_fetched_via_proxy() &&
861 request->was_fetched_via_spdy() && 911 request->was_fetched_via_spdy() &&
862 request->url().SchemeIs(url::kHttpScheme)) { 912 request->url().SchemeIs(url::kHttpScheme)) {
863 scheduler_->OnReceivedSpdyProxiedHttpResponse( 913 scheduler_->OnReceivedSpdyProxiedHttpResponse(
864 info->GetChildID(), info->GetRouteID()); 914 info->GetChildID(), info->GetRouteID());
865 } 915 }
866 916
917 if (request->response_info().async_revalidation_required) {
918 DCHECK(async_revalidation_manager_);
919 async_revalidation_manager_->BeginAsyncRevalidation(*request,
920 scheduler_.get());
921 }
922
867 int render_process_id, render_frame_host; 923 int render_process_id, render_frame_host;
868 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host)) 924 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host))
869 return; 925 return;
870 926
871 // Don't notify WebContents observers for requests known to be 927 // Don't notify WebContents observers for requests known to be
872 // downloads; they aren't really associated with the Webcontents. 928 // downloads; they aren't really associated with the Webcontents.
873 // Note that not all downloads are known before content sniffing. 929 // Note that not all downloads are known before content sniffing.
874 if (info->IsDownload()) 930 if (info->IsDownload())
875 return; 931 return;
876 932
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 // Only block image loads, as the attack applies largely to the "src" 1372 // Only block image loads, as the attack applies largely to the "src"
1317 // property of the <img> tag. It is common for web properties to allow 1373 // property of the <img> tag. It is common for web properties to allow
1318 // untrusted values for <img src>; this is considered a fair thing for an 1374 // untrusted values for <img src>; this is considered a fair thing for an
1319 // HTML sanitizer to do. Conversely, any HTML sanitizer that didn't 1375 // HTML sanitizer to do. Conversely, any HTML sanitizer that didn't
1320 // filter sources for <script>, <link>, <embed>, <object>, <iframe> tags 1376 // filter sources for <script>, <link>, <embed>, <object>, <iframe> tags
1321 // would be considered vulnerable in and of itself. 1377 // would be considered vulnerable in and of itself.
1322 do_not_prompt_for_login = true; 1378 do_not_prompt_for_login = true;
1323 load_flags |= net::LOAD_DO_NOT_USE_EMBEDDED_IDENTITY; 1379 load_flags |= net::LOAD_DO_NOT_USE_EMBEDDED_IDENTITY;
1324 } 1380 }
1325 1381
1382 bool support_async_revalidation =
1383 !is_sync_load && async_revalidation_manager_ &&
1384 AsyncRevalidationManager::QualifiesForAsyncRevalidation(request_data);
1385
1386 if (support_async_revalidation)
1387 load_flags |= net::LOAD_SUPPORT_ASYNC_REVALIDATION;
1388
1326 // Sync loads should have maximum priority and should be the only 1389 // Sync loads should have maximum priority and should be the only
1327 // requets that have the ignore limits flag set. 1390 // requets that have the ignore limits flag set.
1328 if (is_sync_load) { 1391 if (is_sync_load) {
1329 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY); 1392 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY);
1330 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0); 1393 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0);
1331 } else { 1394 } else {
1332 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0); 1395 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0);
1333 } 1396 }
1334 new_request->SetLoadFlags(load_flags); 1397 new_request->SetLoadFlags(load_flags);
1335 1398
(...skipping 16 matching lines...) Expand all
1352 request_data.has_user_gesture, 1415 request_data.has_user_gesture,
1353 request_data.enable_load_timing, 1416 request_data.enable_load_timing,
1354 request_data.enable_upload_progress, 1417 request_data.enable_upload_progress,
1355 do_not_prompt_for_login, 1418 do_not_prompt_for_login,
1356 request_data.referrer_policy, 1419 request_data.referrer_policy,
1357 request_data.visiblity_state, 1420 request_data.visiblity_state,
1358 resource_context, filter_->GetWeakPtr(), 1421 resource_context, filter_->GetWeakPtr(),
1359 report_raw_headers, 1422 report_raw_headers,
1360 !is_sync_load, 1423 !is_sync_load,
1361 IsUsingLoFi(request_data.lofi_state, delegate_, 1424 IsUsingLoFi(request_data.lofi_state, delegate_,
1362 *new_request, resource_context)); 1425 *new_request, resource_context),
1426 support_async_revalidation ? request_data.headers : std::string());
1363 // Request takes ownership. 1427 // Request takes ownership.
1364 extra_info->AssociateWithRequest(new_request.get()); 1428 extra_info->AssociateWithRequest(new_request.get());
1365 1429
1366 if (new_request->url().SchemeIs(url::kBlobScheme)) { 1430 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1367 // Hang on to a reference to ensure the blob is not released prior 1431 // Hang on to a reference to ensure the blob is not released prior
1368 // to the job being started. 1432 // to the job being started.
1369 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 1433 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1370 new_request.get(), 1434 new_request.get(),
1371 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL( 1435 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL(
1372 new_request->url())); 1436 new_request->url()));
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 false, // has_user_gesture 1717 false, // has_user_gesture
1654 false, // enable_load_timing 1718 false, // enable_load_timing
1655 false, // enable_upload_progress 1719 false, // enable_upload_progress
1656 false, // do_not_prompt_for_login 1720 false, // do_not_prompt_for_login
1657 blink::WebReferrerPolicyDefault, 1721 blink::WebReferrerPolicyDefault,
1658 blink::WebPageVisibilityStateVisible, 1722 blink::WebPageVisibilityStateVisible,
1659 context, 1723 context,
1660 base::WeakPtr<ResourceMessageFilter>(), // filter 1724 base::WeakPtr<ResourceMessageFilter>(), // filter
1661 false, // report_raw_headers 1725 false, // report_raw_headers
1662 true, // is_async 1726 true, // is_async
1663 false); // is_using_lofi 1727 false, // is_using_lofi
1728 std::string()); // original_headers
1664 } 1729 }
1665 1730
1666 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, 1731 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id,
1667 int route_id, 1732 int route_id,
1668 bool is_visible, 1733 bool is_visible,
1669 bool is_audible) { 1734 bool is_audible) {
1670 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible); 1735 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible);
1671 } 1736 }
1672 1737
1673 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted( 1738 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 true, // enable_load_timing 2158 true, // enable_load_timing
2094 false, // enable_upload_progress 2159 false, // enable_upload_progress
2095 false, // do_not_prompt_for_login 2160 false, // do_not_prompt_for_login
2096 info.common_params.referrer.policy, 2161 info.common_params.referrer.policy,
2097 // TODO(davidben): This is only used for prerenders. Replace 2162 // TODO(davidben): This is only used for prerenders. Replace
2098 // is_showing with something for that. Or maybe it just comes from the 2163 // is_showing with something for that. Or maybe it just comes from the
2099 // same mechanism as the cookie one. 2164 // same mechanism as the cookie one.
2100 blink::WebPageVisibilityStateVisible, resource_context, 2165 blink::WebPageVisibilityStateVisible, resource_context,
2101 base::WeakPtr<ResourceMessageFilter>(), // filter 2166 base::WeakPtr<ResourceMessageFilter>(), // filter
2102 false, // request_data.report_raw_headers 2167 false, // request_data.report_raw_headers
2103 true, 2168 true, // is_async
2104 IsUsingLoFi(info.common_params.lofi_state, delegate_, 2169 IsUsingLoFi(info.common_params.lofi_state, delegate_,
2105 *new_request, resource_context)); 2170 *new_request, resource_context),
2171 // The original_headers field is for stale-while-revalidate but the
2172 // feature doesn't work with PlzNavigate, so it's just a placeholder
2173 // here.
2174 // TODO(ricea): Make the feature work with stale-while-revalidate
2175 // and clean this up.
2176 std::string()); // original_headers
2106 // Request takes ownership. 2177 // Request takes ownership.
2107 extra_info->AssociateWithRequest(new_request.get()); 2178 extra_info->AssociateWithRequest(new_request.get());
2108 2179
2109 if (new_request->url().SchemeIs(url::kBlobScheme)) { 2180 if (new_request->url().SchemeIs(url::kBlobScheme)) {
2110 // Hang on to a reference to ensure the blob is not released prior 2181 // Hang on to a reference to ensure the blob is not released prior
2111 // to the job being started. 2182 // to the job being started.
2112 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 2183 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
2113 new_request.get(), 2184 new_request.get(),
2114 blob_context->GetBlobDataFromPublicURL(new_request->url())); 2185 blob_context->GetBlobDataFromPublicURL(new_request->url()));
2115 } 2186 }
(...skipping 17 matching lines...) Expand all
2133 handler = AddStandardHandlers(new_request.get(), resource_type, 2204 handler = AddStandardHandlers(new_request.get(), resource_type,
2134 resource_context, 2205 resource_context,
2135 nullptr, // appcache_service 2206 nullptr, // appcache_service
2136 -1, // child_id 2207 -1, // child_id
2137 -1, // route_id 2208 -1, // route_id
2138 handler.Pass()); 2209 handler.Pass());
2139 2210
2140 BeginRequestInternal(new_request.Pass(), handler.Pass()); 2211 BeginRequestInternal(new_request.Pass(), handler.Pass());
2141 } 2212 }
2142 2213
2214 void ResourceDispatcherHostImpl::EnableStaleWhileRevalidateForTesting() {
2215 if (!async_revalidation_manager_)
2216 async_revalidation_manager_.reset(new AsyncRevalidationManager);
2217 }
2218
2143 // static 2219 // static
2144 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2220 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
2145 net::URLRequest* request) { 2221 net::URLRequest* request) {
2146 // The following fields should be a minor size contribution (experimentally 2222 // The following fields should be a minor size contribution (experimentally
2147 // on the order of 100). However since they are variable length, it could 2223 // on the order of 100). However since they are variable length, it could
2148 // in theory be a sizeable contribution. 2224 // in theory be a sizeable contribution.
2149 int strings_cost = request->extra_request_headers().ToString().size() + 2225 int strings_cost = request->extra_request_headers().ToString().size() +
2150 request->original_url().spec().size() + 2226 request->original_url().spec().size() +
2151 request->referrer().size() + 2227 request->referrer().size() +
2152 request->method().size(); 2228 request->method().size();
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2455 load_flags |= net::LOAD_PREFETCH; 2531 load_flags |= net::LOAD_PREFETCH;
2456 } 2532 }
2457 2533
2458 if (is_sync_load) 2534 if (is_sync_load)
2459 load_flags |= net::LOAD_IGNORE_LIMITS; 2535 load_flags |= net::LOAD_IGNORE_LIMITS;
2460 2536
2461 return load_flags; 2537 return load_flags;
2462 } 2538 }
2463 2539
2464 } // namespace content 2540 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_request_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698