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

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: Workaround iwyu bug in prerender_resource Created 5 years, 4 months 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 <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/bind.h" 14 #include "base/bind.h"
14 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
17 #include "base/debug/alias.h" 18 #include "base/debug/alias.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
20 #include "base/memory/shared_memory.h" 21 #include "base/memory/shared_memory.h"
21 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/metrics/field_trial.h"
22 #include "base/metrics/histogram_macros.h" 24 #include "base/metrics/histogram_macros.h"
23 #include "base/metrics/sparse_histogram.h" 25 #include "base/metrics/sparse_histogram.h"
24 #include "base/profiler/scoped_tracker.h" 26 #include "base/profiler/scoped_tracker.h"
25 #include "base/stl_util.h" 27 #include "base/stl_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"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 #include "net/base/load_flags.h" 86 #include "net/base/load_flags.h"
85 #include "net/base/mime_util.h" 87 #include "net/base/mime_util.h"
86 #include "net/base/net_errors.h" 88 #include "net/base/net_errors.h"
87 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 89 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
88 #include "net/base/request_priority.h" 90 #include "net/base/request_priority.h"
89 #include "net/base/upload_data_stream.h" 91 #include "net/base/upload_data_stream.h"
90 #include "net/cert/cert_status_flags.h" 92 #include "net/cert/cert_status_flags.h"
91 #include "net/cookies/cookie_monster.h" 93 #include "net/cookies/cookie_monster.h"
92 #include "net/http/http_response_headers.h" 94 #include "net/http/http_response_headers.h"
93 #include "net/http/http_response_info.h" 95 #include "net/http/http_response_info.h"
96 #include "net/http/http_transaction_factory.h"
97 #include "net/http/http_util.h"
94 #include "net/ssl/ssl_cert_request_info.h" 98 #include "net/ssl/ssl_cert_request_info.h"
95 #include "net/url_request/url_request.h" 99 #include "net/url_request/url_request.h"
96 #include "net/url_request/url_request_context.h" 100 #include "net/url_request/url_request_context.h"
97 #include "net/url_request/url_request_job_factory.h" 101 #include "net/url_request/url_request_job_factory.h"
98 #include "storage/browser/blob/blob_data_handle.h" 102 #include "storage/browser/blob/blob_data_handle.h"
99 #include "storage/browser/blob/blob_storage_context.h" 103 #include "storage/browser/blob/blob_storage_context.h"
100 #include "storage/browser/blob/blob_url_request_job_factory.h" 104 #include "storage/browser/blob/blob_url_request_job_factory.h"
101 #include "storage/browser/blob/shareable_file_reference.h" 105 #include "storage/browser/blob/shareable_file_reference.h"
102 #include "storage/browser/fileapi/file_permission_policy.h" 106 #include "storage/browser/fileapi/file_permission_policy.h"
103 #include "storage/browser/fileapi/file_system_context.h" 107 #include "storage/browser/fileapi/file_system_context.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 DCHECK_CURRENTLY_ON(BrowserThread::UI); 432 DCHECK_CURRENTLY_ON(BrowserThread::UI);
429 RenderFrameHostImpl* host = 433 RenderFrameHostImpl* host =
430 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); 434 RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
431 if (host != NULL) { 435 if (host != NULL) {
432 DCHECK(host->frame_tree_node()->IsMainFrame()); 436 DCHECK(host->frame_tree_node()->IsMainFrame());
433 host->frame_tree_node()->navigator()->LogResourceRequestTime( 437 host->frame_tree_node()->navigator()->LogResourceRequestTime(
434 timestamp, url); 438 timestamp, url);
435 } 439 }
436 } 440 }
437 441
442 bool QualifiesForAsyncRevalidation(const ResourceHostMsg_Request& request) {
443 if (request.load_flags &
444 (net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE |
445 net::LOAD_VALIDATE_CACHE | net::LOAD_PREFERRING_CACHE |
446 net::LOAD_ONLY_FROM_CACHE)) {
mmenke 2015/10/09 16:02:22 LOAD_IGNORE_LIMITS is also kinda weird. You eithe
Adam Rice 2015/10/13 22:53:17 LOAD_IGNORE_LIMITS is never set by Blink, but I ad
447 return false;
448 }
449 if (request.method != "GET")
450 return false;
451 // A GET request should not have a body, but don't leave it to chance.
452 if (request.request_body.get())
453 return false;
454 if (!request.url.SchemeIsHTTPOrHTTPS())
455 return false;
456 return true;
457 }
458
438 } // namespace 459 } // namespace
439 460
440 // static 461 // static
441 ResourceDispatcherHost* ResourceDispatcherHost::Get() { 462 ResourceDispatcherHost* ResourceDispatcherHost::Get() {
442 return g_resource_dispatcher_host; 463 return g_resource_dispatcher_host;
443 } 464 }
444 465
445 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl() 466 ResourceDispatcherHostImpl::ResourceDispatcherHostImpl()
446 : save_file_manager_(new SaveFileManager()), 467 : save_file_manager_(new SaveFileManager()),
447 request_id_(-1), 468 request_id_(-1),
448 is_shutdown_(false), 469 is_shutdown_(false),
449 num_in_flight_requests_(0), 470 num_in_flight_requests_(0),
450 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()), 471 max_num_in_flight_requests_(base::SharedMemory::GetHandleLimit()),
451 max_num_in_flight_requests_per_process_( 472 max_num_in_flight_requests_per_process_(static_cast<int>(
452 static_cast<int>( 473 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)),
453 max_num_in_flight_requests_ * kMaxRequestsPerProcessRatio)),
454 max_outstanding_requests_cost_per_process_( 474 max_outstanding_requests_cost_per_process_(
455 kMaxOutstandingRequestsCostPerProcess), 475 kMaxOutstandingRequestsCostPerProcess),
456 filter_(NULL), 476 filter_(NULL),
457 delegate_(NULL), 477 delegate_(NULL),
458 allow_cross_origin_auth_prompt_(false) { 478 allow_cross_origin_auth_prompt_(false),
479 async_revalidation_enabled_(false) {
459 DCHECK_CURRENTLY_ON(BrowserThread::UI); 480 DCHECK_CURRENTLY_ON(BrowserThread::UI);
460 DCHECK(!g_resource_dispatcher_host); 481 DCHECK(!g_resource_dispatcher_host);
461 g_resource_dispatcher_host = this; 482 g_resource_dispatcher_host = this;
462 483
463 GetContentClient()->browser()->ResourceDispatcherHostCreated(); 484 GetContentClient()->browser()->ResourceDispatcherHostCreated();
464 485
465 ANNOTATE_BENIGN_RACE( 486 ANNOTATE_BENIGN_RACE(
466 &last_user_gesture_time_, 487 &last_user_gesture_time_,
467 "We don't care about the precise value, see http://crbug.com/92889"); 488 "We don't care about the precise value, see http://crbug.com/92889");
468 489
469 BrowserThread::PostTask(BrowserThread::IO, 490 BrowserThread::PostTask(BrowserThread::IO,
470 FROM_HERE, 491 FROM_HERE,
471 base::Bind(&ResourceDispatcherHostImpl::OnInit, 492 base::Bind(&ResourceDispatcherHostImpl::OnInit,
472 base::Unretained(this))); 493 base::Unretained(this)));
473 494
474 update_load_states_timer_.reset( 495 update_load_states_timer_.reset(
475 new base::RepeatingTimer<ResourceDispatcherHostImpl>()); 496 new base::RepeatingTimer<ResourceDispatcherHostImpl>());
497
498 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
499 if (base::FieldTrialList::FindFullName("StaleWhileRevalidate") == "Enabled" ||
500 command_line->HasSwitch(switches::kEnableStaleWhileRevalidate)) {
501 async_revalidation_enabled_ = true;
502 }
476 } 503 }
477 504
478 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() { 505 ResourceDispatcherHostImpl::~ResourceDispatcherHostImpl() {
479 DCHECK(outstanding_requests_stats_map_.empty()); 506 DCHECK(outstanding_requests_stats_map_.empty());
507 // It's not safe to destroy this object while AsyncRevalidationDriver objects
508 // have callbacks referencing it.
509 CHECK(in_progress_async_revalidations_.empty());
480 DCHECK(g_resource_dispatcher_host); 510 DCHECK(g_resource_dispatcher_host);
481 g_resource_dispatcher_host = NULL; 511 g_resource_dispatcher_host = NULL;
482 } 512 }
483 513
484 // static 514 // static
485 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() { 515 ResourceDispatcherHostImpl* ResourceDispatcherHostImpl::Get() {
486 return g_resource_dispatcher_host; 516 return g_resource_dispatcher_host;
487 } 517 }
488 518
489 void ResourceDispatcherHostImpl::SetDelegate( 519 void ResourceDispatcherHostImpl::SetDelegate(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 (*i)->GetRequestInfo()->is_stream() || 601 (*i)->GetRequestInfo()->is_stream() ||
572 ((*i)->GetRequestInfo()->detachable_handler() && 602 ((*i)->GetRequestInfo()->detachable_handler() &&
573 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) || 603 (*i)->GetRequestInfo()->detachable_handler()->is_detached()) ||
574 (*i)->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER || 604 (*i)->GetRequestInfo()->GetProcessType() == PROCESS_TYPE_BROWSER ||
575 (*i)->is_transferring()); 605 (*i)->is_transferring());
576 } 606 }
577 #endif 607 #endif
578 608
579 loaders_to_cancel.clear(); 609 loaders_to_cancel.clear();
580 610
611 // Cancelling async revalidations should not result in the creation of new
612 // requests, but do it before the checks just to be on the safe side.
613 CancelAsyncRevalidationsForResourceContext(context);
614
581 // Validate that no more requests for this context were added. 615 // Validate that no more requests for this context were added.
582 for (LoaderMap::const_iterator i = pending_loaders_.begin(); 616 for (LoaderMap::const_iterator i = pending_loaders_.begin();
583 i != pending_loaders_.end(); ++i) { 617 i != pending_loaders_.end(); ++i) {
584 // http://crbug.com/90971 618 // http://crbug.com/90971
585 CHECK_NE(i->second->GetRequestInfo()->GetContext(), context); 619 CHECK_NE(i->second->GetRequestInfo()->GetContext(), context);
586 } 620 }
587 621
588 for (BlockedLoadersMap::const_iterator i = blocked_loaders_map_.begin(); 622 for (BlockedLoadersMap::const_iterator i = blocked_loaders_map_.begin();
589 i != blocked_loaders_map_.end(); ++i) { 623 i != blocked_loaders_map_.end(); ++i) {
590 BlockedLoadersList* loaders = i->second; 624 BlockedLoadersList* loaders = i->second;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 // the old handler (AsyncResourceHandler) may modify it in parallel via the 803 // the old handler (AsyncResourceHandler) may modify it in parallel via the
770 // ResourceDispatcherHostDelegate. 804 // ResourceDispatcherHostDelegate.
771 if (response->head.headers.get()) { 805 if (response->head.headers.get()) {
772 stream_info->response_headers = 806 stream_info->response_headers =
773 new net::HttpResponseHeaders(response->head.headers->raw_headers()); 807 new net::HttpResponseHeaders(response->head.headers->raw_headers());
774 } 808 }
775 delegate_->OnStreamCreated(request, stream_info.Pass()); 809 delegate_->OnStreamCreated(request, stream_info.Pass());
776 return handler.Pass(); 810 return handler.Pass();
777 } 811 }
778 812
813 ResourceDispatcherHostImpl::ExtraRequestParams::ExtraRequestParams()
814 : blob_context(nullptr),
815 child_id(0),
816 is_sync_load(false),
817 use_embedded_identity(false),
818 support_async_revalidation(false),
819 extra_headers(nullptr) {}
820
779 ResourceDispatcherHostLoginDelegate* 821 ResourceDispatcherHostLoginDelegate*
780 ResourceDispatcherHostImpl::CreateLoginDelegate( 822 ResourceDispatcherHostImpl::CreateLoginDelegate(
781 ResourceLoader* loader, 823 ResourceLoader* loader,
782 net::AuthChallengeInfo* auth_info) { 824 net::AuthChallengeInfo* auth_info) {
783 if (!delegate_) 825 if (!delegate_)
784 return NULL; 826 return NULL;
785 827
786 return delegate_->CreateLoginDelegate(auth_info, loader->request()); 828 return delegate_->CreateLoginDelegate(auth_info, loader->request());
787 } 829 }
788 830
(...skipping 28 matching lines...) Expand all
817 } 859 }
818 860
819 void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader, 861 void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader,
820 const GURL& new_url) { 862 const GURL& new_url) {
821 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 863 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
822 864
823 int render_process_id, render_frame_host; 865 int render_process_id, render_frame_host;
824 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host)) 866 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host))
825 return; 867 return;
826 868
869 // Remove the LOAD_SUPPORT_ASYNC_REVALIDATION flag if it is present.
870 net::URLRequest* request = loader->request();
871 if (request->load_flags() & net::LOAD_SUPPORT_ASYNC_REVALIDATION) {
872 int new_load_flags = request->load_flags() &
873 ~net::LOAD_SUPPORT_ASYNC_REVALIDATION;
874 request->SetLoadFlags(new_load_flags);
davidben 2015/10/08 21:57:51 This isn't sufficient. The first redirect leg alre
Adam Rice 2015/10/13 22:53:17 I think will just modify net::HttpCache::Transacti
875 }
876
827 // Notify the observers on the UI thread. 877 // Notify the observers on the UI thread.
828 scoped_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails( 878 scoped_ptr<ResourceRedirectDetails> detail(new ResourceRedirectDetails(
829 loader->request(), 879 loader->request(),
830 GetCertID(loader->request(), info->GetChildID()), 880 GetCertID(loader->request(), info->GetChildID()),
831 new_url)); 881 new_url));
832 BrowserThread::PostTask( 882 BrowserThread::PostTask(
833 BrowserThread::UI, FROM_HERE, 883 BrowserThread::UI, FROM_HERE,
834 base::Bind( 884 base::Bind(
835 &NotifyRedirectOnUI, 885 &NotifyRedirectOnUI,
836 render_process_id, render_frame_host, base::Passed(&detail))); 886 render_process_id, render_frame_host, base::Passed(&detail)));
837 } 887 }
838 888
839 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { 889 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) {
840 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); 890 ResourceRequestInfoImpl* info = loader->GetRequestInfo();
841 net::URLRequest* request = loader->request(); 891 net::URLRequest* request = loader->request();
842 if (request->was_fetched_via_proxy() && 892 if (request->was_fetched_via_proxy() &&
843 request->was_fetched_via_spdy() && 893 request->was_fetched_via_spdy() &&
844 request->url().SchemeIs(url::kHttpScheme)) { 894 request->url().SchemeIs(url::kHttpScheme)) {
845 scheduler_->OnReceivedSpdyProxiedHttpResponse( 895 scheduler_->OnReceivedSpdyProxiedHttpResponse(
846 info->GetChildID(), info->GetRouteID()); 896 info->GetChildID(), info->GetRouteID());
847 } 897 }
848 898
899 if (request->response_info().async_revalidation_required)
900 BeginAsyncRevalidation(request);
mmenke 2015/10/09 16:02:22 We shouldn't call this on failures, right? Partic
mmenke 2015/10/09 16:29:57 David pointed out to me that we don't reach this p
901
849 int render_process_id, render_frame_host; 902 int render_process_id, render_frame_host;
850 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host)) 903 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_host))
851 return; 904 return;
852 905
853 // Notify the observers on the UI thread. 906 // Notify the observers on the UI thread.
854 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails( 907 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails(
855 request, GetCertID(request, info->GetChildID()))); 908 request, GetCertID(request, info->GetChildID())));
856 BrowserThread::PostTask( 909 BrowserThread::PostTask(
857 BrowserThread::UI, FROM_HERE, 910 BrowserThread::UI, FROM_HERE,
858 base::Bind( 911 base::Bind(
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 1256
1204 // Allow the observer to block/handle the request. 1257 // Allow the observer to block/handle the request.
1205 if (delegate_ && !delegate_->ShouldBeginRequest(request_data.method, 1258 if (delegate_ && !delegate_->ShouldBeginRequest(request_data.method,
1206 request_data.url, 1259 request_data.url,
1207 request_data.resource_type, 1260 request_data.resource_type,
1208 resource_context)) { 1261 resource_context)) {
1209 AbortRequestBeforeItStarts(filter_, sync_result, request_id); 1262 AbortRequestBeforeItStarts(filter_, sync_result, request_id);
1210 return; 1263 return;
1211 } 1264 }
1212 1265
1213 // Construct the request. 1266 ExtraRequestParams params;
1214 scoped_ptr<net::URLRequest> new_request = request_context->CreateRequest( 1267 params.blob_context = GetBlobStorageContext(filter_->blob_storage_context());
1215 request_data.url, request_data.priority, NULL); 1268 params.child_id = child_id;
1216 1269 params.is_sync_load = sync_result != nullptr;
1217 new_request->set_method(request_data.method); 1270 params.use_embedded_identity = true;
1218 new_request->set_first_party_for_cookies( 1271 params.extra_headers = &headers;
1219 request_data.first_party_for_cookies);
1220
1221 // If the request is a MAIN_FRAME request, the first-party URL gets updated on
1222 // redirects.
1223 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) {
1224 new_request->set_first_party_url_policy(
1225 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT);
1226 }
1227
1228 const Referrer referrer(request_data.referrer, request_data.referrer_policy);
1229 SetReferrerForRequest(new_request.get(), referrer);
1230
1231 new_request->SetExtraRequestHeaders(headers);
1232
1233 storage::BlobStorageContext* blob_context =
1234 GetBlobStorageContext(filter_->blob_storage_context());
1235 // Resolve elements from request_body and prepare upload data.
1236 if (request_data.request_body.get()) {
1237 // |blob_context| could be null when the request is from the plugins because
1238 // ResourceMessageFilters created in PluginProcessHost don't have the blob
1239 // context.
1240 if (blob_context) {
1241 // Attaches the BlobDataHandles to request_body not to free the blobs and
1242 // any attached shareable files until upload completion. These data will
1243 // be used in UploadDataStream and ServiceWorkerURLRequestJob.
1244 AttachRequestBodyBlobDataHandles(
1245 request_data.request_body.get(),
1246 blob_context);
1247 }
1248 new_request->set_upload(UploadDataStreamBuilder::Build(
1249 request_data.request_body.get(),
1250 blob_context,
1251 filter_->file_system_context(),
1252 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
1253 .get()));
1254 }
1255
1256 bool allow_download = request_data.allow_download &&
1257 IsResourceTypeFrame(request_data.resource_type);
1258 bool do_not_prompt_for_login = request_data.do_not_prompt_for_login; 1272 bool do_not_prompt_for_login = request_data.do_not_prompt_for_login;
1259 bool is_sync_load = sync_result != NULL;
1260 int load_flags =
1261 BuildLoadFlagsForRequest(request_data, child_id, is_sync_load);
1262 if (request_data.resource_type == RESOURCE_TYPE_PREFETCH || 1273 if (request_data.resource_type == RESOURCE_TYPE_PREFETCH ||
1263 request_data.resource_type == RESOURCE_TYPE_FAVICON) { 1274 request_data.resource_type == RESOURCE_TYPE_FAVICON) {
1264 do_not_prompt_for_login = true; 1275 do_not_prompt_for_login = true;
1265 } 1276 }
1266 if (request_data.resource_type == RESOURCE_TYPE_IMAGE && 1277 if (request_data.resource_type == RESOURCE_TYPE_IMAGE &&
1267 HTTP_AUTH_RELATION_BLOCKED_CROSS == 1278 HTTP_AUTH_RELATION_BLOCKED_CROSS ==
1268 HttpAuthRelationTypeOf(request_data.url, 1279 HttpAuthRelationTypeOf(request_data.url,
1269 request_data.first_party_for_cookies)) { 1280 request_data.first_party_for_cookies)) {
1270 // Prevent third-party image content from prompting for login, as this 1281 // Prevent third-party image content from prompting for login, as this
1271 // is often a scam to extract credentials for another domain from the user. 1282 // is often a scam to extract credentials for another domain from the user.
1272 // Only block image loads, as the attack applies largely to the "src" 1283 // Only block image loads, as the attack applies largely to the "src"
1273 // property of the <img> tag. It is common for web properties to allow 1284 // property of the <img> tag. It is common for web properties to allow
1274 // untrusted values for <img src>; this is considered a fair thing for an 1285 // untrusted values for <img src>; this is considered a fair thing for an
1275 // HTML sanitizer to do. Conversely, any HTML sanitizer that didn't 1286 // HTML sanitizer to do. Conversely, any HTML sanitizer that didn't
1276 // filter sources for <script>, <link>, <embed>, <object>, <iframe> tags 1287 // filter sources for <script>, <link>, <embed>, <object>, <iframe> tags
1277 // would be considered vulnerable in and of itself. 1288 // would be considered vulnerable in and of itself.
1278 do_not_prompt_for_login = true; 1289 do_not_prompt_for_login = true;
1279 load_flags |= net::LOAD_DO_NOT_USE_EMBEDDED_IDENTITY; 1290 params.use_embedded_identity = false;
1280 } 1291 }
1281 1292
1282 // Sync loads should have maximum priority and should be the only 1293 // Check if request is eligible for async revalidation.
1283 // requets that have the ignore limits flag set. 1294 params.support_async_revalidation =
1284 if (is_sync_load) { 1295 (!params.is_sync_load && async_revalidation_enabled_ &&
1285 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY); 1296 QualifiesForAsyncRevalidation(request_data));
mmenke 2015/10/08 21:58:26 We shouldn't do async revalidations when "predicti
Adam Rice 2015/10/13 22:53:17 I don't agree that stale-while-revalidate is a pre
mmenke 2015/10/13 23:01:53 You are guessing that it will be used in the futur
mmenke 2015/10/14 00:16:49 Worth noting it also potentially drains battery by
Adam Rice 2015/10/14 15:03:45 The feature is not speculative. We are not making
1286 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0); 1297
1287 } else { 1298 scoped_ptr<net::URLRequest> new_request =
1288 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0); 1299 ConstructRequest(request_context, request_data, params);
1289 } 1300
1290 new_request->SetLoadFlags(load_flags); 1301 bool allow_download = request_data.allow_download &&
1302 IsResourceTypeFrame(request_data.resource_type);
1291 1303
1292 // Make extra info and read footer (contains request ID). 1304 // Make extra info and read footer (contains request ID).
1293 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl( 1305 ResourceRequestInfoImpl* extra_info = new ResourceRequestInfoImpl(
1294 process_type, child_id, route_id, 1306 process_type, child_id, route_id,
1295 -1, // frame_tree_node_id 1307 -1, // frame_tree_node_id
1296 request_data.origin_pid, 1308 request_data.origin_pid,
1297 request_id, 1309 request_id,
1298 request_data.render_frame_id, 1310 request_data.render_frame_id,
1299 request_data.is_main_frame, 1311 request_data.is_main_frame,
1300 request_data.parent_is_main_frame, 1312 request_data.parent_is_main_frame,
1301 request_data.parent_render_frame_id, 1313 request_data.parent_render_frame_id,
1302 request_data.resource_type, 1314 request_data.resource_type,
1303 request_data.transition_type, 1315 request_data.transition_type,
1304 request_data.should_replace_current_entry, 1316 request_data.should_replace_current_entry,
1305 false, // is download 1317 false, // is download
1306 false, // is stream 1318 false, // is stream
1307 allow_download, 1319 allow_download,
1308 request_data.has_user_gesture, 1320 request_data.has_user_gesture,
1309 request_data.enable_load_timing, 1321 request_data.enable_load_timing,
1310 request_data.enable_upload_progress, 1322 request_data.enable_upload_progress,
1311 do_not_prompt_for_login, 1323 do_not_prompt_for_login,
1312 request_data.referrer_policy, 1324 request_data.referrer_policy,
1313 request_data.visiblity_state, 1325 request_data.visiblity_state,
1314 resource_context, filter_->GetWeakPtr(), 1326 resource_context, filter_->GetWeakPtr(),
1315 !is_sync_load); 1327 !params.is_sync_load,
1328 params.support_async_revalidation ? &request_data : NULL);
1316 // Request takes ownership. 1329 // Request takes ownership.
1317 extra_info->AssociateWithRequest(new_request.get()); 1330 extra_info->AssociateWithRequest(new_request.get());
1318 1331
1319 if (new_request->url().SchemeIs(url::kBlobScheme)) { 1332 if (new_request->url().SchemeIs(url::kBlobScheme)) {
1320 // Hang on to a reference to ensure the blob is not released prior 1333 // Hang on to a reference to ensure the blob is not released prior
1321 // to the job being started. 1334 // to the job being started.
1322 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 1335 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
1323 new_request.get(), 1336 new_request.get(),
1324 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL( 1337 filter_->blob_storage_context()->context()->GetBlobDataFromPublicURL(
1325 new_request->url())); 1338 new_request->url()));
1326 } 1339 }
1327 1340
1328 // Initialize the service worker handler for the request. We don't use 1341 // Initialize the service worker handler for the request. We don't use
1329 // ServiceWorker for synchronous loads to avoid renderer deadlocks. 1342 // ServiceWorker for synchronous loads to avoid renderer deadlocks.
1330 ServiceWorkerRequestHandler::InitializeHandler( 1343 ServiceWorkerRequestHandler::InitializeHandler(
1331 new_request.get(), filter_->service_worker_context(), blob_context, 1344 new_request.get(), filter_->service_worker_context(), params.blob_context,
1332 child_id, request_data.service_worker_provider_id, 1345 child_id, request_data.service_worker_provider_id,
1333 request_data.skip_service_worker || is_sync_load, 1346 request_data.skip_service_worker || params.is_sync_load,
1334 request_data.fetch_request_mode, request_data.fetch_credentials_mode, 1347 request_data.fetch_request_mode, request_data.fetch_credentials_mode,
1335 request_data.fetch_redirect_mode, request_data.resource_type, 1348 request_data.fetch_redirect_mode, request_data.resource_type,
1336 request_data.fetch_request_context_type, request_data.fetch_frame_type, 1349 request_data.fetch_request_context_type, request_data.fetch_frame_type,
1337 request_data.request_body); 1350 request_data.request_body);
1338 1351
1339 // Have the appcache associate its extra info with the request. 1352 // Have the appcache associate its extra info with the request.
1340 AppCacheInterceptor::SetExtraRequestInfo( 1353 AppCacheInterceptor::SetExtraRequestInfo(
1341 new_request.get(), filter_->appcache_service(), child_id, 1354 new_request.get(), filter_->appcache_service(), child_id,
1342 request_data.appcache_host_id, request_data.resource_type, 1355 request_data.appcache_host_id, request_data.resource_type,
1343 request_data.should_reset_appcache); 1356 request_data.should_reset_appcache);
1344 1357
1345 scoped_ptr<ResourceHandler> handler( 1358 scoped_ptr<ResourceHandler> handler(CreateResourceHandler(
1346 CreateResourceHandler( 1359 new_request.get(), request_data, sync_result, route_id, process_type,
1347 new_request.get(), 1360 child_id, resource_context));
1348 request_data, sync_result, route_id, process_type, child_id,
1349 resource_context));
1350 1361
1351 if (handler) 1362 if (handler)
1352 BeginRequestInternal(new_request.Pass(), handler.Pass()); 1363 BeginRequestInternal(new_request.Pass(), handler.Pass());
1353 } 1364 }
1354 1365
1366 scoped_ptr<net::URLRequest> ResourceDispatcherHostImpl::ConstructRequest(
1367 net::URLRequestContext* request_context,
1368 const ResourceHostMsg_Request& request_data,
1369 const ExtraRequestParams& extra_params) {
1370 // Construct the request.
1371 scoped_ptr<net::URLRequest> new_request = request_context->CreateRequest(
1372 request_data.url, request_data.priority, NULL);
1373
1374 new_request->set_method(request_data.method);
1375 new_request->set_first_party_for_cookies(
1376 request_data.first_party_for_cookies);
1377
1378 // If the request is a MAIN_FRAME request, the first-party URL gets updated on
1379 // redirects.
1380 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME) {
1381 new_request->set_first_party_url_policy(
1382 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT);
1383 }
1384
1385 const Referrer referrer(request_data.referrer, request_data.referrer_policy);
1386 SetReferrerForRequest(new_request.get(), referrer);
1387
1388 new_request->SetExtraRequestHeaders(*extra_params.extra_headers);
1389
1390 // Resolve elements from request_body and prepare upload data.
1391 if (request_data.request_body.get()) {
1392 // |blob_context| could be null when the request is from the plugins because
1393 // ResourceMessageFilters created in PluginProcessHost don't have the blob
1394 // context.
1395 if (extra_params.blob_context) {
1396 // Attaches the BlobDataHandles to request_body not to free the blobs and
1397 // any attached shareable files until upload completion. These data will
1398 // be used in UploadDataStream and ServiceWorkerURLRequestJob.
1399 AttachRequestBodyBlobDataHandles(request_data.request_body.get(),
1400 extra_params.blob_context);
1401 }
1402 new_request->set_upload(UploadDataStreamBuilder::Build(
1403 request_data.request_body.get(), extra_params.blob_context,
1404 filter_->file_system_context(),
1405 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
1406 .get()));
1407 }
1408
1409 int load_flags = BuildLoadFlagsForRequest(request_data, extra_params.child_id,
1410 extra_params.is_sync_load);
1411
1412 if (!extra_params.use_embedded_identity)
1413 load_flags |= net::LOAD_DO_NOT_USE_EMBEDDED_IDENTITY;
1414
1415 if (extra_params.support_async_revalidation)
1416 load_flags |= net::LOAD_SUPPORT_ASYNC_REVALIDATION;
1417
1418 // Sync loads should have maximum priority and should be the only
1419 // requests that have the ignore limits flag set.
1420 if (extra_params.is_sync_load) {
1421 DCHECK_EQ(request_data.priority, net::MAXIMUM_PRIORITY);
1422 DCHECK_NE(load_flags & net::LOAD_IGNORE_LIMITS, 0);
1423 } else {
1424 DCHECK_EQ(load_flags & net::LOAD_IGNORE_LIMITS, 0);
1425 }
1426 new_request->SetLoadFlags(load_flags);
1427
1428 return new_request.Pass();
1429 }
1430
1355 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler( 1431 scoped_ptr<ResourceHandler> ResourceDispatcherHostImpl::CreateResourceHandler(
1356 net::URLRequest* request, 1432 net::URLRequest* request,
1357 const ResourceHostMsg_Request& request_data, 1433 const ResourceHostMsg_Request& request_data,
1358 IPC::Message* sync_result, 1434 IPC::Message* sync_result,
1359 int route_id, 1435 int route_id,
1360 int process_type, 1436 int process_type,
1361 int child_id, 1437 int child_id,
1362 ResourceContext* resource_context) { 1438 ResourceContext* resource_context) {
1363 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. 1439 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
1364 tracked_objects::ScopedTracker tracking_profile( 1440 tracked_objects::ScopedTracker tracking_profile(
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 false, // is_stream 1652 false, // is_stream
1577 download, // allow_download 1653 download, // allow_download
1578 false, // has_user_gesture 1654 false, // has_user_gesture
1579 false, // enable_load_timing 1655 false, // enable_load_timing
1580 false, // enable_upload_progress 1656 false, // enable_upload_progress
1581 false, // do_not_prompt_for_login 1657 false, // do_not_prompt_for_login
1582 blink::WebReferrerPolicyDefault, 1658 blink::WebReferrerPolicyDefault,
1583 blink::WebPageVisibilityStateVisible, 1659 blink::WebPageVisibilityStateVisible,
1584 context, 1660 context,
1585 base::WeakPtr<ResourceMessageFilter>(), // filter 1661 base::WeakPtr<ResourceMessageFilter>(), // filter
1586 true); // is_async 1662 true, // is_async
1663 NULL); // original_request
davidben 2015/10/08 21:57:52 nullptr
Adam Rice 2015/10/13 22:53:17 Done.
1587 } 1664 }
1588 1665
1589 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id, 1666 void ResourceDispatcherHostImpl::OnRenderViewHostCreated(int child_id,
1590 int route_id, 1667 int route_id,
1591 bool is_visible, 1668 bool is_visible,
1592 bool is_audible) { 1669 bool is_audible) {
1593 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible); 1670 scheduler_->OnClientCreated(child_id, route_id, is_visible, is_audible);
1594 } 1671 }
1595 1672
1596 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted( 1673 void ResourceDispatcherHostImpl::OnRenderViewHostDeleted(
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 true, // enable_load_timing 2096 true, // enable_load_timing
2020 false, // enable_upload_progress 2097 false, // enable_upload_progress
2021 false, // do_not_prompt_for_login 2098 false, // do_not_prompt_for_login
2022 info.common_params.referrer.policy, 2099 info.common_params.referrer.policy,
2023 // TODO(davidben): This is only used for prerenders. Replace 2100 // TODO(davidben): This is only used for prerenders. Replace
2024 // is_showing with something for that. Or maybe it just comes from the 2101 // is_showing with something for that. Or maybe it just comes from the
2025 // same mechanism as the cookie one. 2102 // same mechanism as the cookie one.
2026 blink::WebPageVisibilityStateVisible, 2103 blink::WebPageVisibilityStateVisible,
2027 resource_context, 2104 resource_context,
2028 base::WeakPtr<ResourceMessageFilter>(), // filter 2105 base::WeakPtr<ResourceMessageFilter>(), // filter
2029 true); 2106 true, // is_async
2107 NULL); // original_message
davidben 2015/10/08 21:57:51 original_request
davidben 2015/10/08 21:57:52 nullptr
Adam Rice 2015/10/13 22:53:17 Done.
Adam Rice 2015/10/13 22:53:17 Done.
2030 // Request takes ownership. 2108 // Request takes ownership.
2031 extra_info->AssociateWithRequest(new_request.get()); 2109 extra_info->AssociateWithRequest(new_request.get());
2032 2110
2033 if (new_request->url().SchemeIs(url::kBlobScheme)) { 2111 if (new_request->url().SchemeIs(url::kBlobScheme)) {
2034 // Hang on to a reference to ensure the blob is not released prior 2112 // Hang on to a reference to ensure the blob is not released prior
2035 // to the job being started. 2113 // to the job being started.
2036 ChromeBlobStorageContext* blob_context = 2114 ChromeBlobStorageContext* blob_context =
2037 GetChromeBlobStorageContextForResourceContext(resource_context); 2115 GetChromeBlobStorageContextForResourceContext(resource_context);
2038 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( 2116 storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
2039 new_request.get(), 2117 new_request.get(),
2040 blob_context->context()->GetBlobDataFromPublicURL(new_request->url())); 2118 blob_context->context()->GetBlobDataFromPublicURL(new_request->url()));
2041 } 2119 }
2042 2120
2043 // TODO(davidben): Attach ServiceWorkerRequestHandler. 2121 // TODO(davidben): Attach ServiceWorkerRequestHandler.
2044 // TODO(michaeln): Help out with this and that. 2122 // TODO(michaeln): Help out with this and that.
2045 // TODO(davidben): Attach AppCacheInterceptor. 2123 // TODO(davidben): Attach AppCacheInterceptor.
2046 2124
2047 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler( 2125 scoped_ptr<ResourceHandler> handler(new NavigationResourceHandler(
2048 new_request.get(), loader)); 2126 new_request.get(), loader));
2049 2127
2050 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the 2128 // TODO(davidben): Pass in the appropriate appcache_service. Also fix the
2051 // dependency on child_id/route_id. Those are used by the ResourceScheduler; 2129 // dependency on child_id/route_id. Those are used by the ResourceScheduler;
2052 // currently it's a no-op. 2130 // currently it's a no-op.
2053 handler = AddStandardHandlers(new_request.get(), resource_type, 2131 handler = AddStandardHandlers(new_request.get(), resource_type,
2054 resource_context, 2132 resource_context,
2055 nullptr, // appcache_service 2133 nullptr, // appcache_service
2056 -1, // child_id 2134 -1, // child_id
2057 -1, // route_id 2135 -1, // route_id
2058 handler.Pass()); 2136 handler.Pass());
2059 2137
2060 BeginRequestInternal(new_request.Pass(), handler.Pass()); 2138 BeginRequestInternal(new_request.Pass(), handler.Pass());
2061 } 2139 }
2062 2140
2063 // static 2141 // static
2064 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost( 2142 int ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(
2065 net::URLRequest* request) { 2143 net::URLRequest* request) {
2066 // The following fields should be a minor size contribution (experimentally 2144 // The following fields should be a minor size contribution (experimentally
2067 // on the order of 100). However since they are variable length, it could 2145 // on the order of 100). However since they are variable length, it could
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2385 // allow requesting them if requester has ReadRawCookies permission. 2463 // allow requesting them if requester has ReadRawCookies permission.
2386 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) 2464 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS)
2387 && !policy->CanReadRawCookies(child_id)) { 2465 && !policy->CanReadRawCookies(child_id)) {
2388 VLOG(1) << "Denied unauthorized request for raw headers"; 2466 VLOG(1) << "Denied unauthorized request for raw headers";
2389 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; 2467 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS;
2390 } 2468 }
2391 2469
2392 return load_flags; 2470 return load_flags;
2393 } 2471 }
2394 2472
2473 void ResourceDispatcherHostImpl::BeginAsyncRevalidation(
2474 net::URLRequest* for_request) {
2475 ResourceRequestInfoImpl* info =
2476 ResourceRequestInfoImpl::ForRequest(for_request);
2477 DCHECK(info);
2478 ResourceHostMsg_Request* original_request_data = info->original_request();
2479 DCHECK(original_request_data);
2480 DCHECK(!original_request_data->request_body);
2481
2482 ResourceHostMsg_Request new_request_data = *original_request_data;
2483 new_request_data.do_not_prompt_for_login = true;
2484 new_request_data.allow_download = false;
2485 new_request_data.priority = net::MINIMUM_PRIORITY;
2486
2487 int child_id = info->GetChildID();
2488 int route_id = info->GetRouteID();
2489
2490 ResourceContext* resource_context = NULL;
2491 net::URLRequestContext* request_context = NULL;
2492 // This |request_context| needs to be valid until
2493 // RemoveResourceContext(resource_context) is called. This is currently
2494 // correct, see
2495 // https://groups.google.com/a/chromium.org/d/msg/net-dev/lHh764ZFdr0/phJIWXok t7cJ
davidben 2015/10/08 21:57:51 I must have missed the context when you made the o
Adam Rice 2015/10/13 22:53:17 If the child is already gone at this point, I thin
2496 info->filter()->GetContexts(new_request_data, &resource_context,
2497 &request_context);
2498 CHECK(ContainsKey(active_resource_contexts_, resource_context));
2499 if (is_shutdown_)
2500 return;
mmenke 2015/10/09 16:02:22 Can this happen while shutting down? Also, why is
Adam Rice 2015/10/13 22:53:17 1. Based on other uses in this file: probably. 2.
2501
2502 AsyncRevalidationKey async_revalidation_key(
2503 resource_context, request_context->http_transaction_factory()->GetCache(),
2504 original_request_data->url);
2505 std::pair<AsyncRevalidationMap::iterator, bool> insert_result =
2506 in_progress_async_revalidations_.insert(
2507 AsyncRevalidationMap::value_type(async_revalidation_key, nullptr));
2508 if (!insert_result.second) {
2509 // A matching async revalidation is already in progress for this cache; we
2510 // don't need another one.
2511 return;
2512 }
2513
2514 net::HttpRequestHeaders headers;
2515 headers.AddHeadersFromString(new_request_data.headers);
davidben 2015/10/08 21:57:51 If the request did not change, it really needs to
Adam Rice 2015/10/13 22:53:17 The cache will conditionalize the request if If-Mo
2516
2517 ExtraRequestParams params;
2518 params.child_id = child_id;
davidben 2015/10/08 21:57:52 This request cannot be associated with this proces
Adam Rice 2015/10/13 22:53:17 This is only used by BuildLoadFlagsForRequest to d
2519 params.is_sync_load = false;
2520 params.use_embedded_identity = true;
2521 params.support_async_revalidation = false;
2522 params.extra_headers = &headers;
2523 if (new_request_data.resource_type == RESOURCE_TYPE_IMAGE &&
2524 HTTP_AUTH_RELATION_BLOCKED_CROSS ==
2525 HttpAuthRelationTypeOf(new_request_data.url,
2526 new_request_data.first_party_for_cookies)) {
davidben 2015/10/08 21:57:52 We should avoid duplicating this code. Ideally by
Adam Rice 2015/10/13 22:53:17 I would rather do the experiment first before worr
2527 // Prevent <img> tags from using cached credentials to third-party sites
2528 // to perform actions on those sites.
2529 params.use_embedded_identity = false;
2530 }
2531
2532 scoped_ptr<net::URLRequest> new_request =
2533 ConstructRequest(request_context, new_request_data, params);
2534
2535 scoped_ptr<ResourceThrottle> throttle = scheduler_->ScheduleRequest(
2536 child_id, route_id, false, new_request.get());
davidben 2015/10/08 21:57:51 Associating the request with child_id / route_id d
Adam Rice 2015/10/13 22:53:17 The async request has to be scheduled after the ot
2537 // This use of base::Unretained() is safe because the AsyncRevalidatonDriver
2538 // object will be destroyed before this object is.
2539 insert_result.first->second = new AsyncRevalidationDriver(
2540 new_request.Pass(), throttle.Pass(),
2541 base::Bind(&ResourceDispatcherHostImpl::OnAsyncRevalidationComplete,
2542 base::Unretained(this), async_revalidation_key));
mmenke 2015/10/09 16:02:22 Not creating a ResourceRequestInfo for the request
Adam Rice 2015/10/13 22:53:17 Sorry, I thought we had agreed that the request sh
mmenke 2015/10/13 23:01:53 I'm not saying we should have the object, but that
2543 insert_result.first->second->StartRequest();
2544 }
2545
2546 void ResourceDispatcherHostImpl::OnAsyncRevalidationComplete(
2547 const AsyncRevalidationKey& key) {
2548 // TODO(ricea): Record histograms?
2549 auto it = in_progress_async_revalidations_.find(key);
2550 // This is CHECK() and not DCHECK() because deferencing an off-the-end
2551 // iterator would cause a security hole.
2552 CHECK(it != in_progress_async_revalidations_.end());
davidben 2015/10/08 21:57:52 I don't think we do CHECK vs DCHECK this way. Othe
Adam Rice 2015/10/13 22:53:17 My understanding is that the security people would
2553 delete it->second, it->second = nullptr;
davidben 2015/10/08 21:57:51 Style: Don't use the comma operator.
Adam Rice 2015/10/13 22:53:17 Done.
2554 in_progress_async_revalidations_.erase(it);
2555 }
2556
2557 void ResourceDispatcherHostImpl::CancelAsyncRevalidationsForResourceContext(
2558 ResourceContext* resource_context) {
2559 // For this algorithm to work, elements using |resource_context| must be
2560 // contiguous in the map (ie. it must form the first part of the key).
2561 AsyncRevalidationKey partial_key(resource_context);
2562 auto next_it = in_progress_async_revalidations_.lower_bound(partial_key);
2563 while (next_it != in_progress_async_revalidations_.end() &&
2564 next_it->first.resource_context == resource_context) {
2565 // Erasing the element invalidates the iterator. Increment it first.
2566 auto current_it = next_it++;
2567 current_it->second->CancelRequest();
2568 delete current_it->second, current_it->second = nullptr;
davidben 2015/10/08 21:57:52 Style: Don't use the comma operator.
Adam Rice 2015/10/13 22:53:17 Done.
2569 in_progress_async_revalidations_.erase(current_it);
2570 }
2571 }
2572
2395 } // namespace content 2573 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698