| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(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 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 } | 685 } |
| 686 | 686 |
| 687 // We are explicitly forcing the download of 'url'. | 687 // We are explicitly forcing the download of 'url'. |
| 688 void ResourceDispatcherHost::BeginDownload( | 688 void ResourceDispatcherHost::BeginDownload( |
| 689 const GURL& url, | 689 const GURL& url, |
| 690 const GURL& referrer, | 690 const GURL& referrer, |
| 691 const DownloadSaveInfo& save_info, | 691 const DownloadSaveInfo& save_info, |
| 692 bool prompt_for_save_location, | 692 bool prompt_for_save_location, |
| 693 int child_id, | 693 int child_id, |
| 694 int route_id, | 694 int route_id, |
| 695 URLRequestContext* request_context) { | 695 net::URLRequestContext* request_context) { |
| 696 if (is_shutdown_) | 696 if (is_shutdown_) |
| 697 return; | 697 return; |
| 698 | 698 |
| 699 // Check if the renderer is permitted to request the requested URL. | 699 // Check if the renderer is permitted to request the requested URL. |
| 700 if (!ChildProcessSecurityPolicy::GetInstance()-> | 700 if (!ChildProcessSecurityPolicy::GetInstance()-> |
| 701 CanRequestURL(child_id, url)) { | 701 CanRequestURL(child_id, url)) { |
| 702 VLOG(1) << "Denied unauthorized download request for " | 702 VLOG(1) << "Denied unauthorized download request for " |
| 703 << url.possibly_invalid_spec(); | 703 << url.possibly_invalid_spec(); |
| 704 return; | 704 return; |
| 705 } | 705 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 | 742 |
| 743 ResourceDispatcherHostRequestInfo* extra_info = | 743 ResourceDispatcherHostRequestInfo* extra_info = |
| 744 CreateRequestInfoForBrowserRequest(handler, child_id, route_id, true); | 744 CreateRequestInfoForBrowserRequest(handler, child_id, route_id, true); |
| 745 SetRequestInfo(request, extra_info); // Request takes ownership. | 745 SetRequestInfo(request, extra_info); // Request takes ownership. |
| 746 chrome_browser_net::SetOriginProcessUniqueIDForRequest(child_id, request); | 746 chrome_browser_net::SetOriginProcessUniqueIDForRequest(child_id, request); |
| 747 | 747 |
| 748 BeginRequestInternal(request); | 748 BeginRequestInternal(request); |
| 749 } | 749 } |
| 750 | 750 |
| 751 // This function is only used for saving feature. | 751 // This function is only used for saving feature. |
| 752 void ResourceDispatcherHost::BeginSaveFile(const GURL& url, | 752 void ResourceDispatcherHost::BeginSaveFile( |
| 753 const GURL& referrer, | 753 const GURL& url, |
| 754 int child_id, | 754 const GURL& referrer, |
| 755 int route_id, | 755 int child_id, |
| 756 URLRequestContext* request_context) { | 756 int route_id, |
| 757 net::URLRequestContext* request_context) { |
| 757 if (is_shutdown_) | 758 if (is_shutdown_) |
| 758 return; | 759 return; |
| 759 | 760 |
| 760 // Ensure the Chrome plugins are loaded, as they may intercept network | 761 // Ensure the Chrome plugins are loaded, as they may intercept network |
| 761 // requests. Does nothing if they are already loaded. | 762 // requests. Does nothing if they are already loaded. |
| 762 PluginService::GetInstance()->LoadChromePlugins(this); | 763 PluginService::GetInstance()->LoadChromePlugins(this); |
| 763 | 764 |
| 764 scoped_refptr<ResourceHandler> handler( | 765 scoped_refptr<ResourceHandler> handler( |
| 765 new SaveFileResourceHandler(child_id, | 766 new SaveFileResourceHandler(child_id, |
| 766 route_id, | 767 route_id, |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 return is_prefetch_enabled_; | 1947 return is_prefetch_enabled_; |
| 1947 } | 1948 } |
| 1948 | 1949 |
| 1949 // static | 1950 // static |
| 1950 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { | 1951 void ResourceDispatcherHost::set_is_prefetch_enabled(bool value) { |
| 1951 is_prefetch_enabled_ = value; | 1952 is_prefetch_enabled_ = value; |
| 1952 } | 1953 } |
| 1953 | 1954 |
| 1954 // static | 1955 // static |
| 1955 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; | 1956 bool ResourceDispatcherHost::is_prefetch_enabled_ = false; |
| OLD | NEW |