summaryrefslogtreecommitdiffstats
path: root/content/ppapi_plugin
diff options
context:
space:
mode:
authorjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 22:09:11 +0000
committerjschuh@chromium.org <jschuh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 22:09:11 +0000
commitf0ecb550248afddff9a28c8bf645e689f59a6e3e (patch)
tree5f5cf57c51d63213af26411488117f64e1a3b42d /content/ppapi_plugin
parente9dfe22b38c9f4b14dbf047e3e0816537ea632d4 (diff)
downloadchromium_src-f0ecb550248afddff9a28c8bf645e689f59a6e3e.zip
chromium_src-f0ecb550248afddff9a28c8bf645e689f59a6e3e.tar.gz
chromium_src-f0ecb550248afddff9a28c8bf645e689f59a6e3e.tar.bz2
Broker out PPAPI handle duplication
BUG=127449 Review URL: https://chromiumcodereview.appspot.com/10378057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136686 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/ppapi_plugin')
-rw-r--r--content/ppapi_plugin/broker_process_dispatcher.cc4
-rw-r--r--content/ppapi_plugin/broker_process_dispatcher.h5
-rw-r--r--content/ppapi_plugin/plugin_process_dispatcher.cc4
-rw-r--r--content/ppapi_plugin/plugin_process_dispatcher.h5
-rw-r--r--content/ppapi_plugin/ppapi_thread.cc38
-rw-r--r--content/ppapi_plugin/ppapi_thread.h22
6 files changed, 51 insertions, 27 deletions
diff --git a/content/ppapi_plugin/broker_process_dispatcher.cc b/content/ppapi_plugin/broker_process_dispatcher.cc
index c5f4baa..6d5ffa8 100644
--- a/content/ppapi_plugin/broker_process_dispatcher.cc
+++ b/content/ppapi_plugin/broker_process_dispatcher.cc
@@ -19,11 +19,9 @@ const int kBrokerReleaseTimeSeconds = 30;
} // namespace
BrokerProcessDispatcher::BrokerProcessDispatcher(
- base::ProcessHandle remote_process_handle,
PP_GetInterface_Func get_plugin_interface,
PP_ConnectInstance_Func connect_instance)
- : ppapi::proxy::BrokerSideDispatcher(remote_process_handle,
- connect_instance),
+ : ppapi::proxy::BrokerSideDispatcher(connect_instance),
get_plugin_interface_(get_plugin_interface) {
ChildProcess::current()->AddRefProcess();
}
diff --git a/content/ppapi_plugin/broker_process_dispatcher.h b/content/ppapi_plugin/broker_process_dispatcher.h
index 2232a6a..abf1124 100644
--- a/content/ppapi_plugin/broker_process_dispatcher.h
+++ b/content/ppapi_plugin/broker_process_dispatcher.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -14,8 +14,7 @@
// from the PPAPI proxy on the Chrome multiprocess infrastructure.
class BrokerProcessDispatcher : public ppapi::proxy::BrokerSideDispatcher {
public:
- BrokerProcessDispatcher(base::ProcessHandle remote_process_handle,
- PP_GetInterface_Func get_plugin_interface,
+ BrokerProcessDispatcher(PP_GetInterface_Func get_plugin_interface,
PP_ConnectInstance_Func connect_instance);
virtual ~BrokerProcessDispatcher();
diff --git a/content/ppapi_plugin/plugin_process_dispatcher.cc b/content/ppapi_plugin/plugin_process_dispatcher.cc
index bf77c66..869f94c 100644
--- a/content/ppapi_plugin/plugin_process_dispatcher.cc
+++ b/content/ppapi_plugin/plugin_process_dispatcher.cc
@@ -16,11 +16,9 @@ const int kPluginReleaseTimeSeconds = 30;
} // namespace
PluginProcessDispatcher::PluginProcessDispatcher(
- base::ProcessHandle remote_process_handle,
PP_GetInterface_Func get_interface,
bool incognito)
- : ppapi::proxy::PluginDispatcher(remote_process_handle,
- get_interface,
+ : ppapi::proxy::PluginDispatcher(get_interface,
incognito) {
ChildProcess::current()->AddRefProcess();
}
diff --git a/content/ppapi_plugin/plugin_process_dispatcher.h b/content/ppapi_plugin/plugin_process_dispatcher.h
index 631b0c1..b48f5b1 100644
--- a/content/ppapi_plugin/plugin_process_dispatcher.h
+++ b/content/ppapi_plugin/plugin_process_dispatcher.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -13,8 +13,7 @@
// from the PPAPI proxy on the Chrome multiprocess infrastructure.
class PluginProcessDispatcher : public ppapi::proxy::PluginDispatcher {
public:
- PluginProcessDispatcher(base::ProcessHandle remote_process_handle,
- PP_GetInterface_Func get_interface,
+ PluginProcessDispatcher(PP_GetInterface_Func get_interface,
bool incognito);
virtual ~PluginProcessDispatcher();
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index bf84ce2..7b7d2455 100644
--- a/content/ppapi_plugin/ppapi_thread.cc
+++ b/content/ppapi_plugin/ppapi_thread.cc
@@ -18,6 +18,7 @@
#include "content/ppapi_plugin/ppapi_webkitplatformsupport_impl.h"
#include "content/public/common/sandbox_init.h"
#include "ipc/ipc_channel_handle.h"
+#include "ipc/ipc_platform_file.h"
#include "ipc/ipc_sync_channel.h"
#include "ppapi/c/dev/ppp_network_state_dev.h"
#include "ppapi/c/pp_errors.h"
@@ -117,6 +118,12 @@ bool PpapiThread::OnMessageReceived(const IPC::Message& msg) {
IPC_END_MESSAGE_MAP()
return true;
}
+void PpapiThread::OnChannelConnected(int32 peer_pid) {
+#if defined(OS_WIN)
+ if (is_broker_)
+ peer_handle_.Set(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid));
+#endif
+}
base::MessageLoopProxy* PpapiThread::GetIPCMessageLoop() {
return ChildProcess::current()->io_message_loop_proxy();
@@ -126,6 +133,22 @@ base::WaitableEvent* PpapiThread::GetShutdownEvent() {
return ChildProcess::current()->GetShutDownEvent();
}
+IPC::PlatformFileForTransit PpapiThread::ShareHandleWithRemote(
+ base::PlatformFile handle,
+ const IPC::SyncChannel& channel,
+ bool should_close_source) {
+#if defined(OS_WIN)
+ if (peer_handle_.IsValid()) {
+ DCHECK(is_broker_);
+ return IPC::GetFileHandleForProcess(handle, peer_handle_,
+ should_close_source);
+ }
+#endif
+
+ return content::BrokerGetFileHandleForProcess(handle, channel.peer_pid(),
+ should_close_source);
+}
+
std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() {
return &globally_seen_instance_ids_;
}
@@ -247,13 +270,11 @@ void PpapiThread::OnMsgLoadPlugin(const FilePath& path) {
library_.Reset(library.Release());
}
-void PpapiThread::OnMsgCreateChannel(base::ProcessHandle host_process_handle,
- int renderer_id,
+void PpapiThread::OnMsgCreateChannel(int renderer_id,
bool incognito) {
IPC::ChannelHandle channel_handle;
if (!library_.is_valid() || // Plugin couldn't be loaded.
- !SetupRendererChannel(host_process_handle, renderer_id, incognito,
- &channel_handle)) {
+ !SetupRendererChannel(renderer_id, incognito, &channel_handle)) {
Send(new PpapiHostMsg_ChannelCreated(IPC::ChannelHandle()));
return;
}
@@ -284,8 +305,7 @@ void PpapiThread::OnPluginDispatcherMessageReceived(const IPC::Message& msg) {
dispatcher->second->OnMessageReceived(msg);
}
-bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle,
- int renderer_id,
+bool PpapiThread::SetupRendererChannel(int renderer_id,
bool incognito,
IPC::ChannelHandle* handle) {
DCHECK(is_broker_ == (connect_instance_func_ != NULL));
@@ -297,8 +317,7 @@ bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle,
bool init_result = false;
if (is_broker_) {
BrokerProcessDispatcher* broker_dispatcher =
- new BrokerProcessDispatcher(host_process_handle,
- get_plugin_interface_,
+ new BrokerProcessDispatcher(get_plugin_interface_,
connect_instance_func_);
init_result = broker_dispatcher->InitBrokerWithChannel(this,
plugin_handle,
@@ -306,8 +325,7 @@ bool PpapiThread::SetupRendererChannel(base::ProcessHandle host_process_handle,
dispatcher = broker_dispatcher;
} else {
PluginProcessDispatcher* plugin_dispatcher =
- new PluginProcessDispatcher(host_process_handle, get_plugin_interface_,
- incognito);
+ new PluginProcessDispatcher(get_plugin_interface_, incognito);
init_result = plugin_dispatcher->InitPluginWithChannel(this,
plugin_handle,
false);
diff --git a/content/ppapi_plugin/ppapi_thread.h b/content/ppapi_plugin/ppapi_thread.h
index c416ba4..229ec3b 100644
--- a/content/ppapi_plugin/ppapi_thread.h
+++ b/content/ppapi_plugin/ppapi_thread.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -22,6 +22,10 @@
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/plugin_proxy_delegate.h"
+#if defined(OS_WIN)
+#include "base/win/scoped_handle.h"
+#endif
+
class CommandLine;
class FilePath;
class PpapiWebKitPlatformSupportImpl;
@@ -40,11 +44,16 @@ class PpapiThread : public ChildThread,
private:
// ChildThread overrides.
virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE;
+ virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
// PluginDispatcher::PluginDelegate implementation.
virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() OVERRIDE;
virtual base::MessageLoopProxy* GetIPCMessageLoop() OVERRIDE;
virtual base::WaitableEvent* GetShutdownEvent() OVERRIDE;
+ virtual IPC::PlatformFileForTransit ShareHandleWithRemote(
+ base::PlatformFile handle,
+ const IPC::SyncChannel& channel,
+ bool should_close_source) OVERRIDE;
virtual uint32 Register(
ppapi::proxy::PluginDispatcher* plugin_dispatcher) OVERRIDE;
virtual void Unregister(uint32 plugin_dispatcher_id) OVERRIDE;
@@ -55,16 +64,14 @@ class PpapiThread : public ChildThread,
// Message handlers.
void OnMsgLoadPlugin(const FilePath& path);
- void OnMsgCreateChannel(base::ProcessHandle host_process_handle,
- int renderer_id,
+ void OnMsgCreateChannel(int renderer_id,
bool incognito);
void OnMsgSetNetworkState(bool online);
void OnPluginDispatcherMessageReceived(const IPC::Message& msg);
// Sets up the channel to the given renderer. On success, returns true and
// fills the given ChannelHandle with the information from the new channel.
- bool SetupRendererChannel(base::ProcessHandle host_process_handle,
- int renderer_id,
+ bool SetupRendererChannel(int renderer_id,
bool incognito,
IPC::ChannelHandle* handle);
@@ -103,6 +110,11 @@ class PpapiThread : public ChildThread,
// The WebKitPlatformSupport implementation.
scoped_ptr<PpapiWebKitPlatformSupportImpl> webkit_platform_support_;
+#if defined(OS_WIN)
+ // Caches the handle to the peer process if this is a broker.
+ base::win::ScopedHandle peer_handle_;
+#endif
+
DISALLOW_IMPLICIT_CONSTRUCTORS(PpapiThread);
};