OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "content/browser/renderer_host/resource_queue.h" | 5 #include "content/browser/renderer_host/resource_queue.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
9 #include "content/browser/renderer_host/global_request_id.h" | 9 #include "content/browser/renderer_host/global_request_id.h" |
10 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 10 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 DCHECK(!ContainsKey(interested_delegates_, request_id)); | 69 DCHECK(!ContainsKey(interested_delegates_, request_id)); |
70 interested_delegates_[request_id] = interested_delegates; | 70 interested_delegates_[request_id] = interested_delegates; |
71 } | 71 } |
72 | 72 |
73 void ResourceQueue::RemoveRequest(const GlobalRequestID& request_id) { | 73 void ResourceQueue::RemoveRequest(const GlobalRequestID& request_id) { |
74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 74 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
75 requests_.erase(request_id); | 75 requests_.erase(request_id); |
76 } | 76 } |
77 | 77 |
78 void ResourceQueue::StartDelayedRequest(ResourceQueueDelegate* delegate, | 78 void ResourceQueue::StartDelayedRequests(ResourceQueueDelegate* delegate) { |
79 const GlobalRequestID& request_id) { | |
80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
81 DCHECK(!shutdown_); | 80 DCHECK(!shutdown_); |
82 | 81 |
83 DCHECK(ContainsKey(interested_delegates_, request_id)); | 82 for (RequestMap::iterator i = requests_.begin(); i != requests_.end(); ++i) { |
84 DCHECK(ContainsKey(interested_delegates_[request_id], delegate)); | 83 GlobalRequestID request_id = i->first; |
85 interested_delegates_[request_id].erase(delegate); | 84 // Ignore requests that this delegate never asked to delay. |
86 if (interested_delegates_[request_id].empty()) { | 85 if (!ContainsKey(interested_delegates_, request_id) || |
87 interested_delegates_.erase(request_id); | 86 !ContainsKey(interested_delegates_[request_id], delegate)) { |
| 87 continue; |
| 88 } |
| 89 interested_delegates_[request_id].erase(delegate); |
88 | 90 |
89 if (ContainsKey(requests_, request_id)) { | 91 // If no more delegates want a delay, start the request. |
90 net::URLRequest* request = requests_[request_id]; | 92 if (interested_delegates_[request_id].empty()) { |
| 93 interested_delegates_.erase(request_id); |
| 94 net::URLRequest* request = i->second; |
91 // The request shouldn't have started (SUCCESS is the initial state). | 95 // The request shouldn't have started (SUCCESS is the initial state). |
92 DCHECK_EQ(net::URLRequestStatus::SUCCESS, request->status().status()); | 96 DCHECK_EQ(net::URLRequestStatus::SUCCESS, request->status().status()); |
93 request->Start(); | 97 request->Start(); |
94 } | 98 } |
95 } | 99 } |
96 } | 100 } |
OLD | NEW |