Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 // sample values). | 189 // sample values). |
| 190 std::vector<int> GetAllNetErrorCodes() { | 190 std::vector<int> GetAllNetErrorCodes() { |
| 191 std::vector<int> all_error_codes; | 191 std::vector<int> all_error_codes; |
| 192 #define NET_ERROR(label, value) all_error_codes.push_back(-(value)); | 192 #define NET_ERROR(label, value) all_error_codes.push_back(-(value)); |
| 193 #include "net/base/net_error_list.h" | 193 #include "net/base/net_error_list.h" |
| 194 #undef NET_ERROR | 194 #undef NET_ERROR |
| 195 return all_error_codes; | 195 return all_error_codes; |
| 196 } | 196 } |
| 197 | 197 |
| 198 #if defined(OS_WIN) | 198 #if defined(OS_WIN) |
| 199 #pragma warning (disable: 4748) | 199 #pragma warning(disable: 4748) |
| 200 #pragma optimize( "", off ) | 200 #pragma optimize("", off) |
| 201 #endif | 201 #endif |
| 202 | 202 |
| 203 // Temporary experiment to help track down http://crbug.com/68766. | 203 // Temporary experiment to help track down http://crbug.com/68766. |
| 204 // This should crash if called with an invalid ChromeURLRequestContext. | 204 // This should crash if called with an invalid ChromeURLRequestContext. |
| 205 // TODO(eroman): Delete this when experiment is complete. | 205 // TODO(eroman): Delete this when experiment is complete. |
| 206 void CheckContextForBug68766(net::URLRequestContext* context) { | 206 void CheckContextForBug68766(net::URLRequestContext* context) { |
| 207 if (context) | 207 if (context) |
| 208 static_cast<ChromeURLRequestContext*>(context)->IsExternal(); | 208 static_cast<ChromeURLRequestContext*>(context)->IsExternal(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 #if defined(OS_WIN) | 211 #if defined(OS_WIN) |
| 212 #pragma optimize( "", on ) | 212 #pragma optimize("", on) |
| 213 #pragma warning (default: 4748) | 213 #pragma warning(default: 4748) |
| 214 #endif | 214 #endif |
| 215 | 215 |
| 216 } // namespace | 216 } // namespace |
| 217 | 217 |
| 218 ResourceDispatcherHost::ResourceDispatcherHost() | 218 ResourceDispatcherHost::ResourceDispatcherHost() |
| 219 : ALLOW_THIS_IN_INITIALIZER_LIST( | 219 : ALLOW_THIS_IN_INITIALIZER_LIST( |
| 220 download_file_manager_(new DownloadFileManager(this))), | 220 download_file_manager_(new DownloadFileManager(this))), |
| 221 download_request_limiter_(new DownloadRequestLimiter()), | 221 download_request_limiter_(new DownloadRequestLimiter()), |
| 222 ALLOW_THIS_IN_INITIALIZER_LIST( | 222 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 223 save_file_manager_(new SaveFileManager(this))), | 223 save_file_manager_(new SaveFileManager(this))), |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 521 request_data.resource_type, | 521 request_data.resource_type, |
| 522 upload_size, | 522 upload_size, |
| 523 false, // is download | 523 false, // is download |
| 524 ResourceType::IsFrame(request_data.resource_type), // allow_download | 524 ResourceType::IsFrame(request_data.resource_type), // allow_download |
| 525 request_data.has_user_gesture, | 525 request_data.has_user_gesture, |
| 526 request_data.host_renderer_id, | 526 request_data.host_renderer_id, |
| 527 request_data.host_render_view_id); | 527 request_data.host_render_view_id); |
| 528 ApplyExtensionLocalizationFilter(request_data.url, request_data.resource_type, | 528 ApplyExtensionLocalizationFilter(request_data.url, request_data.resource_type, |
| 529 extra_info); | 529 extra_info); |
| 530 SetRequestInfo(request, extra_info); // Request takes ownership. | 530 SetRequestInfo(request, extra_info); // Request takes ownership. |
| 531 | |
| 532 // Determine and store the child ID of the request originator | |
| 533 // If we can't find an originator then we fall back to the ID of the | |
| 534 // render process through which the request was received. | |
|
awong
2011/01/27 21:03:07
drive-by style nit.
Add a newline before the TODO
| |
| 535 // TODO(wez): This lookup is too expensive - need a FromPID()... | |
| 536 int origin_child_id = child_id; | |
| 537 for (BrowserChildProcessHost::Iterator i; !i.Done(); ++i) { | |
|
brettw
2011/01/27 21:23:51
I don't think this approach is a good idea. It's b
| |
| 538 base::ProcessHandle process_handle = (*i)->handle(); | |
| 539 int pid = base::GetProcId(process_handle); | |
| 540 if (pid == request_data.origin_pid) { | |
| 541 origin_child_id = (*i)->id(); | |
| 542 break; | |
| 543 } | |
| 544 } | |
| 531 chrome_browser_net::SetOriginProcessUniqueIDForRequest( | 545 chrome_browser_net::SetOriginProcessUniqueIDForRequest( |
| 532 request_data.origin_child_id, request); | 546 origin_child_id, request); |
| 533 | 547 |
| 534 if (request->url().SchemeIs(chrome::kBlobScheme) && context) { | 548 if (request->url().SchemeIs(chrome::kBlobScheme) && context) { |
| 535 // Hang on to a reference to ensure the blob is not released prior | 549 // Hang on to a reference to ensure the blob is not released prior |
| 536 // to the job being started. | 550 // to the job being started. |
| 537 webkit_blob::BlobStorageController* controller = | 551 webkit_blob::BlobStorageController* controller = |
| 538 context->blob_storage_context()->controller(); | 552 context->blob_storage_context()->controller(); |
| 539 extra_info->set_requested_blob_data( | 553 extra_info->set_requested_blob_data( |
| 540 controller->GetBlobDataFromUrl(request->url())); | 554 controller->GetBlobDataFromUrl(request->url())); |
| 541 } | 555 } |
| 542 | 556 |
| (...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1951 return is_prefetch_enabled_; | 1965 return is_prefetch_enabled_; |
| 1952 } | 1966 } |
| 1953 | 1967 |
| 1954 // static | 1968 // static |
| 1955 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1969 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
| 1956 is_prefetch_enabled_ = value; | 1970 is_prefetch_enabled_ = value; |
| 1957 } | 1971 } |
| 1958 | 1972 |
| 1959 // static | 1973 // static |
| 1960 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1974 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
| OLD | NEW |