Chromium Code Reviews| Index: content/browser/loader/resource_dispatcher_host_impl.cc |
| diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc |
| index b0045d4b84d13418624d827742a7423f70797805..0228cc3a5739f9c4829f00ca0bc539c00ecd708f 100644 |
| --- a/content/browser/loader/resource_dispatcher_host_impl.cc |
| +++ b/content/browser/loader/resource_dispatcher_host_impl.cc |
| @@ -416,13 +416,13 @@ void ResourceDispatcherHostImpl::CancelRequestsForContext( |
| // the requests to cancel first, and then we start cancelling. We assert at |
| // the end that there are no more to cancel since the context is about to go |
| // away. |
| - typedef std::vector<linked_ptr<ResourceLoader> > LoaderList; |
| + typedef ScopedVector<ResourceLoader> LoaderList; |
| LoaderList loaders_to_cancel; |
| for (LoaderMap::iterator i = pending_loaders_.begin(); |
| i != pending_loaders_.end();) { |
| if (i->second->GetRequestInfo()->GetContext() == context) { |
| - loaders_to_cancel.push_back(i->second); |
| + loaders_to_cancel.push_back(i->second.release()); |
| pending_loaders_.erase(i++); |
| } else { |
| ++i; |
| @@ -443,15 +443,16 @@ void ResourceDispatcherHostImpl::CancelRequestsForContext( |
| blocked_loaders_map_.erase(i++); |
| for (BlockedLoadersList::const_iterator it = loaders->begin(); |
| it != loaders->end(); ++it) { |
| - linked_ptr<ResourceLoader> loader = *it; |
| + scoped_ptr<ResourceLoader> loader(*it); |
| info = loader->GetRequestInfo(); |
| // We make the assumption that all requests on the list have the same |
| // ResourceContext. |
| DCHECK_EQ(context, info->GetContext()); |
| IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), |
| info->GetChildID()); |
| - loaders_to_cancel.push_back(loader); |
| + loaders_to_cancel.push_back(loader.release()); |
| } |
| + loaders->weak_erase(loaders->begin(), loaders->end()); |
|
willchan no longer on Chromium
2012/12/13 06:30:43
Why not weak_clear()?
James Simonsen
2012/12/14 20:23:23
Didn't know about it. Done.
|
| delete loaders; |
| } else { |
| ++i; |
| @@ -874,14 +875,14 @@ void ResourceDispatcherHostImpl::BeginRequest( |
| // If the request that's coming in is being transferred from another process, |
| // we want to reuse and resume the old loader rather than start a new one. |
| - linked_ptr<ResourceLoader> deferred_loader; |
| + scoped_ptr<ResourceLoader> deferred_loader; |
| { |
| LoaderMap::iterator it = pending_loaders_.find( |
| GlobalRequestID(request_data.transferred_request_child_id, |
| request_data.transferred_request_request_id)); |
| if (it != pending_loaders_.end()) { |
| if (it->second->is_transferring()) { |
| - deferred_loader = it->second; |
| + deferred_loader.reset(it->second.release()); |
| pending_loaders_.erase(it); |
| } else { |
| RecordAction(UserMetricsAction("BadMessageTerminate_RDH")); |
| @@ -922,7 +923,7 @@ void ResourceDispatcherHostImpl::BeginRequest( |
| // Construct the request. |
| scoped_ptr<net::URLRequest> new_request; |
| net::URLRequest* request; |
| - if (deferred_loader.get()) { |
| + if (deferred_loader) { |
| request = deferred_loader->request(); |
| // Give the ResourceLoader (or any of the ResourceHandlers held by it) a |
| @@ -1056,9 +1057,11 @@ void ResourceDispatcherHostImpl::BeginRequest( |
| throttles.Pass())); |
| } |
| - if (deferred_loader.get()) { |
| - pending_loaders_[extra_info->GetGlobalRequestID()] = deferred_loader; |
| - deferred_loader->CompleteTransfer(handler.Pass()); |
| + if (deferred_loader) { |
| + pending_loaders_[extra_info->GetGlobalRequestID()] = make_linked_ptr( |
| + deferred_loader.release()); |
| + pending_loaders_[extra_info->GetGlobalRequestID()]->CompleteTransfer( |
| + handler.Pass()); |
| } else { |
| BeginRequestInternal(new_request.Pass(), handler.Pass()); |
| } |
| @@ -1485,26 +1488,27 @@ void ResourceDispatcherHostImpl::BeginRequestInternal( |
| return; |
| } |
| - linked_ptr<ResourceLoader> loader( |
| + scoped_ptr<ResourceLoader> loader( |
| new ResourceLoader(request.Pass(), handler.Pass(), this)); |
| ProcessRouteIDs pair_id(info->GetChildID(), info->GetRouteID()); |
| BlockedLoadersMap::const_iterator iter = blocked_loaders_map_.find(pair_id); |
| if (iter != blocked_loaders_map_.end()) { |
| // The request should be blocked. |
| - iter->second->push_back(loader); |
| + iter->second->push_back(loader.release()); |
| return; |
| } |
| - StartLoading(info, loader); |
| + StartLoading(info, loader.Pass()); |
| } |
| void ResourceDispatcherHostImpl::StartLoading( |
| ResourceRequestInfoImpl* info, |
| - const linked_ptr<ResourceLoader>& loader) { |
| - pending_loaders_[info->GetGlobalRequestID()] = loader; |
| - |
| - loader->StartRequest(); |
| + scoped_ptr<ResourceLoader> loader) { |
| + pending_loaders_[info->GetGlobalRequestID()] = make_linked_ptr( |
| + loader.release()); |
| + pending_loaders_[info->GetGlobalRequestID()]->ScheduleRequest( |
| + &resource_scheduler_); |
| } |
| void ResourceDispatcherHostImpl::OnUserGesture(WebContentsImpl* contents) { |
| @@ -1670,16 +1674,17 @@ void ResourceDispatcherHostImpl::ProcessBlockedRequestsForRoute( |
| for (BlockedLoadersList::iterator loaders_iter = loaders->begin(); |
| loaders_iter != loaders->end(); ++loaders_iter) { |
| - linked_ptr<ResourceLoader> loader = *loaders_iter; |
| + scoped_ptr<ResourceLoader> loader(*loaders_iter); |
| ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
| if (cancel_requests) { |
| IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), |
| info->GetChildID()); |
| } else { |
| - StartLoading(info, loader); |
| + StartLoading(info, loader.Pass()); |
| } |
| } |
| + loaders->weak_erase(loaders->begin(), loaders->end()); |
| delete loaders; |
|
willchan no longer on Chromium
2012/12/13 06:30:43
weak_clear?
James Simonsen
2012/12/14 20:23:23
Done.
|
| } |
| @@ -1721,8 +1726,8 @@ ResourceLoader* ResourceDispatcherHostImpl::GetLoader( |
| return i->second.get(); |
| } |
| -ResourceLoader* ResourceDispatcherHostImpl::GetLoader(int child_id, |
| - int request_id) const { |
| +ResourceLoader* ResourceDispatcherHostImpl::GetLoader( |
| + int child_id, int request_id) const { |
| return GetLoader(GlobalRequestID(child_id, request_id)); |
| } |