summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/plugin_data_remover_impl.cc1
-rw-r--r--content/browser/plugin_service_impl.cc6
-rw-r--r--content/browser/ppapi_plugin_process_host.cc30
-rw-r--r--content/browser/ppapi_plugin_process_host.h3
-rw-r--r--content/browser/renderer_host/render_message_filter.cc9
-rw-r--r--content/common/fileapi/file_system_dispatcher.cc3
-rw-r--r--content/common/view_messages.h6
-rw-r--r--content/content_common.gypi1
-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
-rw-r--r--content/public/common/sandbox_init.cc44
-rw-r--r--content/public/common/sandbox_init.h10
-rw-r--r--content/renderer/pepper/pepper_broker_impl.cc6
-rw-r--r--content/renderer/pepper/pepper_broker_impl.h6
-rw-r--r--content/renderer/pepper/pepper_broker_impl_unittest.cc8
-rw-r--r--content/renderer/pepper/pepper_plugin_delegate_impl.cc17
-rw-r--r--content/renderer/pepper/pepper_plugin_delegate_impl.h1
-rw-r--r--content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc10
-rw-r--r--content/renderer/pepper/pepper_proxy_channel_delegate_impl.h4
-rw-r--r--content/renderer/render_view_impl.cc2
-rw-r--r--content/renderer/render_view_impl.h1
-rw-r--r--ppapi/proxy/broker_dispatcher.cc16
-rw-r--r--ppapi/proxy/broker_dispatcher.h10
-rw-r--r--ppapi/proxy/dispatcher.cc6
-rw-r--r--ppapi/proxy/dispatcher.h3
-rw-r--r--ppapi/proxy/host_dispatcher.cc5
-rw-r--r--ppapi/proxy/host_dispatcher.h3
-rw-r--r--ppapi/proxy/plugin_dispatcher.cc5
-rw-r--r--ppapi/proxy/plugin_dispatcher.h3
-rw-r--r--ppapi/proxy/ppapi_messages.h3
-rw-r--r--ppapi/proxy/ppapi_proxy_test.cc24
-rw-r--r--ppapi/proxy/ppapi_proxy_test.h8
-rw-r--r--ppapi/proxy/proxy_channel.cc9
-rw-r--r--ppapi/proxy/proxy_channel.h16
-rw-r--r--webkit/fileapi/file_system_callback_dispatcher.cc5
-rw-r--r--webkit/fileapi/file_system_callback_dispatcher.h3
40 files changed, 214 insertions, 151 deletions
diff --git a/content/browser/plugin_data_remover_impl.cc b/content/browser/plugin_data_remover_impl.cc
index be082c1..d84f0d3 100644
--- a/content/browser/plugin_data_remover_impl.cc
+++ b/content/browser/plugin_data_remover_impl.cc
@@ -163,7 +163,6 @@ class PluginDataRemoverImpl::Context
}
virtual void OnPpapiChannelOpened(
- base::ProcessHandle /* plugin_process_handle */,
const IPC::ChannelHandle& channel_handle,
int /* child_id */) OVERRIDE {
if (!channel_handle.name.empty())
diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc
index e239126..e7dfead 100644
--- a/content/browser/plugin_service_impl.cc
+++ b/content/browser/plugin_service_impl.cc
@@ -344,8 +344,7 @@ void PluginServiceImpl::OpenChannelToPpapiPlugin(
plugin_host->OpenChannelToPlugin(client);
} else {
// Send error.
- client->OnPpapiChannelOpened(base::kNullProcessHandle,
- IPC::ChannelHandle(), 0);
+ client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0);
}
}
@@ -357,8 +356,7 @@ void PluginServiceImpl::OpenChannelToPpapiBroker(
plugin_host->OpenChannelToPlugin(client);
} else {
// Send error.
- client->OnPpapiChannelOpened(base::kNullProcessHandle,
- IPC::ChannelHandle(), 0);
+ client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0);
}
}
diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc
index 48d019f..d774718 100644
--- a/content/browser/ppapi_plugin_process_host.cc
+++ b/content/browser/ppapi_plugin_process_host.cc
@@ -207,13 +207,12 @@ void PpapiPluginProcessHost::RequestPluginChannel(Client* client) {
// We can't send any sync messages from the browser because it might lead to
// a hang. See the similar code in PluginProcessHost for more description.
PpapiMsg_CreateChannel* msg = new PpapiMsg_CreateChannel(
- process_handle, renderer_id, client->OffTheRecord());
+ renderer_id, client->OffTheRecord());
msg->set_unblock(true);
if (Send(msg)) {
sent_requests_.push(client);
} else {
- client->OnPpapiChannelOpened(base::kNullProcessHandle,
- IPC::ChannelHandle(), 0);
+ client->OnPpapiChannelOpened(IPC::ChannelHandle(), 0);
}
}
@@ -260,14 +259,12 @@ void PpapiPluginProcessHost::CancelRequests() {
DVLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "")
<< "CancelRequests()";
for (size_t i = 0; i < pending_requests_.size(); i++) {
- pending_requests_[i]->OnPpapiChannelOpened(base::kNullProcessHandle,
- IPC::ChannelHandle(), 0);
+ pending_requests_[i]->OnPpapiChannelOpened(IPC::ChannelHandle(), 0);
}
pending_requests_.clear();
while (!sent_requests_.empty()) {
- sent_requests_.front()->OnPpapiChannelOpened(base::kNullProcessHandle,
- IPC::ChannelHandle(), 0);
+ sent_requests_.front()->OnPpapiChannelOpened(IPC::ChannelHandle(), 0);
sent_requests_.pop();
}
}
@@ -283,22 +280,5 @@ void PpapiPluginProcessHost::OnRendererPluginChannelCreated(
Client* client = sent_requests_.front();
sent_requests_.pop();
- // Prepare the handle to send to the renderer.
- base::ProcessHandle plugin_process = process_->GetHandle();
-#if defined(OS_WIN)
- base::ProcessHandle renderer_process;
- int renderer_id;
- client->GetPpapiChannelInfo(&renderer_process, &renderer_id);
-
- base::ProcessHandle renderers_plugin_handle = NULL;
- ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
- renderer_process, &renderers_plugin_handle,
- 0, FALSE, DUPLICATE_SAME_ACCESS);
-#elif defined(OS_POSIX)
- // Don't need to duplicate anything on POSIX since it's just a PID.
- base::ProcessHandle renderers_plugin_handle = plugin_process;
-#endif
-
- client->OnPpapiChannelOpened(renderers_plugin_handle, channel_handle,
- process_->GetData().id);
+ client->OnPpapiChannelOpened(channel_handle, process_->GetData().id);
}
diff --git a/content/browser/ppapi_plugin_process_host.h b/content/browser/ppapi_plugin_process_host.h
index 6054a0d..deef50f 100644
--- a/content/browser/ppapi_plugin_process_host.h
+++ b/content/browser/ppapi_plugin_process_host.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.
@@ -45,7 +45,6 @@ class PpapiPluginProcessHost : public content::BrowserChildProcessHostDelegate,
// IPC::ChannelHandle(),
// 0
virtual void OnPpapiChannelOpened(
- base::ProcessHandle plugin_process_handle,
const IPC::ChannelHandle& channel_handle,
int plugin_child_id) = 0;
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 248e563..e704ec62 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -130,11 +130,10 @@ class OpenChannelToPpapiPluginCallback
*renderer_id = filter()->render_process_id();
}
- virtual void OnPpapiChannelOpened(base::ProcessHandle plugin_process_handle,
- const IPC::ChannelHandle& channel_handle,
+ virtual void OnPpapiChannelOpened(const IPC::ChannelHandle& channel_handle,
int plugin_child_id) {
ViewHostMsg_OpenChannelToPepperPlugin::WriteReplyParams(
- reply_msg(), plugin_process_handle, channel_handle, plugin_child_id);
+ reply_msg(), channel_handle, plugin_child_id);
SendReplyAndDeleteThis();
}
@@ -169,12 +168,10 @@ class OpenChannelToPpapiBrokerCallback
*renderer_id = filter_->render_process_id();
}
- virtual void OnPpapiChannelOpened(base::ProcessHandle broker_process_handle,
- const IPC::ChannelHandle& channel_handle,
+ virtual void OnPpapiChannelOpened(const IPC::ChannelHandle& channel_handle,
int /* plugin_child_id */) {
filter_->Send(new ViewMsg_PpapiBrokerChannelCreated(routing_id_,
request_id_,
- broker_process_handle,
channel_handle));
delete this;
}
diff --git a/content/common/fileapi/file_system_dispatcher.cc b/content/common/fileapi/file_system_dispatcher.cc
index 0d2d2b9..dc3309e 100644
--- a/content/common/fileapi/file_system_dispatcher.cc
+++ b/content/common/fileapi/file_system_dispatcher.cc
@@ -308,7 +308,6 @@ void FileSystemDispatcher::OnDidOpenFile(
fileapi::FileSystemCallbackDispatcher* dispatcher =
dispatchers_.Lookup(request_id);
DCHECK(dispatcher);
- dispatcher->DidOpenFile(IPC::PlatformFileForTransitToPlatformFile(file),
- base::kNullProcessHandle);
+ dispatcher->DidOpenFile(IPC::PlatformFileForTransitToPlatformFile(file));
dispatchers_.Remove(request_id);
}
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index 4e18783..b9598aa 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -1157,9 +1157,8 @@ IPC_MESSAGE_CONTROL1(ViewMsg_NetworkStateChanged,
// Reply to ViewHostMsg_OpenChannelToPpapiBroker
// Tells the renderer that the channel to the broker has been created.
-IPC_MESSAGE_ROUTED3(ViewMsg_PpapiBrokerChannelCreated,
+IPC_MESSAGE_ROUTED2(ViewMsg_PpapiBrokerChannelCreated,
int /* request_id */,
- base::ProcessHandle /* broker_process_handle */,
IPC::ChannelHandle /* handle */)
// Tells the renderer to empty its plugin list cache, optional reloading
@@ -1670,9 +1669,8 @@ IPC_MESSAGE_ROUTED3(ViewHostMsg_WebUISend,
// plugin is hung.
//
// On error an empty string and null handles are returned.
-IPC_SYNC_MESSAGE_CONTROL1_3(ViewHostMsg_OpenChannelToPepperPlugin,
+IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_OpenChannelToPepperPlugin,
FilePath /* path */,
- base::ProcessHandle /* plugin_process_handle */,
IPC::ChannelHandle /* handle to channel */,
int /* plugin_child_id */)
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 0e312b1..a0ee418 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -71,6 +71,7 @@
'public/common/resource_dispatcher_delegate.h',
'public/common/resource_response.h',
'public/common/result_codes.h',
+ 'public/common/sandbox_init.cc',
'public/common/sandbox_init.h',
'public/common/sandbox_linux.h',
'public/common/sandbox_type_mac.h',
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);
};
diff --git a/content/public/common/sandbox_init.cc b/content/public/common/sandbox_init.cc
new file mode 100644
index 0000000..528eec7
--- /dev/null
+++ b/content/public/common/sandbox_init.cc
@@ -0,0 +1,44 @@
+// 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.
+
+#include "content/public/common/sandbox_init.h"
+
+#if defined(OS_ANDROID)
+#include <unistd.h>
+#endif
+
+namespace content {
+
+IPC::PlatformFileForTransit BrokerGetFileHandleForProcess(
+ base::PlatformFile handle,
+ base::ProcessId target_process_id,
+ bool should_close_source) {
+ IPC::PlatformFileForTransit out_handle;
+#if defined(OS_WIN)
+ DWORD options = DUPLICATE_SAME_ACCESS;
+ if (should_close_source)
+ options |= DUPLICATE_CLOSE_SOURCE;
+ if (!content::BrokerDuplicateHandle(handle, target_process_id, &out_handle,
+ 0, options)) {
+ out_handle = IPC::InvalidPlatformFileForTransit();
+ }
+#elif defined(OS_POSIX)
+ // If asked to close the source, we can simply re-use the source fd instead of
+ // dup()ing and close()ing.
+ // When we're not closing the source, we need to duplicate the handle and take
+ // ownership of that. The reason is that this function is often used to
+ // generate IPC messages, and the handle must remain valid until it's sent to
+ // the other process from the I/O thread. Without the dup, calling code might
+ // close the source handle before the message is sent, creating a race
+ // condition.
+ int fd = should_close_source ? handle : ::dup(handle);
+ out_handle = base::FileDescriptor(fd, true);
+#else
+ #error Not implemented.
+#endif
+ return out_handle;
+}
+
+} // namespace content
+
diff --git a/content/public/common/sandbox_init.h b/content/public/common/sandbox_init.h
index 24da5a9..a6dcccc 100644
--- a/content/public/common/sandbox_init.h
+++ b/content/public/common/sandbox_init.h
@@ -9,6 +9,7 @@
#include "base/process.h"
#include "build/build_config.h"
#include "content/common/content_export.h"
+#include "ipc/ipc_platform_file.h"
#if defined(OS_WIN)
namespace sandbox {
@@ -76,6 +77,15 @@ CONTENT_EXPORT void InitializeSandbox();
#endif
+// Platform neutral wrapper for making an exact copy of a handle for use in
+// the target process. On Windows this wraps BrokerDuplicateHandle() with the
+// DUPLICATE_SAME_ACCESS flag. On posix it behaves essentially the same as
+// IPC::GetFileHandleForProcess()
+CONTENT_EXPORT IPC::PlatformFileForTransit BrokerGetFileHandleForProcess(
+ base::PlatformFile handle,
+ base::ProcessId target_process_id,
+ bool should_close_source);
+
} // namespace content
#endif // CONTENT_PUBLIC_COMMON_SANDBOX_INIT_H_
diff --git a/content/renderer/pepper/pepper_broker_impl.cc b/content/renderer/pepper/pepper_broker_impl.cc
index 94b88a4..1885b8e 100644
--- a/content/renderer/pepper/pepper_broker_impl.cc
+++ b/content/renderer/pepper/pepper_broker_impl.cc
@@ -55,7 +55,6 @@ PepperBrokerDispatcherWrapper::~PepperBrokerDispatcherWrapper() {
}
bool PepperBrokerDispatcherWrapper::Init(
- base::ProcessHandle broker_process_handle,
const IPC::ChannelHandle& channel_handle) {
if (channel_handle.name.empty())
return false;
@@ -68,7 +67,7 @@ bool PepperBrokerDispatcherWrapper::Init(
dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl);
dispatcher_.reset(
- new ppapi::proxy::BrokerHostDispatcher(broker_process_handle));
+ new ppapi::proxy::BrokerHostDispatcher());
if (!dispatcher_->InitBrokerWithChannel(dispatcher_delegate_.get(),
channel_handle,
@@ -191,11 +190,10 @@ void PepperBrokerImpl::Disconnect(webkit::ppapi::PPB_Broker_Impl* client) {
}
void PepperBrokerImpl::OnBrokerChannelConnected(
- base::ProcessHandle broker_process_handle,
const IPC::ChannelHandle& channel_handle) {
scoped_ptr<PepperBrokerDispatcherWrapper> dispatcher(
new PepperBrokerDispatcherWrapper);
- if (dispatcher->Init(broker_process_handle, channel_handle)) {
+ if (dispatcher->Init(channel_handle)) {
dispatcher_.reset(dispatcher.release());
// Process all pending channel requests from the plugins.
diff --git a/content/renderer/pepper/pepper_broker_impl.h b/content/renderer/pepper/pepper_broker_impl.h
index cbed850..091000e 100644
--- a/content/renderer/pepper/pepper_broker_impl.h
+++ b/content/renderer/pepper/pepper_broker_impl.h
@@ -37,8 +37,7 @@ class CONTENT_EXPORT PepperBrokerDispatcherWrapper {
PepperBrokerDispatcherWrapper();
~PepperBrokerDispatcherWrapper();
- bool Init(base::ProcessHandle plugin_process_handle,
- const IPC::ChannelHandle& channel_handle);
+ bool Init(const IPC::ChannelHandle& channel_handle);
int32_t SendHandleToBroker(PP_Instance instance,
base::SyncSocket::Handle handle);
@@ -59,8 +58,7 @@ class PepperBrokerImpl : public webkit::ppapi::PluginDelegate::Broker,
virtual void Disconnect(webkit::ppapi::PPB_Broker_Impl* client) OVERRIDE;
// Called when the channel to the broker has been established.
- void OnBrokerChannelConnected(base::ProcessHandle broker_process_handle,
- const IPC::ChannelHandle& channel_handle);
+ void OnBrokerChannelConnected(const IPC::ChannelHandle& channel_handle);
// Connects the plugin to the broker via a pipe.
void ConnectPluginToBroker(webkit::ppapi::PPB_Broker_Impl* client);
diff --git a/content/renderer/pepper/pepper_broker_impl_unittest.cc b/content/renderer/pepper/pepper_broker_impl_unittest.cc
index b3148cc..4a909a1 100644
--- a/content/renderer/pepper/pepper_broker_impl_unittest.cc
+++ b/content/renderer/pepper/pepper_broker_impl_unittest.cc
@@ -25,21 +25,19 @@ class PepperBrokerImplTest : public ::testing::Test {
// Initialization should fail.
TEST_F(PepperBrokerImplTest, InitFailure) {
PepperBrokerDispatcherWrapper dispatcher_wrapper;
- base::ProcessHandle broker_process_handle = base::kNullProcessHandle;
IPC::ChannelHandle invalid_channel; // Invalid by default.
// An invalid handle should result in a failure (false) without a LOG(FATAL),
// such as the one in CreatePipe(). Call it twice because without the invalid
// handle check, the posix code would hit a one-time path due to a static
// variable and go through the LOG(FATAL) path.
- EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, invalid_channel));
- EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, invalid_channel));
+ EXPECT_FALSE(dispatcher_wrapper.Init(invalid_channel));
+ EXPECT_FALSE(dispatcher_wrapper.Init(invalid_channel));
}
// On valid ChannelHandle, initialization should succeed.
TEST_F(PepperBrokerImplTest, InitSuccess) {
PepperBrokerDispatcherWrapper dispatcher_wrapper;
- base::ProcessHandle broker_process_handle = base::kNullProcessHandle;
const char kChannelName[] = "PepperPluginDelegateImplTestChannelName";
#if defined(OS_POSIX)
int fds[2] = {-1, -1};
@@ -52,7 +50,7 @@ TEST_F(PepperBrokerImplTest, InitSuccess) {
IPC::ChannelHandle valid_channel(kChannelName);
#endif // defined(OS_POSIX));
- EXPECT_TRUE(dispatcher_wrapper.Init(broker_process_handle, valid_channel));
+ EXPECT_TRUE(dispatcher_wrapper.Init(valid_channel));
#if defined(OS_POSIX)
EXPECT_EQ(0, ::close(fds[0]));
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.cc b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
index 5803ffb..c6bad77 100644
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.cc
@@ -102,8 +102,7 @@ class HostDispatcherWrapper
HostDispatcherWrapper() {}
virtual ~HostDispatcherWrapper() {}
- bool Init(base::ProcessHandle plugin_process_handle,
- const IPC::ChannelHandle& channel_handle,
+ bool Init(const IPC::ChannelHandle& channel_handle,
PP_Module pp_module,
PP_GetInterface_Func local_get_interface,
const ppapi::Preferences& preferences,
@@ -119,7 +118,7 @@ class HostDispatcherWrapper
dispatcher_delegate_.reset(new PepperProxyChannelDelegateImpl);
dispatcher_.reset(new ppapi::proxy::HostDispatcher(
- plugin_process_handle, pp_module, local_get_interface, filter));
+ pp_module, local_get_interface, filter));
if (!dispatcher_->InitHostWithChannel(dispatcher_delegate_.get(),
channel_handle,
@@ -234,11 +233,10 @@ PepperPluginDelegateImpl::CreatePepperPluginModule(
}
// Out of process: have the browser start the plugin process for us.
- base::ProcessHandle plugin_process_handle = base::kNullProcessHandle;
IPC::ChannelHandle channel_handle;
int plugin_child_id = 0;
render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin(
- path, &plugin_process_handle, &channel_handle, &plugin_child_id));
+ path, &channel_handle, &plugin_child_id));
if (channel_handle.name.empty()) {
// Couldn't be initialized.
return scoped_refptr<webkit::ppapi::PluginModule>();
@@ -256,7 +254,6 @@ PepperPluginDelegateImpl::CreatePepperPluginModule(
PepperPluginRegistry::GetInstance()->AddLiveModule(path, module);
scoped_ptr<HostDispatcherWrapper> dispatcher(new HostDispatcherWrapper);
if (!dispatcher->Init(
- plugin_process_handle,
channel_handle,
module->pp_module(),
webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc(),
@@ -296,21 +293,20 @@ scoped_refptr<PepperBrokerImpl> PepperPluginDelegateImpl::CreateBroker(
void PepperPluginDelegateImpl::OnPpapiBrokerChannelCreated(
int request_id,
- base::ProcessHandle broker_process_handle,
const IPC::ChannelHandle& handle) {
scoped_refptr<PepperBrokerImpl>* broker_ptr =
pending_connect_broker_.Lookup(request_id);
if (broker_ptr) {
scoped_refptr<PepperBrokerImpl> broker = *broker_ptr;
pending_connect_broker_.Remove(request_id);
- broker->OnBrokerChannelConnected(broker_process_handle, handle);
+ broker->OnBrokerChannelConnected(handle);
} else {
// There is no broker waiting for this channel. Close it so the broker can
// clean up and possibly exit.
// The easiest way to clean it up is to just put it in an object
// and then close them. This failure case is not performance critical.
PepperBrokerDispatcherWrapper temp_dispatcher;
- temp_dispatcher.Init(broker_process_handle, handle);
+ temp_dispatcher.Init(handle);
}
}
@@ -837,8 +833,7 @@ class AsyncOpenFileSystemURLCallbackTranslator
}
virtual void DidOpenFile(
- base::PlatformFile file,
- base::ProcessHandle unused) {
+ base::PlatformFile file) {
callback_.Run(base::PLATFORM_FILE_OK, base::PassPlatformFile(&file));
// Make sure we won't leak file handle if the requester has died.
if (file != base::kInvalidPlatformFileValue) {
diff --git a/content/renderer/pepper/pepper_plugin_delegate_impl.h b/content/renderer/pepper/pepper_plugin_delegate_impl.h
index a7ce753..1d94723 100644
--- a/content/renderer/pepper/pepper_plugin_delegate_impl.h
+++ b/content/renderer/pepper/pepper_plugin_delegate_impl.h
@@ -119,7 +119,6 @@ class PepperPluginDelegateImpl
// Called by RenderView when ViewMsg_PpapiBrokerChannelCreated.
void OnPpapiBrokerChannelCreated(int request_id,
- base::ProcessHandle broker_process_handle,
const IPC::ChannelHandle& handle);
// Removes broker from pending_connect_broker_ if present. Returns true if so.
diff --git a/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc b/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc
index 3fef0dd..e9af62c 100644
--- a/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc
+++ b/content/renderer/pepper/pepper_proxy_channel_delegate_impl.cc
@@ -5,6 +5,7 @@
#include "content/renderer/pepper/pepper_proxy_channel_delegate_impl.h"
#include "content/common/child_process.h"
+#include "content/public/common/sandbox_init.h"
namespace content {
@@ -22,4 +23,13 @@ base::WaitableEvent* PepperProxyChannelDelegateImpl::GetShutdownEvent() {
return ChildProcess::current()->GetShutDownEvent();
}
+IPC::PlatformFileForTransit
+PepperProxyChannelDelegateImpl::ShareHandleWithRemote(
+ base::PlatformFile handle,
+ const IPC::SyncChannel& channel,
+ bool should_close_source) {
+ return content::BrokerGetFileHandleForProcess(handle, channel.peer_pid(),
+ should_close_source);
+}
+
} // namespace content
diff --git a/content/renderer/pepper/pepper_proxy_channel_delegate_impl.h b/content/renderer/pepper/pepper_proxy_channel_delegate_impl.h
index 94636a6..243047b 100644
--- a/content/renderer/pepper/pepper_proxy_channel_delegate_impl.h
+++ b/content/renderer/pepper/pepper_proxy_channel_delegate_impl.h
@@ -18,6 +18,10 @@ class PepperProxyChannelDelegateImpl
// ProxyChannel::Delegate implementation.
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;
};
} // namespace content
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 821fe0b..67217f3 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -5269,10 +5269,8 @@ void RenderViewImpl::OnAsyncFileOpened(
void RenderViewImpl::OnPpapiBrokerChannelCreated(
int request_id,
- base::ProcessHandle broker_process_handle,
const IPC::ChannelHandle& handle) {
pepper_delegate_.OnPpapiBrokerChannelCreated(request_id,
- broker_process_handle,
handle);
}
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 8e5522a..470aefe 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -809,7 +809,6 @@ class RenderViewImpl : public RenderWidget,
IPC::PlatformFileForTransit file_for_transit,
int message_id);
void OnPpapiBrokerChannelCreated(int request_id,
- base::ProcessHandle broker_process_handle,
const IPC::ChannelHandle& handle);
void OnCancelDownload(int32 download_id);
void OnClearFocusedNode();
diff --git a/ppapi/proxy/broker_dispatcher.cc b/ppapi/proxy/broker_dispatcher.cc
index c3f3b47..97fca5c 100644
--- a/ppapi/proxy/broker_dispatcher.cc
+++ b/ppapi/proxy/broker_dispatcher.cc
@@ -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.
@@ -12,10 +12,8 @@
namespace ppapi {
namespace proxy {
-BrokerDispatcher::BrokerDispatcher(base::ProcessHandle remote_process_handle,
- PP_ConnectInstance_Func connect_instance)
- : ProxyChannel(remote_process_handle),
- connect_instance_(connect_instance) {
+BrokerDispatcher::BrokerDispatcher(PP_ConnectInstance_Func connect_instance)
+ : connect_instance_(connect_instance) {
}
BrokerDispatcher::~BrokerDispatcher() {
@@ -65,9 +63,8 @@ void BrokerDispatcher::OnMsgConnectToPlugin(
}
}
-BrokerHostDispatcher::BrokerHostDispatcher(
- base::ProcessHandle remote_process_handle)
- : BrokerDispatcher(remote_process_handle, NULL) {
+BrokerHostDispatcher::BrokerHostDispatcher()
+ : BrokerDispatcher(NULL) {
}
void BrokerHostDispatcher::OnChannelError() {
@@ -80,9 +77,8 @@ void BrokerHostDispatcher::OnChannelError() {
}
BrokerSideDispatcher::BrokerSideDispatcher(
- base::ProcessHandle remote_process_handle,
PP_ConnectInstance_Func connect_instance)
- : BrokerDispatcher(remote_process_handle, connect_instance) {
+ : BrokerDispatcher(connect_instance) {
}
void BrokerSideDispatcher::OnChannelError() {
diff --git a/ppapi/proxy/broker_dispatcher.h b/ppapi/proxy/broker_dispatcher.h
index f325858..5354632 100644
--- a/ppapi/proxy/broker_dispatcher.h
+++ b/ppapi/proxy/broker_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.
@@ -29,8 +29,7 @@ class PPAPI_PROXY_EXPORT BrokerDispatcher : public ProxyChannel {
protected:
// You must call InitBrokerWithChannel after the constructor.
- BrokerDispatcher(base::ProcessHandle remote_process_handle,
- PP_ConnectInstance_Func connect_instance);
+ explicit BrokerDispatcher(PP_ConnectInstance_Func connect_instance);
void OnMsgConnectToPlugin(PP_Instance instance,
IPC::PlatformFileForTransit handle,
@@ -45,7 +44,7 @@ class PPAPI_PROXY_EXPORT BrokerDispatcher : public ProxyChannel {
// The dispatcher for the browser side of the broker channel.
class PPAPI_PROXY_EXPORT BrokerHostDispatcher : public BrokerDispatcher {
public:
- BrokerHostDispatcher(base::ProcessHandle remote_process_handle);
+ BrokerHostDispatcher();
// IPC::Channel::Listener implementation.
virtual void OnChannelError() OVERRIDE;
@@ -54,8 +53,7 @@ class PPAPI_PROXY_EXPORT BrokerHostDispatcher : public BrokerDispatcher {
// The dispatcher for the broker side of the broker channel.
class PPAPI_PROXY_EXPORT BrokerSideDispatcher : public BrokerDispatcher {
public:
- BrokerSideDispatcher(base::ProcessHandle remote_process_handle,
- PP_ConnectInstance_Func connect_instance);
+ explicit BrokerSideDispatcher(PP_ConnectInstance_Func connect_instance);
// IPC::Channel::Listener implementation.
virtual void OnChannelError() OVERRIDE;
diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc
index a646643..7ecd2c1 100644
--- a/ppapi/proxy/dispatcher.cc
+++ b/ppapi/proxy/dispatcher.cc
@@ -17,10 +17,8 @@
namespace ppapi {
namespace proxy {
-Dispatcher::Dispatcher(base::ProcessHandle remote_process_handle,
- PP_GetInterface_Func local_get_interface)
- : ProxyChannel(remote_process_handle),
- disallow_trusted_interfaces_(false), // TODO(brettw) make this settable.
+Dispatcher::Dispatcher(PP_GetInterface_Func local_get_interface)
+ : disallow_trusted_interfaces_(false), // TODO(brettw) make this settable.
local_get_interface_(local_get_interface) {
}
diff --git a/ppapi/proxy/dispatcher.h b/ppapi/proxy/dispatcher.h
index f5cc468..797fa08 100644
--- a/ppapi/proxy/dispatcher.h
+++ b/ppapi/proxy/dispatcher.h
@@ -81,8 +81,7 @@ class PPAPI_PROXY_EXPORT Dispatcher : public ProxyChannel {
}
protected:
- Dispatcher(base::ProcessHandle remote_process_handle,
- PP_GetInterface_Func local_get_interface);
+ explicit Dispatcher(PP_GetInterface_Func local_get_interface);
// Setter for the derived classes to set the appropriate var serialization.
// Takes one reference of the given pointer, which must be on the heap.
diff --git a/ppapi/proxy/host_dispatcher.cc b/ppapi/proxy/host_dispatcher.cc
index 8cac0ef..f9d3471 100644
--- a/ppapi/proxy/host_dispatcher.cc
+++ b/ppapi/proxy/host_dispatcher.cc
@@ -61,11 +61,10 @@ class BoolRestorer {
} // namespace
-HostDispatcher::HostDispatcher(base::ProcessHandle remote_process_handle,
- PP_Module module,
+HostDispatcher::HostDispatcher(PP_Module module,
PP_GetInterface_Func local_get_interface,
SyncMessageStatusReceiver* sync_status)
- : Dispatcher(remote_process_handle, local_get_interface),
+ : Dispatcher(local_get_interface),
sync_status_(sync_status),
pp_module_(module),
ppb_proxy_(NULL),
diff --git a/ppapi/proxy/host_dispatcher.h b/ppapi/proxy/host_dispatcher.h
index e7b5135..b43d305 100644
--- a/ppapi/proxy/host_dispatcher.h
+++ b/ppapi/proxy/host_dispatcher.h
@@ -47,8 +47,7 @@ class PPAPI_PROXY_EXPORT HostDispatcher : public Dispatcher {
// SyncMessageStatusReceiver.
//
// You must call InitHostWithChannel after the constructor.
- HostDispatcher(base::ProcessHandle host_process_handle,
- PP_Module module,
+ HostDispatcher(PP_Module module,
PP_GetInterface_Func local_get_interface,
SyncMessageStatusReceiver* sync_status);
~HostDispatcher();
diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc
index 1e3fc25..ad8c620 100644
--- a/ppapi/proxy/plugin_dispatcher.cc
+++ b/ppapi/proxy/plugin_dispatcher.cc
@@ -58,10 +58,9 @@ InstanceData::~InstanceData() {
}
}
-PluginDispatcher::PluginDispatcher(base::ProcessHandle remote_process_handle,
- PP_GetInterface_Func get_interface,
+PluginDispatcher::PluginDispatcher(PP_GetInterface_Func get_interface,
bool incognito)
- : Dispatcher(remote_process_handle, get_interface),
+ : Dispatcher(get_interface),
plugin_delegate_(NULL),
received_preferences_(false),
plugin_dispatcher_id_(0),
diff --git a/ppapi/proxy/plugin_dispatcher.h b/ppapi/proxy/plugin_dispatcher.h
index 3e43bf2..5d344e7 100644
--- a/ppapi/proxy/plugin_dispatcher.h
+++ b/ppapi/proxy/plugin_dispatcher.h
@@ -70,8 +70,7 @@ class PPAPI_PROXY_EXPORT PluginDispatcher
// module ID will be set upon receipt of the InitializeModule message.
//
// You must call InitPluginWithChannel after the constructor.
- PluginDispatcher(base::ProcessHandle remote_process_handle,
- PP_GetInterface_Func get_interface,
+ PluginDispatcher(PP_GetInterface_Func get_interface,
bool incognito);
virtual ~PluginDispatcher();
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index b40d9a8..493352d6 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -209,8 +209,7 @@ IPC_MESSAGE_CONTROL1(PpapiMsg_LoadPlugin, FilePath /* path */)
// Creates a channel to talk to a renderer. The plugin will respond with
// PpapiHostMsg_ChannelCreated.
-IPC_MESSAGE_CONTROL3(PpapiMsg_CreateChannel,
- base::ProcessHandle /* host_process_handle */,
+IPC_MESSAGE_CONTROL2(PpapiMsg_CreateChannel,
int /* renderer_id */,
bool /* incognito */)
diff --git a/ppapi/proxy/ppapi_proxy_test.cc b/ppapi/proxy/ppapi_proxy_test.cc
index e1fb6e7..445f84b 100644
--- a/ppapi/proxy/ppapi_proxy_test.cc
+++ b/ppapi/proxy/ppapi_proxy_test.cc
@@ -157,7 +157,6 @@ void PluginProxyTestHarness::SetUpHarness() {
resource_tracker().DidCreateInstance(pp_instance());
plugin_dispatcher_.reset(new PluginDispatcher(
- base::Process::Current().handle(),
&MockGetInterface,
false));
plugin_dispatcher_->InitWithTestSink(&sink());
@@ -175,7 +174,6 @@ void PluginProxyTestHarness::SetUpHarnessWithChannel(
plugin_delegate_mock_.Init(ipc_message_loop, shutdown_event);
plugin_dispatcher_.reset(new PluginDispatcher(
- base::Process::Current().handle(),
&MockGetInterface,
false));
plugin_dispatcher_->InitPluginWithChannel(&plugin_delegate_mock_,
@@ -201,6 +199,16 @@ PluginProxyTestHarness::PluginDelegateMock::GetShutdownEvent() {
return shutdown_event_;
}
+IPC::PlatformFileForTransit
+PluginProxyTestHarness::PluginDelegateMock::ShareHandleWithRemote(
+ base::PlatformFile handle,
+ const IPC::SyncChannel& /* channel */,
+ bool should_close_source) {
+ return IPC::GetFileHandleForProcess(handle,
+ base::Process::Current().handle(),
+ should_close_source);
+}
+
std::set<PP_Instance>*
PluginProxyTestHarness::PluginDelegateMock::GetGloballySeenInstanceIDSet() {
return &instance_id_set_;
@@ -266,7 +274,6 @@ void HostProxyTestHarness::SetUpHarness() {
// These must be first since the dispatcher set-up uses them.
PpapiGlobals::SetPpapiGlobalsOnThreadForTest(GetGlobals());
host_dispatcher_.reset(new HostDispatcher(
- base::Process::Current().handle(),
pp_module(),
&MockGetInterface,
status_receiver_.get()));
@@ -284,7 +291,6 @@ void HostProxyTestHarness::SetUpHarnessWithChannel(
delegate_mock_.Init(ipc_message_loop, shutdown_event);
host_dispatcher_.reset(new HostDispatcher(
- base::Process::Current().handle(),
pp_module(),
&MockGetInterface,
status_receiver_.get()));
@@ -308,6 +314,16 @@ base::WaitableEvent* HostProxyTestHarness::DelegateMock::GetShutdownEvent() {
return shutdown_event_;
}
+IPC::PlatformFileForTransit
+HostProxyTestHarness::DelegateMock::ShareHandleWithRemote(
+ base::PlatformFile handle,
+ const IPC::SyncChannel& /* channel */,
+ bool should_close_source) {
+ return IPC::GetFileHandleForProcess(handle,
+ base::Process::Current().handle(),
+ should_close_source);
+}
+
// HostProxyTest ---------------------------------------------------------------
diff --git a/ppapi/proxy/ppapi_proxy_test.h b/ppapi/proxy/ppapi_proxy_test.h
index b2a3f36..59a5671 100644
--- a/ppapi/proxy/ppapi_proxy_test.h
+++ b/ppapi/proxy/ppapi_proxy_test.h
@@ -114,6 +114,10 @@ class PluginProxyTestHarness : public ProxyTestHarnessBase {
// ProxyChannel::Delegate implementation.
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;
// PluginDispatcher::PluginDelegate implementation.
virtual std::set<PP_Instance>* GetGloballySeenInstanceIDSet() OVERRIDE;
@@ -189,6 +193,10 @@ class HostProxyTestHarness : public ProxyTestHarnessBase {
// ProxyChannel::Delegate implementation.
virtual base::MessageLoopProxy* GetIPCMessageLoop();
virtual base::WaitableEvent* GetShutdownEvent();
+ virtual IPC::PlatformFileForTransit ShareHandleWithRemote(
+ base::PlatformFile handle,
+ const IPC::SyncChannel& /* channel */,
+ bool should_close_source) OVERRIDE;
private:
base::MessageLoopProxy* ipc_message_loop_; // Weak
diff --git a/ppapi/proxy/proxy_channel.cc b/ppapi/proxy/proxy_channel.cc
index fd5937f..c67d83c 100644
--- a/ppapi/proxy/proxy_channel.cc
+++ b/ppapi/proxy/proxy_channel.cc
@@ -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.
@@ -10,9 +10,8 @@
namespace ppapi {
namespace proxy {
-ProxyChannel::ProxyChannel(base::ProcessHandle remote_process_handle)
+ProxyChannel::ProxyChannel()
: delegate_(NULL),
- remote_process_handle_(remote_process_handle),
test_sink_(NULL) {
}
@@ -51,8 +50,8 @@ int ProxyChannel::TakeRendererFD() {
IPC::PlatformFileForTransit ProxyChannel::ShareHandleWithRemote(
base::PlatformFile handle,
bool should_close_source) {
- return IPC::GetFileHandleForProcess(handle, remote_process_handle_,
- should_close_source);
+ return delegate_->ShareHandleWithRemote(handle, *channel_,
+ should_close_source);
}
bool ProxyChannel::Send(IPC::Message* msg) {
diff --git a/ppapi/proxy/proxy_channel.h b/ppapi/proxy/proxy_channel.h
index f32d470..424da94 100644
--- a/ppapi/proxy/proxy_channel.h
+++ b/ppapi/proxy/proxy_channel.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.
@@ -38,6 +38,16 @@ class PPAPI_PROXY_EXPORT ProxyChannel
// Returns the event object that becomes signalled when the main thread's
// message loop exits.
virtual base::WaitableEvent* GetShutdownEvent() = 0;
+
+ // Duplicates a handle to the provided object, returning one that is valid
+ // on the other side of the channel. This is part of the delegate interface
+ // because both sides of the channel may not have sufficient permission to
+ // duplicate handles directly. The implementation must provide the same
+ // guarantees as ProxyChannel::ShareHandleWithRemote below.
+ virtual IPC::PlatformFileForTransit ShareHandleWithRemote(
+ base::PlatformFile handle,
+ const IPC::SyncChannel& channel,
+ bool should_close_source) = 0;
};
virtual ~ProxyChannel();
@@ -73,7 +83,7 @@ class PPAPI_PROXY_EXPORT ProxyChannel
#endif
protected:
- explicit ProxyChannel(base::ProcessHandle remote_process_handle);
+ explicit ProxyChannel();
// You must call this function before anything else. Returns true on success.
// The delegate pointer must outlive this class, ownership is not
@@ -90,8 +100,6 @@ class PPAPI_PROXY_EXPORT ProxyChannel
// Non-owning pointer. Guaranteed non-NULL after init is called.
ProxyChannel::Delegate* delegate_;
- base::ProcessHandle remote_process_handle_; // See getter above.
-
// When we're unit testing, this will indicate the sink for the messages to
// be deposited so they can be inspected by the test. When non-NULL, this
// indicates that the channel should not be used.
diff --git a/webkit/fileapi/file_system_callback_dispatcher.cc b/webkit/fileapi/file_system_callback_dispatcher.cc
index 08fdf55..5317bb8 100644
--- a/webkit/fileapi/file_system_callback_dispatcher.cc
+++ b/webkit/fileapi/file_system_callback_dispatcher.cc
@@ -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.
@@ -12,8 +12,7 @@ FileSystemCallbackDispatcher::~FileSystemCallbackDispatcher() {
}
void FileSystemCallbackDispatcher::DidOpenFile(
- base::PlatformFile file,
- base::ProcessHandle peer_handle) {
+ base::PlatformFile file) {
NOTREACHED();
if (file != base::kInvalidPlatformFileValue)
diff --git a/webkit/fileapi/file_system_callback_dispatcher.h b/webkit/fileapi/file_system_callback_dispatcher.h
index 9d18f9d..a41c8df 100644
--- a/webkit/fileapi/file_system_callback_dispatcher.h
+++ b/webkit/fileapi/file_system_callback_dispatcher.h
@@ -58,8 +58,7 @@ class FileSystemCallbackDispatcher {
// for Pepper.
// The method will be responsible for closing |file|.
virtual void DidOpenFile(
- base::PlatformFile file,
- base::ProcessHandle peer_handle);
+ base::PlatformFile file);
};
} // namespace fileapi