| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "chrome/browser/renderer_host/global_request_id.h" | 38 #include "chrome/browser/renderer_host/global_request_id.h" |
| 39 #include "chrome/browser/renderer_host/redirect_to_file_resource_handler.h" | 39 #include "chrome/browser/renderer_host/redirect_to_file_resource_handler.h" |
| 40 #include "chrome/browser/renderer_host/render_view_host.h" | 40 #include "chrome/browser/renderer_host/render_view_host.h" |
| 41 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 41 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 42 #include "chrome/browser/renderer_host/render_view_host_notification_task.h" | 42 #include "chrome/browser/renderer_host/render_view_host_notification_task.h" |
| 43 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" | 43 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 44 #include "chrome/browser/renderer_host/resource_queue.h" | 44 #include "chrome/browser/renderer_host/resource_queue.h" |
| 45 #include "chrome/browser/renderer_host/resource_request_details.h" | 45 #include "chrome/browser/renderer_host/resource_request_details.h" |
| 46 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h" | 46 #include "chrome/browser/renderer_host/safe_browsing_resource_handler.h" |
| 47 #include "chrome/browser/renderer_host/save_file_resource_handler.h" | 47 #include "chrome/browser/renderer_host/save_file_resource_handler.h" |
| 48 #include "chrome/browser/renderer_host/socket_stream_dispatcher_host.h" | |
| 49 #include "chrome/browser/renderer_host/sync_resource_handler.h" | 48 #include "chrome/browser/renderer_host/sync_resource_handler.h" |
| 50 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 49 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 51 #include "chrome/browser/ssl/ssl_client_auth_handler.h" | 50 #include "chrome/browser/ssl/ssl_client_auth_handler.h" |
| 52 #include "chrome/browser/ssl/ssl_manager.h" | 51 #include "chrome/browser/ssl/ssl_manager.h" |
| 53 #include "chrome/browser/ui/login/login_prompt.h" | 52 #include "chrome/browser/ui/login/login_prompt.h" |
| 54 #include "chrome/browser/worker_host/worker_service.h" | 53 #include "chrome/browser/worker_host/worker_service.h" |
| 55 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
| 56 #include "chrome/common/notification_service.h" | 55 #include "chrome/common/notification_service.h" |
| 57 #include "chrome/common/render_messages.h" | 56 #include "chrome/common/render_messages.h" |
| 58 #include "chrome/common/render_messages_params.h" | 57 #include "chrome/common/render_messages_params.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 203 } |
| 205 | 204 |
| 206 ResourceDispatcherHost::ResourceDispatcherHost() | 205 ResourceDispatcherHost::ResourceDispatcherHost() |
| 207 : ALLOW_THIS_IN_INITIALIZER_LIST( | 206 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 208 download_file_manager_(new DownloadFileManager(this))), | 207 download_file_manager_(new DownloadFileManager(this))), |
| 209 download_request_limiter_(new DownloadRequestLimiter()), | 208 download_request_limiter_(new DownloadRequestLimiter()), |
| 210 ALLOW_THIS_IN_INITIALIZER_LIST( | 209 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 211 save_file_manager_(new SaveFileManager(this))), | 210 save_file_manager_(new SaveFileManager(this))), |
| 212 user_script_listener_(new UserScriptListener(&resource_queue_)), | 211 user_script_listener_(new UserScriptListener(&resource_queue_)), |
| 213 safe_browsing_(SafeBrowsingService::CreateSafeBrowsingService()), | 212 safe_browsing_(SafeBrowsingService::CreateSafeBrowsingService()), |
| 214 socket_stream_dispatcher_host_(new SocketStreamDispatcherHost), | |
| 215 webkit_thread_(new WebKitThread), | 213 webkit_thread_(new WebKitThread), |
| 216 request_id_(-1), | 214 request_id_(-1), |
| 217 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), | 215 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), |
| 218 is_shutdown_(false), | 216 is_shutdown_(false), |
| 219 max_outstanding_requests_cost_per_process_( | 217 max_outstanding_requests_cost_per_process_( |
| 220 kMaxOutstandingRequestsCostPerProcess), | 218 kMaxOutstandingRequestsCostPerProcess), |
| 221 receiver_(NULL) { | 219 receiver_(NULL) { |
| 222 ResourceQueue::DelegateSet resource_queue_delegates; | 220 ResourceQueue::DelegateSet resource_queue_delegates; |
| 223 resource_queue_delegates.insert(user_script_listener_.get()); | 221 resource_queue_delegates.insert(user_script_listener_.get()); |
| 224 resource_queue_.Initialize(resource_queue_delegates); | 222 resource_queue_.Initialize(resource_queue_delegates); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 URLRequestStatus::FAILED, | 295 URLRequestStatus::FAILED, |
| 298 net::ERR_ABORTED), | 296 net::ERR_ABORTED), |
| 299 std::string()); // No security info necessary. | 297 std::string()); // No security info necessary. |
| 300 return true; | 298 return true; |
| 301 } | 299 } |
| 302 | 300 |
| 303 bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message, | 301 bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message, |
| 304 Receiver* receiver, | 302 Receiver* receiver, |
| 305 bool* message_was_ok) { | 303 bool* message_was_ok) { |
| 306 if (!IsResourceDispatcherHostMessage(message)) { | 304 if (!IsResourceDispatcherHostMessage(message)) { |
| 307 return socket_stream_dispatcher_host_->OnMessageReceived( | 305 return false; |
| 308 message, receiver, message_was_ok); | |
| 309 } | 306 } |
| 310 | 307 |
| 311 *message_was_ok = true; | 308 *message_was_ok = true; |
| 312 receiver_ = receiver; | 309 receiver_ = receiver; |
| 313 | 310 |
| 314 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) | 311 IPC_BEGIN_MESSAGE_MAP_EX(ResourceDispatcherHost, message, *message_was_ok) |
| 315 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestResource, OnRequestResource) | 312 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestResource, OnRequestResource) |
| 316 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncLoad, OnSyncLoad) | 313 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SyncLoad, OnSyncLoad) |
| 317 IPC_MESSAGE_HANDLER(ViewHostMsg_ReleaseDownloadedFile, | 314 IPC_MESSAGE_HANDLER(ViewHostMsg_ReleaseDownloadedFile, |
| 318 OnReleaseDownloadedFile) | 315 OnReleaseDownloadedFile) |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 OutstandingRequestsMemoryCostMap::const_iterator entry = | 886 OutstandingRequestsMemoryCostMap::const_iterator entry = |
| 890 outstanding_requests_memory_cost_map_.find(child_id); | 887 outstanding_requests_memory_cost_map_.find(child_id); |
| 891 return (entry == outstanding_requests_memory_cost_map_.end()) ? | 888 return (entry == outstanding_requests_memory_cost_map_.end()) ? |
| 892 0 : entry->second; | 889 0 : entry->second; |
| 893 } | 890 } |
| 894 | 891 |
| 895 // The object died, so cancel and detach all requests associated with it except | 892 // The object died, so cancel and detach all requests associated with it except |
| 896 // for downloads, which belong to the browser process even if initiated via a | 893 // for downloads, which belong to the browser process even if initiated via a |
| 897 // renderer. | 894 // renderer. |
| 898 void ResourceDispatcherHost::CancelRequestsForProcess(int child_id) { | 895 void ResourceDispatcherHost::CancelRequestsForProcess(int child_id) { |
| 899 socket_stream_dispatcher_host_->CancelRequestsForProcess(child_id); | |
| 900 CancelRequestsForRoute(child_id, -1 /* cancel all */); | 896 CancelRequestsForRoute(child_id, -1 /* cancel all */); |
| 901 registered_temp_files_.erase(child_id); | 897 registered_temp_files_.erase(child_id); |
| 902 } | 898 } |
| 903 | 899 |
| 904 void ResourceDispatcherHost::CancelRequestsForRoute(int child_id, | 900 void ResourceDispatcherHost::CancelRequestsForRoute(int child_id, |
| 905 int route_id) { | 901 int route_id) { |
| 906 // Since pending_requests_ is a map, we first build up a list of all of the | 902 // Since pending_requests_ is a map, we first build up a list of all of the |
| 907 // matching requests to be cancelled, and then we cancel them. Since there | 903 // matching requests to be cancelled, and then we cancel them. Since there |
| 908 // may be more than one request to cancel, we cannot simply hold onto the map | 904 // may be more than one request to cancel, we cannot simply hold onto the map |
| 909 // iterators found in the first loop. | 905 // iterators found in the first loop. |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1961 return is_prefetch_enabled_; | 1957 return is_prefetch_enabled_; |
| 1962 } | 1958 } |
| 1963 | 1959 |
| 1964 // static | 1960 // static |
| 1965 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1961 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
| 1966 is_prefetch_enabled_ = value; | 1962 is_prefetch_enabled_ = value; |
| 1967 } | 1963 } |
| 1968 | 1964 |
| 1969 // static | 1965 // static |
| 1970 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1966 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
| OLD | NEW |