Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: content/ppapi_plugin/ppapi_thread.cc

Issue 10378057: Broker out PPAPI handle duplication (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/ppapi_plugin/ppapi_thread.cc
===================================================================
--- content/ppapi_plugin/ppapi_thread.cc (revision 136164)
+++ content/ppapi_plugin/ppapi_thread.cc (working copy)
@@ -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"
@@ -49,7 +50,8 @@
connect_instance_func_(NULL),
local_pp_module_(
base::RandInt(0, std::numeric_limits<PP_Module>::max())),
- next_plugin_dispatcher_id_(1) {
+ next_plugin_dispatcher_id_(1),
+ peer_handle_(base::kNullProcessHandle) {
ppapi::proxy::PluginGlobals* globals = ppapi::proxy::PluginGlobals::Get();
globals->set_plugin_proxy_delegate(this);
globals->set_command_line(
@@ -117,6 +119,12 @@
IPC_END_MESSAGE_MAP()
return true;
}
+void PpapiThread::OnChannelConnected(int32 peer_pid) {
jschuh 2012/05/10 00:10:57 We cache a handle to the other end here, because i
+#if defined(OS_WIN)
+ if (is_broker_)
+ peer_handle_ = ::OpenProcess(PROCESS_DUP_HANDLE, FALSE, peer_pid);
cpu_(ooo_6.6-7.5) 2012/05/10 22:10:43 do we ever close the peer handle? base::ProcessHan
jschuh 2012/05/10 22:16:28 D'oh. I thought I'd made that a scoped handle. Fix
+#endif
+}
base::MessageLoopProxy* PpapiThread::GetIPCMessageLoop() {
return ChildProcess::current()->io_message_loop_proxy();
@@ -126,6 +134,23 @@
return ChildProcess::current()->GetShutDownEvent();
}
+IPC::PlatformFileForTransit PpapiThread::ShareHandleWithRemote(
jschuh 2012/05/10 00:10:57 Here's the handle duping logic.
+ base::PlatformFile handle,
+ const IPC::SyncChannel& channel,
+ bool should_close_source) {
+ IPC::PlatformFileForTransit out_handle;
+ if (peer_handle_) {
+ DCHECK(is_broker_);
+ return IPC::GetFileHandleForProcess(handle, peer_handle_,
+ should_close_source);
+ } else {
+ DCHECK(!is_broker_);
+ return content::BrokerGetFileHandleForProcess(handle, channel.peer_pid(),
+ should_close_source);
+ }
+ return out_handle;
+}
+
std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() {
return &globally_seen_instance_ids_;
}
@@ -247,13 +272,11 @@
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 +307,7 @@
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 +319,7 @@
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 +327,7 @@
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);

Powered by Google App Engine
This is Rietveld 408576698