OLD | NEW |
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" | |
25 #include "chrome/browser/external_protocol_handler.h" | 24 #include "chrome/browser/external_protocol_handler.h" |
26 #include "chrome/browser/in_process_webkit/webkit_thread.h" | 25 #include "chrome/browser/in_process_webkit/webkit_thread.h" |
27 #include "chrome/browser/login_prompt.h" | 26 #include "chrome/browser/login_prompt.h" |
28 #include "chrome/browser/net/chrome_url_request_context.h" | 27 #include "chrome/browser/net/chrome_url_request_context.h" |
29 #include "chrome/browser/plugin_service.h" | 28 #include "chrome/browser/plugin_service.h" |
30 #include "chrome/browser/privacy_blacklist/blacklist.h" | 29 #include "chrome/browser/privacy_blacklist/blacklist.h" |
31 #include "chrome/browser/privacy_blacklist/blocked_response.h" | 30 #include "chrome/browser/privacy_blacklist/blocked_response.h" |
32 #include "chrome/browser/profile.h" | 31 #include "chrome/browser/profile.h" |
33 #include "chrome/browser/renderer_host/async_resource_handler.h" | 32 #include "chrome/browser/renderer_host/async_resource_handler.h" |
34 #include "chrome/browser/renderer_host/buffered_resource_handler.h" | 33 #include "chrome/browser/renderer_host/buffered_resource_handler.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 } // namespace | 245 } // namespace |
247 | 246 |
248 ResourceDispatcherHost::ResourceDispatcherHost(MessageLoop* io_loop) | 247 ResourceDispatcherHost::ResourceDispatcherHost(MessageLoop* io_loop) |
249 : ui_loop_(MessageLoop::current()), | 248 : ui_loop_(MessageLoop::current()), |
250 io_loop_(io_loop), | 249 io_loop_(io_loop), |
251 ALLOW_THIS_IN_INITIALIZER_LIST( | 250 ALLOW_THIS_IN_INITIALIZER_LIST( |
252 download_file_manager_(new DownloadFileManager(ui_loop_, this))), | 251 download_file_manager_(new DownloadFileManager(ui_loop_, this))), |
253 download_request_manager_(new DownloadRequestManager(io_loop, ui_loop_)), | 252 download_request_manager_(new DownloadRequestManager(io_loop, ui_loop_)), |
254 ALLOW_THIS_IN_INITIALIZER_LIST( | 253 ALLOW_THIS_IN_INITIALIZER_LIST( |
255 save_file_manager_(new SaveFileManager(ui_loop_, io_loop, this))), | 254 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))), | |
258 safe_browsing_(new SafeBrowsingService), | 255 safe_browsing_(new SafeBrowsingService), |
259 webkit_thread_(new WebKitThread), | 256 webkit_thread_(new WebKitThread), |
260 request_id_(-1), | 257 request_id_(-1), |
261 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), | 258 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), |
262 is_shutdown_(false), | 259 is_shutdown_(false), |
263 max_outstanding_requests_cost_per_process_( | 260 max_outstanding_requests_cost_per_process_( |
264 kMaxOutstandingRequestsCostPerProcess), | 261 kMaxOutstandingRequestsCostPerProcess), |
265 receiver_(NULL) { | 262 receiver_(NULL) { |
266 } | 263 } |
267 | 264 |
(...skipping 10 matching lines...) Expand all Loading... |
278 iter != blocked_requests_map_.end(); ++iter) { | 275 iter != blocked_requests_map_.end(); ++iter) { |
279 std::pair<std::set<ProcessRouteIDs>::iterator, bool> result = | 276 std::pair<std::set<ProcessRouteIDs>::iterator, bool> result = |
280 ids.insert(iter->first); | 277 ids.insert(iter->first); |
281 // We should not have duplicates. | 278 // We should not have duplicates. |
282 DCHECK(result.second); | 279 DCHECK(result.second); |
283 } | 280 } |
284 for (std::set<ProcessRouteIDs>::const_iterator iter = ids.begin(); | 281 for (std::set<ProcessRouteIDs>::const_iterator iter = ids.begin(); |
285 iter != ids.end(); ++iter) { | 282 iter != ids.end(); ++iter) { |
286 CancelBlockedRequestsForRoute(iter->first, iter->second); | 283 CancelBlockedRequestsForRoute(iter->first, iter->second); |
287 } | 284 } |
288 | |
289 user_script_listener_->OnResourceDispatcherHostGone(); | |
290 } | 285 } |
291 | 286 |
292 void ResourceDispatcherHost::Initialize() { | 287 void ResourceDispatcherHost::Initialize() { |
293 DCHECK(MessageLoop::current() == ui_loop_); | 288 DCHECK(MessageLoop::current() == ui_loop_); |
294 download_file_manager_->Initialize(); | 289 download_file_manager_->Initialize(); |
295 safe_browsing_->Initialize(io_loop_); | 290 safe_browsing_->Initialize(io_loop_); |
296 } | 291 } |
297 | 292 |
298 void ResourceDispatcherHost::Shutdown() { | 293 void ResourceDispatcherHost::Shutdown() { |
299 DCHECK(MessageLoop::current() == ui_loop_); | 294 DCHECK(MessageLoop::current() == ui_loop_); |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 } | 1240 } |
1246 | 1241 |
1247 GlobalRequestID global_id(info->process_id, info->request_id); | 1242 GlobalRequestID global_id(info->process_id, info->request_id); |
1248 pending_requests_[global_id] = request; | 1243 pending_requests_[global_id] = request; |
1249 if (!SSLManager::ShouldStartRequest(this, request, ui_loop_)) { | 1244 if (!SSLManager::ShouldStartRequest(this, request, ui_loop_)) { |
1250 // The SSLManager has told us that we shouldn't start the request yet. The | 1245 // The SSLManager has told us that we shouldn't start the request yet. The |
1251 // SSLManager will potentially change the request (potentially to indicate | 1246 // SSLManager will potentially change the request (potentially to indicate |
1252 // its content should be filtered) and start it itself. | 1247 // its content should be filtered) and start it itself. |
1253 return; | 1248 return; |
1254 } | 1249 } |
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 } | |
1260 request->Start(); | 1250 request->Start(); |
1261 | 1251 |
1262 // Make sure we have the load state monitor running | 1252 // Make sure we have the load state monitor running |
1263 if (!update_load_states_timer_.IsRunning()) { | 1253 if (!update_load_states_timer_.IsRunning()) { |
1264 update_load_states_timer_.Start( | 1254 update_load_states_timer_.Start( |
1265 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), | 1255 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), |
1266 this, &ResourceDispatcherHost::UpdateLoadStates); | 1256 this, &ResourceDispatcherHost::UpdateLoadStates); |
1267 } | 1257 } |
1268 } | 1258 } |
1269 | 1259 |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 case ViewHostMsg_UploadProgress_ACK::ID: | 1708 case ViewHostMsg_UploadProgress_ACK::ID: |
1719 case ViewHostMsg_SyncLoad::ID: | 1709 case ViewHostMsg_SyncLoad::ID: |
1720 return true; | 1710 return true; |
1721 | 1711 |
1722 default: | 1712 default: |
1723 break; | 1713 break; |
1724 } | 1714 } |
1725 | 1715 |
1726 return false; | 1716 return false; |
1727 } | 1717 } |
OLD | NEW |