diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 05:24:21 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 05:24:21 +0000 |
commit | c2c901bf406a50085002f8f1d6d63288d6e28c05 (patch) | |
tree | 7eb876216d6c541404fb73c3eaa32f387c8b9e6b /chrome/browser/renderer_host/resource_dispatcher_host.cc | |
parent | 684970b638fbfe1a2137fd162f630c86d2859828 (diff) | |
download | chromium_src-c2c901bf406a50085002f8f1d6d63288d6e28c05.zip chromium_src-c2c901bf406a50085002f8f1d6d63288d6e28c05.tar.gz chromium_src-c2c901bf406a50085002f8f1d6d63288d6e28c05.tar.bz2 |
Ensure we don't load plugins on the IO thread.
I had to move the locks from PluginService to PluginList, so that a lock (which can block other threads) isn't held while loading the plugins.
BUG=17938
TEST=added asserts which crash if plugins loaded on IO thread, current UI tests exercise them
Review URL: http://codereview.chromium.org/164305
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/resource_dispatcher_host.cc')
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.cc | 54 |
1 files changed, 3 insertions, 51 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index b71f64f..9b32684 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -254,7 +254,6 @@ ResourceDispatcherHost::ResourceDispatcherHost(MessageLoop* io_loop) safe_browsing_(new SafeBrowsingService), webkit_thread_(new WebKitThread), request_id_(-1), - plugin_service_(PluginService::GetInstance()), ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), is_shutdown_(false), max_outstanding_requests_cost_per_process_( @@ -466,7 +465,7 @@ void ResourceDispatcherHost::BeginRequest( // requests. Does nothing if they are already loaded. // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by // starting the load earlier in a BG thread. - plugin_service_->LoadChromePlugins(this); + PluginService::GetInstance()->LoadChromePlugins(this); // Construct the event handler. scoped_refptr<ResourceHandler> handler; @@ -666,7 +665,7 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url, // Ensure the Chrome plugins are loaded, as they may intercept network // requests. Does nothing if they are already loaded. - plugin_service_->LoadChromePlugins(this); + PluginService::GetInstance()->LoadChromePlugins(this); URLRequest* request = new URLRequest(url, this); request_id_--; @@ -732,7 +731,7 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url, // Ensure the Chrome plugins are loaded, as they may intercept network // requests. Does nothing if they are already loaded. - plugin_service_->LoadChromePlugins(this); + PluginService::GetInstance()->LoadChromePlugins(this); scoped_refptr<ResourceHandler> handler = new SaveFileResourceHandler(process_id, @@ -1258,53 +1257,6 @@ void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request) { } } -// This test mirrors the decision that WebKit makes in -// WebFrameLoaderClient::dispatchDecidePolicyForMIMEType. -// static. -bool ResourceDispatcherHost::ShouldDownload( - const std::string& mime_type, const std::string& content_disposition) { - std::string type = StringToLowerASCII(mime_type); - std::string disposition = StringToLowerASCII(content_disposition); - - // First, examine content-disposition. - if (!disposition.empty()) { - bool should_download = true; - - // Some broken sites just send ... - // Content-Disposition: ; filename="file" - // ... screen those out here. - if (disposition[0] == ';') - should_download = false; - - if (disposition.compare(0, 6, "inline") == 0) - should_download = false; - - // Some broken sites just send ... - // Content-Disposition: filename="file" - // ... without a disposition token... Screen those out. - if (disposition.compare(0, 8, "filename") == 0) - should_download = false; - - // Also in use is Content-Disposition: name="file" - if (disposition.compare(0, 4, "name") == 0) - should_download = false; - - // We have a content-disposition of "attachment" or unknown. - // RFC 2183, section 2.8 says that an unknown disposition - // value should be treated as "attachment". - if (should_download) - return true; - } - - // MIME type checking. - if (net::IsSupportedMimeType(type)) - return false; - - // Finally, check the plugin service. - bool allow_wildcard = false; - return !plugin_service_->HavePluginFor(type, allow_wildcard); -} - bool ResourceDispatcherHost::PauseRequestIfNeeded(ExtraRequestInfo* info) { if (info->pause_count > 0) info->is_paused = true; |