summaryrefslogtreecommitdiffstats
path: root/chrome/browser/plugin_service.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 05:24:21 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 05:24:21 +0000
commitc2c901bf406a50085002f8f1d6d63288d6e28c05 (patch)
tree7eb876216d6c541404fb73c3eaa32f387c8b9e6b /chrome/browser/plugin_service.cc
parent684970b638fbfe1a2137fd162f630c86d2859828 (diff)
downloadchromium_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/plugin_service.cc')
-rw-r--r--chrome/browser/plugin_service.cc43
1 files changed, 9 insertions, 34 deletions
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index d9d3e65..fe6dfa6 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -40,8 +40,10 @@ PluginService::PluginService()
// Load the one specified on the command line as well.
const CommandLine* command_line = CommandLine::ForCurrentProcess();
std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin);
- if (!path.empty())
- NPAPI::PluginList::AddExtraPluginPath(FilePath::FromWStringHack(path));
+ if (!path.empty()) {
+ NPAPI::PluginList::Singleton()->AddExtraPluginPath(
+ FilePath::FromWStringHack(path));
+ }
#if defined(OS_WIN)
hkcu_key_.Create(
@@ -75,12 +77,6 @@ PluginService::~PluginService() {
#endif
}
-void PluginService::GetPlugins(bool refresh,
- std::vector<WebPluginInfo>* plugins) {
- AutoLock lock(lock_);
- NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins);
-}
-
void PluginService::LoadChromePlugins(
ResourceDispatcherHost* resource_dispatcher_host) {
resource_dispatcher_host_ = resource_dispatcher_host;
@@ -88,12 +84,10 @@ void PluginService::LoadChromePlugins(
}
void PluginService::SetChromePluginDataDir(const FilePath& data_dir) {
- AutoLock lock(lock_);
chrome_plugin_data_dir_ = data_dir;
}
const FilePath& PluginService::GetChromePluginDataDir() {
- AutoLock lock(lock_);
return chrome_plugin_data_dir_;
}
@@ -132,7 +126,8 @@ PluginProcessHost* PluginService::FindOrStartPluginProcess(
return plugin_host;
WebPluginInfo info;
- if (!GetPluginInfoByPath(plugin_path, &info)) {
+ if (!NPAPI::PluginList::Singleton()->GetPluginInfoByPath(
+ plugin_path, &info)) {
DCHECK(false);
return NULL;
}
@@ -179,7 +174,6 @@ FilePath PluginService::GetPluginPath(const GURL& url,
const std::string& mime_type,
const std::string& clsid,
std::string* actual_mime_type) {
- AutoLock lock(lock_);
bool allow_wildcard = true;
WebPluginInfo info;
if (NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid,
@@ -192,23 +186,6 @@ FilePath PluginService::GetPluginPath(const GURL& url,
return FilePath();
}
-bool PluginService::GetPluginInfoByPath(const FilePath& plugin_path,
- WebPluginInfo* info) {
- AutoLock lock(lock_);
- return NPAPI::PluginList::Singleton()->GetPluginInfoByPath(plugin_path, info);
-}
-
-bool PluginService::HavePluginFor(const std::string& mime_type,
- bool allow_wildcard) {
- AutoLock lock(lock_);
-
- GURL url;
- WebPluginInfo info;
- return NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, "",
- allow_wildcard, &info,
- NULL);
-}
-
void PluginService::OnWaitableEventSignaled(base::WaitableEvent* waitable_event) {
#if defined(OS_WIN)
if (waitable_event == hkcu_event_.get()) {
@@ -217,8 +194,7 @@ void PluginService::OnWaitableEventSignaled(base::WaitableEvent* waitable_event)
hklm_key_.StartWatching();
}
- AutoLock lock(lock_);
- NPAPI::PluginList::ResetPluginsLoaded();
+ NPAPI::PluginList::Singleton()->ResetPluginsLoaded();
for (RenderProcessHost::iterator it = RenderProcessHost::begin();
it != RenderProcessHost::end(); ++it) {
@@ -242,9 +218,8 @@ void PluginService::Observe(NotificationType type,
extension != extensions->end(); ++extension) {
for (size_t i = 0; i < (*extension)->plugins().size(); ++i ) {
const Extension::PluginInfo& plugin = (*extension)->plugins()[i];
- AutoLock lock(lock_);
- NPAPI::PluginList::ResetPluginsLoaded();
- NPAPI::PluginList::AddExtraPluginPath(plugin.path);
+ NPAPI::PluginList::Singleton()->ResetPluginsLoaded();
+ NPAPI::PluginList::Singleton()->AddExtraPluginPath(plugin.path);
if (!plugin.is_public)
private_plugins_[plugin.path] = (*extension)->url();
}