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

Side by Side Diff: content/browser/renderer_host/resource_queue.cc

Issue 8296017: Revert 105659 - Delay network requests on startup if any webRequest or webNavigation extensions a... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
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
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::StartDelayedRequests(ResourceQueueDelegate* delegate) { 78 void ResourceQueue::StartDelayedRequest(ResourceQueueDelegate* delegate,
79 const GlobalRequestID& request_id) {
79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 80 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
80 DCHECK(!shutdown_); 81 DCHECK(!shutdown_);
81 82
82 for (RequestMap::iterator i = requests_.begin(); i != requests_.end(); ++i) { 83 DCHECK(ContainsKey(interested_delegates_, request_id));
83 GlobalRequestID request_id = i->first; 84 DCHECK(ContainsKey(interested_delegates_[request_id], delegate));
84 // Ignore requests that this delegate never asked to delay. 85 interested_delegates_[request_id].erase(delegate);
85 if (!ContainsKey(interested_delegates_, request_id) || 86 if (interested_delegates_[request_id].empty()) {
86 !ContainsKey(interested_delegates_[request_id], delegate)) { 87 interested_delegates_.erase(request_id);
87 continue;
88 }
89 interested_delegates_[request_id].erase(delegate);
90 88
91 // If no more delegates want a delay, start the request. 89 if (ContainsKey(requests_, request_id)) {
92 if (interested_delegates_[request_id].empty()) { 90 net::URLRequest* request = requests_[request_id];
93 interested_delegates_.erase(request_id);
94 net::URLRequest* request = i->second;
95 // The request shouldn't have started (SUCCESS is the initial state). 91 // The request shouldn't have started (SUCCESS is the initial state).
96 DCHECK_EQ(net::URLRequestStatus::SUCCESS, request->status().status()); 92 DCHECK_EQ(net::URLRequestStatus::SUCCESS, request->status().status());
97 request->Start(); 93 request->Start();
98 } 94 }
99 } 95 }
100 } 96 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/resource_queue.h ('k') | content/browser/renderer_host/resource_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698