Chromium Code Reviews| 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 <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 net::Error net_error) { | 224 net::Error net_error) { |
| 225 if (started_cb.is_null()) | 225 if (started_cb.is_null()) |
| 226 return net_error; | 226 return net_error; |
| 227 BrowserThread::PostTask( | 227 BrowserThread::PostTask( |
| 228 BrowserThread::UI, FROM_HERE, | 228 BrowserThread::UI, FROM_HERE, |
| 229 base::Bind(started_cb, static_cast<DownloadItem*>(NULL), net_error)); | 229 base::Bind(started_cb, static_cast<DownloadItem*>(NULL), net_error)); |
| 230 | 230 |
| 231 return net_error; | 231 return net_error; |
| 232 } | 232 } |
| 233 | 233 |
| 234 int BuildLoadFlagsForRequest(const ResourceHostMsg_Request& request_data, | 234 int BuildLoadFlagsForRequest( |
| 235 int child_id, bool is_sync_load) { | 235 const ResourceHostMsg_Request& request_data, int child_id, |
|
darin (slow to review)
2013/04/11 20:01:23
nit: I think the style guide says to put one argum
Randy Smith (Not in Mondays)
2013/04/12 14:06:44
Wow, right you are. I wonder if that changed rece
| |
| 236 bool is_sync_load) { | |
| 236 int load_flags = request_data.load_flags; | 237 int load_flags = request_data.load_flags; |
| 237 | 238 |
| 238 // Although EV status is irrelevant to sub-frames and sub-resources, we have | 239 // Although EV status is irrelevant to sub-frames and sub-resources, we have |
| 239 // to perform EV certificate verification on all resources because an HTTP | 240 // to perform EV certificate verification on all resources because an HTTP |
| 240 // keep-alive connection created to load a sub-frame or a sub-resource could | 241 // keep-alive connection created to load a sub-frame or a sub-resource could |
| 241 // be reused to load a main frame. | 242 // be reused to load a main frame. |
| 242 load_flags |= net::LOAD_VERIFY_EV_CERT; | 243 load_flags |= net::LOAD_VERIFY_EV_CERT; |
| 243 if (request_data.resource_type == ResourceType::MAIN_FRAME) { | 244 if (request_data.resource_type == ResourceType::MAIN_FRAME) { |
| 244 load_flags |= net::LOAD_MAIN_FRAME; | 245 load_flags |= net::LOAD_MAIN_FRAME; |
| 245 } else if (request_data.resource_type == ResourceType::SUB_FRAME) { | 246 } else if (request_data.resource_type == ResourceType::SUB_FRAME) { |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 BrowserThread::PostTask( | 696 BrowserThread::PostTask( |
| 696 BrowserThread::UI, FROM_HERE, | 697 BrowserThread::UI, FROM_HERE, |
| 697 base::Bind( | 698 base::Bind( |
| 698 &NotifyOnUI<ResourceRedirectDetails>, | 699 &NotifyOnUI<ResourceRedirectDetails>, |
| 699 static_cast<int>(NOTIFICATION_RESOURCE_RECEIVED_REDIRECT), | 700 static_cast<int>(NOTIFICATION_RESOURCE_RECEIVED_REDIRECT), |
| 700 render_process_id, render_view_id, base::Passed(&detail))); | 701 render_process_id, render_view_id, base::Passed(&detail))); |
| 701 } | 702 } |
| 702 | 703 |
| 703 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { | 704 void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { |
| 704 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 705 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| 706 // There should be an entry in the map created when we dispatched the | |
|
darin (slow to review)
2013/04/11 20:01:23
DCHECK that this is true? operator[] will create
Randy Smith (Not in Mondays)
2013/04/12 14:06:44
So my basic response to this is "Sure" and I'll pu
| |
| 707 // request. | |
| 708 offline_map_[ProcessRouteIDs(info->GetChildID(), info->GetRouteID())]-> | |
|
darin (slow to review)
2013/04/11 20:01:23
It could also be reasonable for ResourceRequestInf
Randy Smith (Not in Mondays)
2013/04/12 14:06:44
Done, though it was a bit of a yak shave. If you
| |
| 709 RequestCompleted(loader->request()->response_info()); | |
| 705 | 710 |
| 706 int render_process_id, render_view_id; | 711 int render_process_id, render_view_id; |
| 707 if (!info->GetAssociatedRenderView(&render_process_id, &render_view_id)) | 712 if (!info->GetAssociatedRenderView(&render_process_id, &render_view_id)) |
| 708 return; | 713 return; |
| 709 | 714 |
| 710 // Notify the observers on the UI thread. | 715 // Notify the observers on the UI thread. |
| 711 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails( | 716 scoped_ptr<ResourceRequestDetails> detail(new ResourceRequestDetails( |
| 712 loader->request(), | 717 loader->request(), |
| 713 GetCertID(loader->request(), info->GetChildID()))); | 718 GetCertID(loader->request(), info->GetChildID()))); |
| 714 BrowserThread::PostTask( | 719 BrowserThread::PostTask( |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 929 resource_context, | 934 resource_context, |
| 930 referrer)) { | 935 referrer)) { |
| 931 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 936 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); |
| 932 return; | 937 return; |
| 933 } | 938 } |
| 934 | 939 |
| 935 bool is_sync_load = sync_result != NULL; | 940 bool is_sync_load = sync_result != NULL; |
| 936 int load_flags = | 941 int load_flags = |
| 937 BuildLoadFlagsForRequest(request_data, child_id, is_sync_load); | 942 BuildLoadFlagsForRequest(request_data, child_id, is_sync_load); |
| 938 | 943 |
| 944 ProcessRouteIDs id(child_id, route_id); | |
| 945 if (!offline_map_[id]) | |
| 946 offline_map_[id] = new OfflinePolicy(); | |
| 947 load_flags |= offline_map_[id]->GetAdditionalLoadFlags( | |
| 948 load_flags, request_data.resource_type); | |
| 949 | |
| 939 // Construct the request. | 950 // Construct the request. |
| 940 scoped_ptr<net::URLRequest> new_request; | 951 scoped_ptr<net::URLRequest> new_request; |
| 941 net::URLRequest* request; | 952 net::URLRequest* request; |
| 942 if (deferred_loader.get()) { | 953 if (deferred_loader.get()) { |
| 943 request = deferred_loader->request(); | 954 request = deferred_loader->request(); |
| 944 | 955 |
| 945 // Give the ResourceLoader (or any of the ResourceHandlers held by it) a | 956 // Give the ResourceLoader (or any of the ResourceHandlers held by it) a |
| 946 // chance to reset some state before we complete the transfer. | 957 // chance to reset some state before we complete the transfer. |
| 947 deferred_loader->WillCompleteTransfer(); | 958 deferred_loader->WillCompleteTransfer(); |
| 948 } else { | 959 } else { |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1364 for (BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.begin(); | 1375 for (BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.begin(); |
| 1365 iter != blocked_loaders_map_.end(); ++iter) { | 1376 iter != blocked_loaders_map_.end(); ++iter) { |
| 1366 if (iter->first.first == child_id) | 1377 if (iter->first.first == child_id) |
| 1367 route_ids.insert(iter->first.second); | 1378 route_ids.insert(iter->first.second); |
| 1368 } | 1379 } |
| 1369 for (std::set<int>::const_iterator iter = route_ids.begin(); | 1380 for (std::set<int>::const_iterator iter = route_ids.begin(); |
| 1370 iter != route_ids.end(); ++iter) { | 1381 iter != route_ids.end(); ++iter) { |
| 1371 CancelBlockedRequestsForRoute(child_id, *iter); | 1382 CancelBlockedRequestsForRoute(child_id, *iter); |
| 1372 } | 1383 } |
| 1373 } | 1384 } |
| 1385 | |
| 1386 // Cleanup the offline state for the route. | |
| 1387 delete offline_map_[ProcessRouteIDs(child_id, route_id)]; | |
| 1388 offline_map_.erase(ProcessRouteIDs(child_id, route_id)); | |
| 1374 } | 1389 } |
| 1375 | 1390 |
| 1376 // Cancels the request and removes it from the list. | 1391 // Cancels the request and removes it from the list. |
| 1377 void ResourceDispatcherHostImpl::RemovePendingRequest(int child_id, | 1392 void ResourceDispatcherHostImpl::RemovePendingRequest(int child_id, |
| 1378 int request_id) { | 1393 int request_id) { |
| 1379 LoaderMap::iterator i = pending_loaders_.find( | 1394 LoaderMap::iterator i = pending_loaders_.find( |
| 1380 GlobalRequestID(child_id, request_id)); | 1395 GlobalRequestID(child_id, request_id)); |
| 1381 if (i == pending_loaders_.end()) { | 1396 if (i == pending_loaders_.end()) { |
| 1382 NOTREACHED() << "Trying to remove a request that's not here"; | 1397 NOTREACHED() << "Trying to remove a request that's not here"; |
| 1383 return; | 1398 return; |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1756 DelegateMap::iterator it = delegate_map_.find(id); | 1771 DelegateMap::iterator it = delegate_map_.find(id); |
| 1757 DCHECK(it->second->HasObserver(delegate)); | 1772 DCHECK(it->second->HasObserver(delegate)); |
| 1758 it->second->RemoveObserver(delegate); | 1773 it->second->RemoveObserver(delegate); |
| 1759 if (it->second->size() == 0) { | 1774 if (it->second->size() == 0) { |
| 1760 delete it->second; | 1775 delete it->second; |
| 1761 delegate_map_.erase(it); | 1776 delegate_map_.erase(it); |
| 1762 } | 1777 } |
| 1763 } | 1778 } |
| 1764 | 1779 |
| 1765 } // namespace content | 1780 } // namespace content |
| OLD | NEW |