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 <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // Note that the error codes are all positive (since histograms expect positive | 187 // Note that the error codes are all positive (since histograms expect positive |
188 // sample values). | 188 // sample values). |
189 std::vector<int> GetAllNetErrorCodes() { | 189 std::vector<int> GetAllNetErrorCodes() { |
190 std::vector<int> all_error_codes; | 190 std::vector<int> all_error_codes; |
191 #define NET_ERROR(label, value) all_error_codes.push_back(-(value)); | 191 #define NET_ERROR(label, value) all_error_codes.push_back(-(value)); |
192 #include "net/base/net_error_list.h" | 192 #include "net/base/net_error_list.h" |
193 #undef NET_ERROR | 193 #undef NET_ERROR |
194 return all_error_codes; | 194 return all_error_codes; |
195 } | 195 } |
196 | 196 |
| 197 #if defined(OS_WIN) |
| 198 #pragma warning (disable: 4748) |
| 199 #pragma optimize( "", off ) |
| 200 #endif |
| 201 |
| 202 // Temporary experiment to help track down http://crbug.com/68766. |
| 203 // This should crash if called with an invalid ChromeURLRequestContext. |
| 204 // TODO(eroman): Delete this when experiment is complete. |
| 205 void CheckContextForBug68766(URLRequestContext* context) { |
| 206 if (context) |
| 207 static_cast<ChromeURLRequestContext*>(context)->IsExternal(); |
| 208 } |
| 209 |
| 210 #if defined(OS_WIN) |
| 211 #pragma optimize( "", on ) |
| 212 #pragma warning (default: 4748) |
| 213 #endif |
| 214 |
197 } // namespace | 215 } // namespace |
198 | 216 |
199 ResourceDispatcherHost::ResourceDispatcherHost() | 217 ResourceDispatcherHost::ResourceDispatcherHost() |
200 : ALLOW_THIS_IN_INITIALIZER_LIST( | 218 : ALLOW_THIS_IN_INITIALIZER_LIST( |
201 download_file_manager_(new DownloadFileManager(this))), | 219 download_file_manager_(new DownloadFileManager(this))), |
202 download_request_limiter_(new DownloadRequestLimiter()), | 220 download_request_limiter_(new DownloadRequestLimiter()), |
203 ALLOW_THIS_IN_INITIALIZER_LIST( | 221 ALLOW_THIS_IN_INITIALIZER_LIST( |
204 save_file_manager_(new SaveFileManager(this))), | 222 save_file_manager_(new SaveFileManager(this))), |
205 user_script_listener_(new UserScriptListener(&resource_queue_)), | 223 user_script_listener_(new UserScriptListener(&resource_queue_)), |
206 safe_browsing_(SafeBrowsingService::CreateSafeBrowsingService()), | 224 safe_browsing_(SafeBrowsingService::CreateSafeBrowsingService()), |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 int request_id, | 360 int request_id, |
343 const ViewHostMsg_Resource_Request& request_data, | 361 const ViewHostMsg_Resource_Request& request_data, |
344 IPC::Message* sync_result, // only valid for sync | 362 IPC::Message* sync_result, // only valid for sync |
345 int route_id) { | 363 int route_id) { |
346 ChildProcessInfo::ProcessType process_type = filter_->process_type(); | 364 ChildProcessInfo::ProcessType process_type = filter_->process_type(); |
347 int child_id = filter_->child_id(); | 365 int child_id = filter_->child_id(); |
348 | 366 |
349 ChromeURLRequestContext* context = filter_->GetURLRequestContext( | 367 ChromeURLRequestContext* context = filter_->GetURLRequestContext( |
350 request_id, request_data.resource_type); | 368 request_id, request_data.resource_type); |
351 | 369 |
| 370 CheckContextForBug68766(context); |
| 371 |
352 // Might need to resolve the blob references in the upload data. | 372 // Might need to resolve the blob references in the upload data. |
353 if (request_data.upload_data && context) { | 373 if (request_data.upload_data && context) { |
354 context->blob_storage_context()->controller()-> | 374 context->blob_storage_context()->controller()-> |
355 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); | 375 ResolveBlobReferencesInUploadData(request_data.upload_data.get()); |
356 } | 376 } |
357 | 377 |
358 if (is_shutdown_ || | 378 if (is_shutdown_ || |
359 !ShouldServiceRequest(process_type, child_id, request_data)) { | 379 !ShouldServiceRequest(process_type, child_id, request_data)) { |
360 URLRequestStatus status(URLRequestStatus::FAILED, net::ERR_ABORTED); | 380 URLRequestStatus status(URLRequestStatus::FAILED, net::ERR_ABORTED); |
361 if (sync_result) { | 381 if (sync_result) { |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 // (3) If |defer_start| is not set, then the request is inserted into | 1314 // (3) If |defer_start| is not set, then the request is inserted into |
1295 // the resource_queue_ (which may pause it further, or start it). | 1315 // the resource_queue_ (which may pause it further, or start it). |
1296 bool defer_start = false; | 1316 bool defer_start = false; |
1297 if (!info->resource_handler()->OnWillStart( | 1317 if (!info->resource_handler()->OnWillStart( |
1298 info->request_id(), request->url(), | 1318 info->request_id(), request->url(), |
1299 &defer_start)) { | 1319 &defer_start)) { |
1300 CancelRequestInternal(request, false); | 1320 CancelRequestInternal(request, false); |
1301 return; | 1321 return; |
1302 } | 1322 } |
1303 | 1323 |
1304 if (!defer_start) | 1324 if (!defer_start) { |
| 1325 CheckContextForBug68766(request->context()); |
1305 InsertIntoResourceQueue(request, *info); | 1326 InsertIntoResourceQueue(request, *info); |
| 1327 } |
1306 } | 1328 } |
1307 | 1329 |
1308 void ResourceDispatcherHost::InsertIntoResourceQueue( | 1330 void ResourceDispatcherHost::InsertIntoResourceQueue( |
1309 net::URLRequest* request, | 1331 net::URLRequest* request, |
1310 const ResourceDispatcherHostRequestInfo& request_info) { | 1332 const ResourceDispatcherHostRequestInfo& request_info) { |
1311 resource_queue_.AddRequest(request, request_info); | 1333 resource_queue_.AddRequest(request, request_info); |
1312 | 1334 |
1313 // Make sure we have the load state monitor running | 1335 // Make sure we have the load state monitor running |
1314 if (!update_load_states_timer_.IsRunning()) { | 1336 if (!update_load_states_timer_.IsRunning()) { |
1315 update_load_states_timer_.Start( | 1337 update_load_states_timer_.Start( |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1913 return is_prefetch_enabled_; | 1935 return is_prefetch_enabled_; |
1914 } | 1936 } |
1915 | 1937 |
1916 // static | 1938 // static |
1917 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1939 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
1918 is_prefetch_enabled_ = value; | 1940 is_prefetch_enabled_ = value; |
1919 } | 1941 } |
1920 | 1942 |
1921 // static | 1943 // static |
1922 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1944 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
OLD | NEW |