summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-16 14:47:49 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-16 14:47:49 +0000
commita33fa9deedf36922c57d4e1d3e8947ce62606f26 (patch)
tree4066731e41dbf7dfa0d1cb29bb2a4e52acff5851 /content/browser
parent69554ef8f8e60c68512e7ddaa67ff26cf04dad22 (diff)
downloadchromium_src-a33fa9deedf36922c57d4e1d3e8947ce62606f26.zip
chromium_src-a33fa9deedf36922c57d4e1d3e8947ce62606f26.tar.gz
chromium_src-a33fa9deedf36922c57d4e1d3e8947ce62606f26.tar.bz2
Sequentialize calls to PluginList::GetPlugins from PluginService.
BUG=105987 TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=137396 Review URL: https://chromiumcodereview.appspot.com/10381087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137421 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/plugin_service_impl.cc35
-rw-r--r--content/browser/plugin_service_impl.h9
2 files changed, 34 insertions, 10 deletions
diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc
index e7dfead..29873b4 100644
--- a/content/browser/plugin_service_impl.cc
+++ b/content/browser/plugin_service_impl.cc
@@ -13,7 +13,6 @@
#include "base/path_service.h"
#include "base/string_util.h"
#include "base/synchronization/waitable_event.h"
-#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
@@ -60,13 +59,17 @@ static void GetPluginsForGroupsCallback(
// Callback set on the PluginList to assert that plugin loading happens on the
// correct thread.
-void WillLoadPluginsCallback() {
#if defined(OS_WIN)
- CHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+void WillLoadPluginsCallbackWin(
+ base::SequencedWorkerPool::SequenceToken token) {
+ CHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread(
+ token));
+}
#else
+void WillLoadPluginsCallbackPosix() {
CHECK(false) << "Plugin loading should happen out-of-process.";
-#endif
}
+#endif
} // namespace
@@ -147,8 +150,14 @@ void PluginServiceImpl::Init() {
if (!plugin_list_)
plugin_list_ = webkit::npapi::PluginList::Singleton();
+#if defined(OS_WIN)
+ plugin_list_token_ = BrowserThread::GetBlockingPool()->GetSequenceToken();
plugin_list_->set_will_load_plugins_callback(
- base::Bind(&WillLoadPluginsCallback));
+ base::Bind(&WillLoadPluginsCallbackWin, plugin_list_token_));
+#else
+ plugin_list_->set_will_load_plugins_callback(
+ base::Bind(&WillLoadPluginsCallbackPosix));
+#endif
RegisterPepperPlugins();
@@ -163,6 +172,7 @@ void PluginServiceImpl::Init() {
if (!path.empty())
plugin_list_->AddExtraPluginDir(path);
+
#if defined(OS_MACOSX)
// We need to know when the browser comes forward so we can bring modal plugin
// windows forward too.
@@ -192,7 +202,8 @@ void PluginServiceImpl::StartWatchingPlugins() {
hklm_watcher_.StartWatching(hklm_event_.get(), this);
}
}
-#elif defined(OS_POSIX) && !defined(OS_OPENBSD)
+#endif
+#if defined(OS_POSIX) && !defined(OS_OPENBSD)
// On ChromeOS the user can't install plugins anyway and on Windows all
// important plugins register themselves in the registry so no need to do that.
file_watcher_delegate_ = new PluginDirWatcherDelegate();
@@ -506,12 +517,13 @@ void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) {
MessageLoop::current()->message_loop_proxy());
#if defined(OS_WIN)
- BrowserThread::GetBlockingPool()->PostWorkerTaskWithShutdownBehavior(
+ BrowserThread::GetBlockingPool()->PostSequencedWorkerTaskWithShutdownBehavior(
+ plugin_list_token_,
FROM_HERE,
base::Bind(&PluginServiceImpl::GetPluginsInternal, base::Unretained(this),
target_loop, callback),
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
-#else
+#elif defined(OS_POSIX)
std::vector<webkit::WebPluginInfo> cached_plugins;
if (plugin_list_->GetPluginsIfNoRefreshNeeded(&cached_plugins)) {
// Can't assume the caller is reentrant.
@@ -526,6 +538,8 @@ void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) {
base::Bind(&PluginLoaderPosix::LoadPlugins, plugin_loader_,
target_loop, callback));
}
+#else
+#error Not implemented
#endif
}
@@ -534,10 +548,12 @@ void PluginServiceImpl::GetPluginGroups(
GetPlugins(base::Bind(&GetPluginsForGroupsCallback, callback));
}
+#if defined(OS_WIN)
void PluginServiceImpl::GetPluginsInternal(
base::MessageLoopProxy* target_loop,
const PluginService::GetPluginsCallback& callback) {
- DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread());
+ DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread(
+ plugin_list_token_));
std::vector<webkit::WebPluginInfo> plugins;
plugin_list_->GetPlugins(&plugins);
@@ -545,6 +561,7 @@ void PluginServiceImpl::GetPluginsInternal(
target_loop->PostTask(FROM_HERE,
base::Bind(callback, plugins));
}
+#endif
void PluginServiceImpl::OnWaitableEventSignaled(
base::WaitableEvent* waitable_event) {
diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h
index bc8f112..b3fcbf9 100644
--- a/content/browser/plugin_service_impl.h
+++ b/content/browser/plugin_service_impl.h
@@ -18,6 +18,7 @@
#include "base/memory/scoped_vector.h"
#include "base/memory/singleton.h"
#include "base/synchronization/waitable_event_watcher.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "base/time.h"
#include "build/build_config.h"
#include "content/browser/plugin_process_host.h"
@@ -177,9 +178,11 @@ class CONTENT_EXPORT PluginServiceImpl
void RegisterPepperPlugins();
- // Function that is run on the FILE thread to load the plugins synchronously.
+#if defined(OS_WIN)
+ // Run on the blocking pool to load the plugins synchronously.
void GetPluginsInternal(base::MessageLoopProxy* target_loop,
const GetPluginsCallback& callback);
+#endif
// Binding directly to GetAllowedPluginForOpenChannelToPlugin() isn't possible
// because more arity is needed <http://crbug.com/98542>. This just forwards.
@@ -240,6 +243,10 @@ class CONTENT_EXPORT PluginServiceImpl
std::set<PluginProcessHost::Client*> pending_plugin_clients_;
+#if defined(OS_WIN)
+ // Used to sequentialize loading plug-ins from disk.
+ base::SequencedWorkerPool::SequenceToken plugin_list_token_;
+#endif
#if defined(OS_POSIX)
scoped_refptr<PluginLoaderPosix> plugin_loader_;
#endif