summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-18 02:23:23 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-18 02:23:23 +0000
commit6be08ae197f90f71e3804ff1e842000a5db2af20 (patch)
tree3016a1b15cbb62bb76d43d9811a610792fd56d8f
parentd981cd2612938c3737d73922b5e2a9bc74da73ad (diff)
downloadchromium_src-6be08ae197f90f71e3804ff1e842000a5db2af20.zip
chromium_src-6be08ae197f90f71e3804ff1e842000a5db2af20.tar.gz
chromium_src-6be08ae197f90f71e3804ff1e842000a5db2af20.tar.bz2
Move PluginLoaderClient to PluginLoaderPosix in its own file.
BUG=none TEST=none Review URL: http://codereview.chromium.org/8334004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106003 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/plugin_loader_posix.cc77
-rw-r--r--content/browser/plugin_loader_posix.h44
-rw-r--r--content/browser/plugin_service.cc70
-rw-r--r--content/content_browser.gypi14
4 files changed, 131 insertions, 74 deletions
diff --git a/content/browser/plugin_loader_posix.cc b/content/browser/plugin_loader_posix.cc
new file mode 100644
index 0000000..da3d55a
--- /dev/null
+++ b/content/browser/plugin_loader_posix.cc
@@ -0,0 +1,77 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/plugin_loader_posix.h"
+
+#include "base/bind.h"
+#include "base/message_loop_proxy.h"
+#include "content/browser/browser_thread.h"
+#include "content/common/utility_messages.h"
+#include "webkit/plugins/npapi/plugin_list.h"
+
+namespace {
+
+void RunGetPluginsCallback(const PluginService::GetPluginsCallback& callback,
+ const std::vector<webkit::WebPluginInfo> plugins) {
+ callback.Run(plugins);
+}
+
+} // namespace
+
+// static
+void PluginLoaderPosix::LoadPlugins(
+ base::MessageLoopProxy* target_loop,
+ const PluginService::GetPluginsCallback& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ PluginLoaderPosix* client = new PluginLoaderPosix(target_loop, callback);
+ UtilityProcessHost* process_host =
+ new UtilityProcessHost(client, BrowserThread::IO);
+ process_host->set_no_sandbox(true);
+#if defined(OS_MACOSX)
+ process_host->set_child_flags(ChildProcessHost::CHILD_ALLOW_HEAP_EXECUTION);
+#endif
+
+ std::vector<FilePath> extra_plugin_paths;
+ std::vector<FilePath> extra_plugin_dirs;
+ std::vector<webkit::WebPluginInfo> internal_plugins;
+ webkit::npapi::PluginList::Singleton()->GetPluginPathListsToLoad(
+ &extra_plugin_paths, &extra_plugin_dirs, &internal_plugins);
+
+ process_host->Send(new UtilityMsg_LoadPlugins(
+ extra_plugin_paths, extra_plugin_dirs, internal_plugins));
+}
+
+bool PluginLoaderPosix::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(PluginLoaderPosix, message)
+ IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadedPlugins, OnGotPlugins)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void PluginLoaderPosix::OnProcessCrashed(int exit_code) {
+ LOG(ERROR) << "Out-of-process plugin loader crashed with code " << exit_code
+ << ". You will have no plugins!";
+ // Don't leave callers hanging.
+ OnGotPlugins(std::vector<webkit::WebPluginInfo>());
+}
+
+PluginLoaderPosix::PluginLoaderPosix(
+ base::MessageLoopProxy* target_loop,
+ const PluginService::GetPluginsCallback& callback)
+ : target_loop_(target_loop),
+ callback_(callback) {
+}
+
+PluginLoaderPosix::~PluginLoaderPosix() {
+}
+
+void PluginLoaderPosix::OnGotPlugins(
+ const std::vector<webkit::WebPluginInfo>& plugins) {
+ webkit::npapi::PluginList::Singleton()->SetPlugins(plugins);
+ target_loop_->PostTask(FROM_HERE,
+ base::Bind(&RunGetPluginsCallback, callback_, plugins));
+}
diff --git a/content/browser/plugin_loader_posix.h b/content/browser/plugin_loader_posix.h
new file mode 100644
index 0000000..e766f9e
--- /dev/null
+++ b/content/browser/plugin_loader_posix.h
@@ -0,0 +1,44 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_
+#define CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_
+
+#include <vector>
+
+#include "base/memory/ref_counted.h"
+#include "content/browser/plugin_service.h"
+#include "content/browser/utility_process_host.h"
+#include "webkit/plugins/webplugininfo.h"
+
+namespace base {
+class MessageLoopProxy;
+}
+
+class PluginLoaderPosix : public UtilityProcessHost::Client {
+ public:
+ // Must be called on the IO thread.
+ static void LoadPlugins(base::MessageLoopProxy* target_loop,
+ const PluginService::GetPluginsCallback& callback);
+
+ // UtilityProcessHost::Client:
+ virtual void OnProcessCrashed(int exit_code) OVERRIDE;
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+ private:
+ PluginLoaderPosix(base::MessageLoopProxy* target_loop,
+ const PluginService::GetPluginsCallback& callback);
+ virtual ~PluginLoaderPosix();
+
+ void OnGotPlugins(const std::vector<webkit::WebPluginInfo>& plugins);
+
+ // The callback and message loop on which the callback will be run when the
+ // plugin loading process has been completed.
+ scoped_refptr<base::MessageLoopProxy> target_loop_;
+ PluginService::GetPluginsCallback callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(PluginLoaderPosix);
+};
+
+#endif // CONTENT_BROWSER_PLUGIN_LOADER_POSIX_H_
diff --git a/content/browser/plugin_service.cc b/content/browser/plugin_service.cc
index ba05a15..e47ba89 100644
--- a/content/browser/plugin_service.cc
+++ b/content/browser/plugin_service.cc
@@ -18,6 +18,7 @@
#include "base/values.h"
#include "content/browser/browser_thread.h"
#include "content/browser/content_browser_client.h"
+#include "content/browser/plugin_loader_posix.h"
#include "content/browser/plugin_service_filter.h"
#include "content/browser/ppapi_plugin_process_host.h"
#include "content/browser/renderer_host/render_process_host.h"
@@ -73,72 +74,6 @@ void WillLoadPluginsCallback() {
#endif
}
-#if defined(OS_POSIX)
-// Utility child process client that manages the IPC for loading plugins out of
-// process.
-class PluginLoaderClient : public UtilityProcessHost::Client {
- public:
- // Meant to be called on the IO thread. Will invoke the callback on the target
- // loop when the plugins have been loaded.
- static void LoadPluginsOutOfProcess(
- base::MessageLoopProxy* target_loop,
- const PluginService::GetPluginsCallback& callback) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
-
- PluginLoaderClient* client = new PluginLoaderClient(target_loop, callback);
- UtilityProcessHost* process_host =
- new UtilityProcessHost(client, BrowserThread::IO);
- process_host->set_no_sandbox(true);
-#if defined(OS_MACOSX)
- process_host->set_child_flags(ChildProcessHost::CHILD_ALLOW_HEAP_EXECUTION);
-#endif
-
- std::vector<FilePath> extra_plugin_paths;
- std::vector<FilePath> extra_plugin_dirs;
- std::vector<webkit::WebPluginInfo> internal_plugins;
- webkit::npapi::PluginList::Singleton()->GetPluginPathListsToLoad(
- &extra_plugin_paths, &extra_plugin_dirs, &internal_plugins);
-
- process_host->Send(new UtilityMsg_LoadPlugins(
- extra_plugin_paths, extra_plugin_dirs, internal_plugins));
- }
-
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(PluginLoaderClient, message)
- IPC_MESSAGE_HANDLER(UtilityHostMsg_LoadedPlugins, OnGotPlugins)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
- }
-
- virtual void OnProcessCrashed(int exit_code) OVERRIDE {
- LOG(ERROR) << "Out-of-process plugin loader crashed with code " << exit_code
- << ". You will have no plugins!";
- // Don't leave callers hanging.
- OnGotPlugins(std::vector<webkit::WebPluginInfo>());
- }
-
- virtual void OnGotPlugins(const std::vector<webkit::WebPluginInfo>& plugins) {
- webkit::npapi::PluginList::Singleton()->SetPlugins(plugins);
- target_loop_->PostTask(FROM_HERE,
- base::Bind(&RunGetPluginsCallback, callback_, plugins));
- }
-
- private:
- PluginLoaderClient(base::MessageLoopProxy* target_loop,
- const PluginService::GetPluginsCallback& callback)
- : target_loop_(target_loop),
- callback_(callback) {
- }
-
- scoped_refptr<base::MessageLoopProxy> target_loop_;
- PluginService::GetPluginsCallback callback_;
-
- DISALLOW_COPY_AND_ASSIGN(PluginLoaderClient);
-};
-#endif // OS_POSIX
-
} // namespace
#if defined(OS_MACOSX)
@@ -574,8 +509,7 @@ void PluginService::GetPlugins(const GetPluginsCallback& callback) {
base::Bind(&RunGetPluginsCallback, callback, cached_plugins));
} else {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
- base::Bind(&PluginLoaderClient::LoadPluginsOutOfProcess,
- target_loop, callback));
+ base::Bind(&PluginLoaderPosix::LoadPlugins, target_loop, callback));
}
#endif
}
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 61d92de1..ddb91841 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -277,6 +277,14 @@
'browser/net/url_request_slow_download_job.h',
'browser/net/url_request_slow_http_job.cc',
'browser/net/url_request_slow_http_job.h',
+ 'browser/plugin_loader_posix.cc',
+ 'browser/plugin_loader_posix.h',
+ 'browser/plugin_process_host.cc',
+ 'browser/plugin_process_host.h',
+ 'browser/plugin_process_host_mac.cc',
+ 'browser/plugin_service.cc',
+ 'browser/plugin_service.h',
+ 'browser/plugin_service_filter.h',
'browser/power_save_blocker.h',
'browser/power_save_blocker_common.cc',
'browser/power_save_blocker_mac.cc',
@@ -284,12 +292,6 @@
'browser/power_save_blocker_win.cc',
'browser/ppapi_plugin_process_host.cc',
'browser/ppapi_plugin_process_host.h',
- 'browser/plugin_process_host.cc',
- 'browser/plugin_process_host.h',
- 'browser/plugin_process_host_mac.cc',
- 'browser/plugin_service.cc',
- 'browser/plugin_service.h',
- 'browser/plugin_service_filter.h',
'browser/quota_permission_context.h',
'browser/renderer_host/accelerated_plugin_view_mac.h',
'browser/renderer_host/accelerated_plugin_view_mac.mm',