From aa7f880a41a81571f1fc4c781a21cf309885198a Mon Sep 17 00:00:00 2001
From: "bauerb@chromium.org"
 <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Mon, 27 Jan 2014 16:56:32 +0000
Subject: Restart plugin loading only if the plugin list has actually become
 stale.

BUG=171404

Review URL: https://codereview.chromium.org/128773002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247252 0039d316-1c4b-4281-b951-d872f2087c98
---
 content/browser/plugin_service_impl.cc | 40 ++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 14 deletions(-)

(limited to 'content/browser/plugin_service_impl.cc')

diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc
index b65704b..047859a 100644
--- a/content/browser/plugin_service_impl.cc
+++ b/content/browser/plugin_service_impl.cc
@@ -115,6 +115,12 @@ void NotifyPluginDirChanged(const base::FilePath& path, bool error) {
 }
 #endif
 
+void ForwardCallback(base::MessageLoopProxy* target_loop,
+                     const PluginService::GetPluginsCallback& callback,
+                     const std::vector<WebPluginInfo>& plugins) {
+  target_loop->PostTask(FROM_HERE, base::Bind(callback, plugins));
+}
+
 }  // namespace
 
 // static
@@ -597,20 +603,9 @@ void PluginServiceImpl::GetPlugins(const GetPluginsCallback& callback) {
     return;
   }
 #if defined(OS_POSIX)
-  std::vector<WebPluginInfo> cached_plugins;
-  if (PluginList::Singleton()->GetPluginsNoRefresh(&cached_plugins)) {
-    // Can't assume the caller is reentrant.
-    target_loop->PostTask(FROM_HERE,
-        base::Bind(callback, cached_plugins));
-  } else {
-    // If we switch back to loading plugins in process, then we need to make
-    // sure g_thread_init() gets called since plugins may call glib at load.
-    if (!plugin_loader_.get())
-      plugin_loader_ = new PluginLoaderPosix;
-    BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
-        base::Bind(&PluginLoaderPosix::LoadPlugins, plugin_loader_,
-                   target_loop, callback));
-  }
+  BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
+      base::Bind(&PluginServiceImpl::GetPluginsOnIOThread,
+                 base::Unretained(this), target_loop, callback));
 #else
   NOTREACHED();
 #endif
@@ -629,6 +624,23 @@ void PluginServiceImpl::GetPluginsInternal(
       base::Bind(callback, plugins));
 }
 
+#if defined(OS_POSIX)
+void PluginServiceImpl::GetPluginsOnIOThread(
+    base::MessageLoopProxy* target_loop,
+    const GetPluginsCallback& callback) {
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+  // If we switch back to loading plugins in process, then we need to make
+  // sure g_thread_init() gets called since plugins may call glib at load.
+
+  if (!plugin_loader_)
+    plugin_loader_ = new PluginLoaderPosix;
+
+  plugin_loader_->GetPlugins(
+      base::Bind(&ForwardCallback, make_scoped_refptr(target_loop), callback));
+}
+#endif
+
 void PluginServiceImpl::OnWaitableEventSignaled(
     base::WaitableEvent* waitable_event) {
 #if defined(OS_WIN)
-- 
cgit v1.1