summaryrefslogtreecommitdiffstats
path: root/content/ppapi_plugin/ppapi_thread.cc
diff options
context:
space:
mode:
authorddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-16 22:12:45 +0000
committerddorwin@chromium.org <ddorwin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-16 22:12:45 +0000
commite2614c60e3bab6cc1b949ecd8101189d285da17f (patch)
treef664f4e27974b7dee547aba035abef48e27c167c /content/ppapi_plugin/ppapi_thread.cc
parent64a2958841eb968837a90c9a738d9b68e33abb70 (diff)
downloadchromium_src-e2614c60e3bab6cc1b949ecd8101189d285da17f.zip
chromium_src-e2614c60e3bab6cc1b949ecd8101189d285da17f.tar.gz
chromium_src-e2614c60e3bab6cc1b949ecd8101189d285da17f.tar.bz2
Refactored ppapi Dispatcher to share common code between the plugin and broker dispatchers.
Common code is in DispatcherBase. The base of the dispatcher for plugins remains Dispatcher. The base of the dispatcher for Brokers is BrokerDispatcher. BUG=none TEST=ppapi out-of-process plugins Review URL: http://codereview.chromium.org/6859003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81883 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/ppapi_plugin/ppapi_thread.cc')
-rw-r--r--content/ppapi_plugin/ppapi_thread.cc34
1 files changed, 24 insertions, 10 deletions
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index cab4d93..54215a2 100644
--- a/content/ppapi_plugin/ppapi_thread.cc
+++ b/content/ppapi_plugin/ppapi_thread.cc
@@ -9,6 +9,7 @@
#include "base/process_util.h"
#include "base/rand_util.h"
#include "content/common/child_process.h"
+#include "content/ppapi_plugin/broker_process_dispatcher.h"
#include "content/ppapi_plugin/plugin_process_dispatcher.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_sync_channel.h"
@@ -32,11 +33,11 @@ PpapiThread::~PpapiThread() {
return;
// The ShutdownModule/ShutdownBroker function is optional.
- pp::proxy::Dispatcher::ShutdownModuleFunc shutdown_function =
+ pp::proxy::ProxyChannel::ShutdownModuleFunc shutdown_function =
is_broker_ ?
- reinterpret_cast<pp::proxy::Dispatcher::ShutdownModuleFunc>(
+ reinterpret_cast<pp::proxy::ProxyChannel::ShutdownModuleFunc>(
library_.GetFunctionPointer("PPP_ShutdownBroker")) :
- reinterpret_cast<pp::proxy::Dispatcher::ShutdownModuleFunc>(
+ reinterpret_cast<pp::proxy::ProxyChannel::ShutdownModuleFunc>(
library_.GetFunctionPointer("PPP_ShutdownModule"));
if (shutdown_function)
shutdown_function();
@@ -139,18 +140,31 @@ void PpapiThread::OnMsgCreateChannel(base::ProcessHandle host_process_handle,
bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle,
int renderer_id,
IPC::ChannelHandle* handle) {
- // TODO(ddorwin): PluginProcessDispatcher is overkill for the broker. TBD
- // whether to create separate dispatcher classes for the broker.
- // TODO(ddorwin): Provide connect_instance_func_ when is_broker_.
DCHECK(is_broker_ == (connect_instance_func_ != NULL));
DCHECK(is_broker_ == (get_plugin_interface_ == NULL));
- PluginProcessDispatcher* dispatcher(new PluginProcessDispatcher(
- host_process_handle, get_plugin_interface_));
-
IPC::ChannelHandle plugin_handle;
plugin_handle.name = StringPrintf("%d.r%d", base::GetCurrentProcId(),
renderer_id);
- if (!dispatcher->InitWithChannel(this, plugin_handle, false)) {
+
+ pp::proxy::ProxyChannel* dispatcher = NULL;
+ bool init_result = false;
+ if (is_broker_) {
+ BrokerProcessDispatcher* broker_dispatcher =
+ new BrokerProcessDispatcher(host_process_handle, connect_instance_func_);
+ init_result = broker_dispatcher->InitBrokerWithChannel(this,
+ plugin_handle,
+ false);
+ dispatcher = broker_dispatcher;
+ } else {
+ PluginProcessDispatcher* plugin_dispatcher =
+ new PluginProcessDispatcher(host_process_handle, get_plugin_interface_);
+ init_result = plugin_dispatcher->InitPluginWithChannel(this,
+ plugin_handle,
+ false);
+ dispatcher = plugin_dispatcher;
+ }
+
+ if (!init_result) {
delete dispatcher;
return false;
}