diff options
Diffstat (limited to 'content')
25 files changed, 147 insertions, 99 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(); |