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

Side by Side Diff: chrome/browser/renderer_host/resource_dispatcher_host.cc

Issue 173482: Re-try r24372 - Delay request loading until all user scripts that request (Closed)
Patch Set: Created 11 years, 4 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
« no previous file with comments | « chrome/browser/renderer_host/resource_dispatcher_host.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/resource_dispatcher_host.h" 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
14 #include "base/shared_memory.h" 14 #include "base/shared_memory.h"
15 #include "base/stl_util-inl.h" 15 #include "base/stl_util-inl.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "chrome/browser/cert_store.h" 17 #include "chrome/browser/cert_store.h"
18 #include "chrome/browser/child_process_security_policy.h" 18 #include "chrome/browser/child_process_security_policy.h"
19 #include "chrome/browser/cross_site_request_manager.h" 19 #include "chrome/browser/cross_site_request_manager.h"
20 #include "chrome/browser/download/download_file.h" 20 #include "chrome/browser/download/download_file.h"
21 #include "chrome/browser/download/download_manager.h" 21 #include "chrome/browser/download/download_manager.h"
22 #include "chrome/browser/download/download_request_manager.h" 22 #include "chrome/browser/download/download_request_manager.h"
23 #include "chrome/browser/download/save_file_manager.h" 23 #include "chrome/browser/download/save_file_manager.h"
24 #include "chrome/browser/extensions/user_script_listener.h"
24 #include "chrome/browser/external_protocol_handler.h" 25 #include "chrome/browser/external_protocol_handler.h"
25 #include "chrome/browser/in_process_webkit/webkit_thread.h" 26 #include "chrome/browser/in_process_webkit/webkit_thread.h"
26 #include "chrome/browser/login_prompt.h" 27 #include "chrome/browser/login_prompt.h"
27 #include "chrome/browser/net/chrome_url_request_context.h" 28 #include "chrome/browser/net/chrome_url_request_context.h"
28 #include "chrome/browser/plugin_service.h" 29 #include "chrome/browser/plugin_service.h"
29 #include "chrome/browser/privacy_blacklist/blacklist.h" 30 #include "chrome/browser/privacy_blacklist/blacklist.h"
30 #include "chrome/browser/privacy_blacklist/blocked_response.h" 31 #include "chrome/browser/privacy_blacklist/blocked_response.h"
31 #include "chrome/browser/profile.h" 32 #include "chrome/browser/profile.h"
32 #include "chrome/browser/renderer_host/async_resource_handler.h" 33 #include "chrome/browser/renderer_host/async_resource_handler.h"
33 #include "chrome/browser/renderer_host/buffered_resource_handler.h" 34 #include "chrome/browser/renderer_host/buffered_resource_handler.h"
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } // namespace 246 } // namespace
246 247
247 ResourceDispatcherHost::ResourceDispatcherHost(MessageLoop* io_loop) 248 ResourceDispatcherHost::ResourceDispatcherHost(MessageLoop* io_loop)
248 : ui_loop_(MessageLoop::current()), 249 : ui_loop_(MessageLoop::current()),
249 io_loop_(io_loop), 250 io_loop_(io_loop),
250 ALLOW_THIS_IN_INITIALIZER_LIST( 251 ALLOW_THIS_IN_INITIALIZER_LIST(
251 download_file_manager_(new DownloadFileManager(ui_loop_, this))), 252 download_file_manager_(new DownloadFileManager(ui_loop_, this))),
252 download_request_manager_(new DownloadRequestManager(io_loop, ui_loop_)), 253 download_request_manager_(new DownloadRequestManager(io_loop, ui_loop_)),
253 ALLOW_THIS_IN_INITIALIZER_LIST( 254 ALLOW_THIS_IN_INITIALIZER_LIST(
254 save_file_manager_(new SaveFileManager(ui_loop_, io_loop, this))), 255 save_file_manager_(new SaveFileManager(ui_loop_, io_loop, this))),
256 ALLOW_THIS_IN_INITIALIZER_LIST(user_script_listener_(
257 new UserScriptListener(ui_loop_, io_loop, this))),
255 safe_browsing_(new SafeBrowsingService), 258 safe_browsing_(new SafeBrowsingService),
256 webkit_thread_(new WebKitThread), 259 webkit_thread_(new WebKitThread),
257 request_id_(-1), 260 request_id_(-1),
258 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), 261 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)),
259 is_shutdown_(false), 262 is_shutdown_(false),
260 max_outstanding_requests_cost_per_process_( 263 max_outstanding_requests_cost_per_process_(
261 kMaxOutstandingRequestsCostPerProcess), 264 kMaxOutstandingRequestsCostPerProcess),
262 receiver_(NULL) { 265 receiver_(NULL) {
263 } 266 }
264 267
(...skipping 10 matching lines...) Expand all
275 iter != blocked_requests_map_.end(); ++iter) { 278 iter != blocked_requests_map_.end(); ++iter) {
276 std::pair<std::set<ProcessRouteIDs>::iterator, bool> result = 279 std::pair<std::set<ProcessRouteIDs>::iterator, bool> result =
277 ids.insert(iter->first); 280 ids.insert(iter->first);
278 // We should not have duplicates. 281 // We should not have duplicates.
279 DCHECK(result.second); 282 DCHECK(result.second);
280 } 283 }
281 for (std::set<ProcessRouteIDs>::const_iterator iter = ids.begin(); 284 for (std::set<ProcessRouteIDs>::const_iterator iter = ids.begin();
282 iter != ids.end(); ++iter) { 285 iter != ids.end(); ++iter) {
283 CancelBlockedRequestsForRoute(iter->first, iter->second); 286 CancelBlockedRequestsForRoute(iter->first, iter->second);
284 } 287 }
288
289 user_script_listener_->OnResourceDispatcherHostGone();
285 } 290 }
286 291
287 void ResourceDispatcherHost::Initialize() { 292 void ResourceDispatcherHost::Initialize() {
288 DCHECK(MessageLoop::current() == ui_loop_); 293 DCHECK(MessageLoop::current() == ui_loop_);
289 download_file_manager_->Initialize(); 294 download_file_manager_->Initialize();
290 safe_browsing_->Initialize(io_loop_); 295 safe_browsing_->Initialize(io_loop_);
291 } 296 }
292 297
293 void ResourceDispatcherHost::Shutdown() { 298 void ResourceDispatcherHost::Shutdown() {
294 DCHECK(MessageLoop::current() == ui_loop_); 299 DCHECK(MessageLoop::current() == ui_loop_);
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 } 1245 }
1241 1246
1242 GlobalRequestID global_id(info->process_id, info->request_id); 1247 GlobalRequestID global_id(info->process_id, info->request_id);
1243 pending_requests_[global_id] = request; 1248 pending_requests_[global_id] = request;
1244 if (!SSLManager::ShouldStartRequest(this, request, ui_loop_)) { 1249 if (!SSLManager::ShouldStartRequest(this, request, ui_loop_)) {
1245 // The SSLManager has told us that we shouldn't start the request yet. The 1250 // The SSLManager has told us that we shouldn't start the request yet. The
1246 // SSLManager will potentially change the request (potentially to indicate 1251 // SSLManager will potentially change the request (potentially to indicate
1247 // its content should be filtered) and start it itself. 1252 // its content should be filtered) and start it itself.
1248 return; 1253 return;
1249 } 1254 }
1255 if (!user_script_listener_->ShouldStartRequest(request)) {
1256 // This request depends on some user scripts that haven't loaded yet. The
1257 // UserScriptListener will resume the request when they're ready.
1258 return;
1259 }
1250 request->Start(); 1260 request->Start();
1251 1261
1252 // Make sure we have the load state monitor running 1262 // Make sure we have the load state monitor running
1253 if (!update_load_states_timer_.IsRunning()) { 1263 if (!update_load_states_timer_.IsRunning()) {
1254 update_load_states_timer_.Start( 1264 update_load_states_timer_.Start(
1255 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), 1265 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec),
1256 this, &ResourceDispatcherHost::UpdateLoadStates); 1266 this, &ResourceDispatcherHost::UpdateLoadStates);
1257 } 1267 }
1258 } 1268 }
1259 1269
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 case ViewHostMsg_UploadProgress_ACK::ID: 1718 case ViewHostMsg_UploadProgress_ACK::ID:
1709 case ViewHostMsg_SyncLoad::ID: 1719 case ViewHostMsg_SyncLoad::ID:
1710 return true; 1720 return true;
1711 1721
1712 default: 1722 default:
1713 break; 1723 break;
1714 } 1724 }
1715 1725
1716 return false; 1726 return false;
1717 } 1727 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/resource_dispatcher_host.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698