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/renderer_host/resource_dispatcher_host_impl.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 364 |
365 void ResourceDispatcherHostImpl::SetDelegate( | 365 void ResourceDispatcherHostImpl::SetDelegate( |
366 ResourceDispatcherHostDelegate* delegate) { | 366 ResourceDispatcherHostDelegate* delegate) { |
367 delegate_ = delegate; | 367 delegate_ = delegate; |
368 } | 368 } |
369 | 369 |
370 void ResourceDispatcherHostImpl::SetAllowCrossOriginAuthPrompt(bool value) { | 370 void ResourceDispatcherHostImpl::SetAllowCrossOriginAuthPrompt(bool value) { |
371 allow_cross_origin_auth_prompt_ = value; | 371 allow_cross_origin_auth_prompt_ = value; |
372 } | 372 } |
373 | 373 |
| 374 void ResourceDispatcherHostImpl::AddResourceContext(ResourceContext* context) { |
| 375 active_resource_contexts_.insert(context); |
| 376 } |
| 377 |
| 378 void ResourceDispatcherHostImpl::RemoveResourceContext( |
| 379 ResourceContext* context) { |
| 380 CHECK(ContainsKey(active_resource_contexts_, context)); |
| 381 active_resource_contexts_.erase(context); |
| 382 } |
| 383 |
374 void ResourceDispatcherHostImpl::CancelRequestsForContext( | 384 void ResourceDispatcherHostImpl::CancelRequestsForContext( |
375 ResourceContext* context) { | 385 ResourceContext* context) { |
376 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
377 DCHECK(context); | 387 DCHECK(context); |
378 | 388 |
379 canceled_resource_contexts_.insert(context); | 389 CHECK(ContainsKey(active_resource_contexts_, context)); |
380 | 390 |
381 // Note that request cancellation has side effects. Therefore, we gather all | 391 // Note that request cancellation has side effects. Therefore, we gather all |
382 // the requests to cancel first, and then we start cancelling. We assert at | 392 // the requests to cancel first, and then we start cancelling. We assert at |
383 // the end that there are no more to cancel since the context is about to go | 393 // the end that there are no more to cancel since the context is about to go |
384 // away. | 394 // away. |
385 std::vector<net::URLRequest*> requests_to_cancel; | 395 std::vector<net::URLRequest*> requests_to_cancel; |
386 for (PendingRequestList::iterator i = pending_requests_.begin(); | 396 for (PendingRequestList::iterator i = pending_requests_.begin(); |
387 i != pending_requests_.end();) { | 397 i != pending_requests_.end();) { |
388 ResourceRequestInfoImpl* info = | 398 ResourceRequestInfoImpl* info = |
389 ResourceRequestInfoImpl::ForRequest(i->second); | 399 ResourceRequestInfoImpl::ForRequest(i->second); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 const DownloadStartedCallback& started_callback) { | 484 const DownloadStartedCallback& started_callback) { |
475 if (is_shutdown_) | 485 if (is_shutdown_) |
476 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); | 486 return CallbackAndReturn(started_callback, net::ERR_INSUFFICIENT_RESOURCES); |
477 | 487 |
478 const GURL& url = request->original_url(); | 488 const GURL& url = request->original_url(); |
479 | 489 |
480 // http://crbug.com/90971 | 490 // http://crbug.com/90971 |
481 char url_buf[128]; | 491 char url_buf[128]; |
482 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); | 492 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); |
483 base::debug::Alias(url_buf); | 493 base::debug::Alias(url_buf); |
484 CHECK(!ContainsKey(canceled_resource_contexts_, context)); | 494 CHECK(ContainsKey(active_resource_contexts_, context)); |
485 | 495 |
486 const net::URLRequestContext* request_context = context->GetRequestContext(); | 496 const net::URLRequestContext* request_context = context->GetRequestContext(); |
487 request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec()); | 497 request->set_referrer(MaybeStripReferrer(GURL(request->referrer())).spec()); |
488 request->set_context(request_context); | 498 request->set_context(request_context); |
489 int extra_load_flags = net::LOAD_IS_DOWNLOAD; | 499 int extra_load_flags = net::LOAD_IS_DOWNLOAD; |
490 if (prefer_cache) { | 500 if (prefer_cache) { |
491 // If there is upload data attached, only retrieve from cache because there | 501 // If there is upload data attached, only retrieve from cache because there |
492 // is no current mechanism to prompt the user for their consent for a | 502 // is no current mechanism to prompt the user for their consent for a |
493 // re-post. For GETs, try to retrieve data from the cache and skip | 503 // re-post. For GETs, try to retrieve data from the cache and skip |
494 // validating the entry if present. | 504 // validating the entry if present. |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 TransferredNavigations::iterator iter = | 757 TransferredNavigations::iterator iter = |
748 transferred_navigations_.find(old_request_id); | 758 transferred_navigations_.find(old_request_id); |
749 if (iter != transferred_navigations_.end()) { | 759 if (iter != transferred_navigations_.end()) { |
750 deferred_request = iter->second; | 760 deferred_request = iter->second; |
751 pending_requests_.erase(old_request_id); | 761 pending_requests_.erase(old_request_id); |
752 transferred_navigations_.erase(iter); | 762 transferred_navigations_.erase(iter); |
753 } | 763 } |
754 | 764 |
755 ResourceContext* resource_context = filter_->resource_context(); | 765 ResourceContext* resource_context = filter_->resource_context(); |
756 // http://crbug.com/90971 | 766 // http://crbug.com/90971 |
757 CHECK(!ContainsKey(canceled_resource_contexts_, resource_context)); | 767 CHECK(ContainsKey(active_resource_contexts_, resource_context)); |
758 | 768 |
759 // Might need to resolve the blob references in the upload data. | 769 // Might need to resolve the blob references in the upload data. |
760 if (request_data.upload_data) { | 770 if (request_data.upload_data) { |
761 GetBlobStorageControllerForResourceContext(resource_context)-> | 771 GetBlobStorageControllerForResourceContext(resource_context)-> |
762 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); | 772 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); |
763 } | 773 } |
764 | 774 |
765 if (is_shutdown_ || | 775 if (is_shutdown_ || |
766 !ShouldServiceRequest(process_type, child_id, request_data)) { | 776 !ShouldServiceRequest(process_type, child_id, request_data)) { |
767 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 777 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 int child_id, | 1163 int child_id, |
1154 int route_id, | 1164 int route_id, |
1155 ResourceContext* context) { | 1165 ResourceContext* context) { |
1156 if (is_shutdown_) | 1166 if (is_shutdown_) |
1157 return; | 1167 return; |
1158 | 1168 |
1159 // http://crbug.com/90971 | 1169 // http://crbug.com/90971 |
1160 char url_buf[128]; | 1170 char url_buf[128]; |
1161 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); | 1171 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); |
1162 base::debug::Alias(url_buf); | 1172 base::debug::Alias(url_buf); |
1163 CHECK(!ContainsKey(canceled_resource_contexts_, context)); | 1173 CHECK(ContainsKey(active_resource_contexts_, context)); |
1164 | 1174 |
1165 scoped_refptr<ResourceHandler> handler( | 1175 scoped_refptr<ResourceHandler> handler( |
1166 new SaveFileResourceHandler(child_id, | 1176 new SaveFileResourceHandler(child_id, |
1167 route_id, | 1177 route_id, |
1168 url, | 1178 url, |
1169 save_file_manager_.get())); | 1179 save_file_manager_.get())); |
1170 request_id_--; | 1180 request_id_--; |
1171 | 1181 |
1172 const net::URLRequestContext* request_context = context->GetRequestContext(); | 1182 const net::URLRequestContext* request_context = context->GetRequestContext(); |
1173 bool known_proto = | 1183 bool known_proto = |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2334 return allow_cross_origin_auth_prompt_; | 2344 return allow_cross_origin_auth_prompt_; |
2335 } | 2345 } |
2336 | 2346 |
2337 bool ResourceDispatcherHostImpl::IsTransferredNavigation( | 2347 bool ResourceDispatcherHostImpl::IsTransferredNavigation( |
2338 const GlobalRequestID& transferred_request_id) const { | 2348 const GlobalRequestID& transferred_request_id) const { |
2339 return transferred_navigations_.find(transferred_request_id) != | 2349 return transferred_navigations_.find(transferred_request_id) != |
2340 transferred_navigations_.end(); | 2350 transferred_navigations_.end(); |
2341 } | 2351 } |
2342 | 2352 |
2343 } // namespace content | 2353 } // namespace content |
OLD | NEW |