summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/buffered_resource_handler.cc
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-30 23:18:29 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-30 23:18:29 +0000
commit7f2e792eec4293b56c6eb9a5d014cee9ed612841 (patch)
tree08f30bf750e13bbaff2c3871bb0622137883294c /chrome/browser/renderer_host/buffered_resource_handler.cc
parente6d51160f9cf94237fdb2a25317c20c43eb14b6b (diff)
downloadchromium_src-7f2e792eec4293b56c6eb9a5d014cee9ed612841.zip
chromium_src-7f2e792eec4293b56c6eb9a5d014cee9ed612841.tar.gz
chromium_src-7f2e792eec4293b56c6eb9a5d014cee9ed612841.tar.bz2
Revert 33344 - Relocate plugin list fetching to PluginService
We fetch the plugin list from three places. Previously, each location had custom code to proxy the query to the file thread. This change moves the query to the PluginService, which then internally manages posting to the file thread and calling back. I experimented with some different approaches to handling the lifetimes of the requests and responses. The approach now is simple: The PluginService plugin methods are called and respond on the IO thread. Two of the three consumers of the plugin lists are already on the IO thread, so they don't need any complicated thread handling. None of the callers ever need to cancel their requests: one is a singleton, and the other two always wait (in terms of holding a ref on the object) for the requests to complete. This makes lifetime management a lot simpler than it would otherwise be. With this change in place, I can then look at refactoring the PluginService implementation on Linux to do more complicated plugin loading as needed in bug 17863. BUG=17863 Review URL: http://codereview.chromium.org/437069 TBR=evan@chromium.org Review URL: http://codereview.chromium.org/456012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33369 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host/buffered_resource_handler.cc')
-rw-r--r--chrome/browser/renderer_host/buffered_resource_handler.cc38
1 files changed, 21 insertions, 17 deletions
diff --git a/chrome/browser/renderer_host/buffered_resource_handler.cc b/chrome/browser/renderer_host/buffered_resource_handler.cc
index a72c54d..f3ca82f 100644
--- a/chrome/browser/renderer_host/buffered_resource_handler.cc
+++ b/chrome/browser/renderer_host/buffered_resource_handler.cc
@@ -10,7 +10,6 @@
#include "base/logging.h"
#include "base/string_util.h"
#include "chrome/browser/chrome_thread.h"
-#include "chrome/browser/plugin_service.h"
#include "chrome/browser/renderer_host/download_throttling_resource_handler.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
@@ -396,10 +395,10 @@ bool BufferedResourceHandler::ShouldWaitForPlugins() {
ResourceDispatcherHost::InfoForRequest(request_);
host_->PauseRequest(info->child_id(), info->request_id(), true);
- // Schedule plugin loading.
- this->AddRef(); // Balanced in OnGetPluginList.
- PluginService::GetInstance()->GetPluginList(false, this);
-
+ // Schedule plugin loading on the file thread.
+ ChromeThread::PostTask(
+ ChromeThread::FILE, FROM_HERE,
+ NewRunnableMethod(this, &BufferedResourceHandler::LoadPlugins));
return true;
}
@@ -467,18 +466,23 @@ bool BufferedResourceHandler::ShouldDownload(bool* need_plugin_list) {
GURL(), type, allow_wildcard, &info, NULL);
}
-void BufferedResourceHandler::OnGetPluginList(
- const std::vector<WebPluginInfo>& plugins) {
- wait_for_plugins_ = false;
+void BufferedResourceHandler::LoadPlugins() {
+ std::vector<WebPluginInfo> plugins;
+ NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins);
- if (request_) {
- ResourceDispatcherHostRequestInfo* info =
- ResourceDispatcherHost::InfoForRequest(request_);
- host_->PauseRequest(info->child_id(), info->request_id(), false);
- if (!CompleteResponseStarted(info->request_id(), false))
- host_->CancelRequest(info->child_id(), info->request_id(), false);
- }
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded));
+}
- // Drop the reference added before the GetPluginList call.
- this->Release();
+void BufferedResourceHandler::OnPluginsLoaded() {
+ wait_for_plugins_ = false;
+ if (!request_)
+ return;
+
+ ResourceDispatcherHostRequestInfo* info =
+ ResourceDispatcherHost::InfoForRequest(request_);
+ host_->PauseRequest(info->child_id(), info->request_id(), false);
+ if (!CompleteResponseStarted(info->request_id(), false))
+ host_->CancelRequest(info->child_id(), info->request_id(), false);
}