summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 17:17:21 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 17:17:21 +0000
commit5d84d01d904a2e5fa3e17b8d9165e63a20351160 (patch)
treedd87a4d94ed6276dc1551cbc5d3c744eb268cebd /chrome
parent9a80065bad1506ac11163d597ace3295ddbfa8cb (diff)
downloadchromium_src-5d84d01d904a2e5fa3e17b8d9165e63a20351160.zip
chromium_src-5d84d01d904a2e5fa3e17b8d9165e63a20351160.tar.gz
chromium_src-5d84d01d904a2e5fa3e17b8d9165e63a20351160.tar.bz2
Implement audio proxy for Pepper.
In addition to the basic proxying, this required some changes to the dispatcher and process infrastructure to get the handles of the processes available when I need them so I can duplicate the shared memory handles properly into the different processes. TEST=none BUG=none Review URL: http://codereview.chromium.org/4985001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68026 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_child_process_host.cc8
-rw-r--r--chrome/browser/browser_child_process_host.h4
-rw-r--r--chrome/browser/ppapi_plugin_process_host.cc42
-rw-r--r--chrome/browser/ppapi_plugin_process_host.h3
-rw-r--r--chrome/common/render_messages_internal.h5
-rw-r--r--chrome/ppapi_plugin/ppapi_thread.cc13
-rw-r--r--chrome/ppapi_plugin/ppapi_thread.h8
-rw-r--r--chrome/renderer/pepper_plugin_delegate_impl.cc4
8 files changed, 67 insertions, 20 deletions
diff --git a/chrome/browser/browser_child_process_host.cc b/chrome/browser/browser_child_process_host.cc
index a317f26..5cfd536 100644
--- a/chrome/browser/browser_child_process_host.cc
+++ b/chrome/browser/browser_child_process_host.cc
@@ -117,6 +117,14 @@ void BrowserChildProcessHost::Launch(
&client_));
}
+base::ProcessHandle BrowserChildProcessHost::GetChildProcessHandle() const {
+ DCHECK(child_process_.get())
+ << "Requesting a child process handle before launching.";
+ DCHECK(child_process_->GetHandle())
+ << "Requesting a child process handle before launch has completed OK.";
+ return child_process_->GetHandle();
+}
+
bool BrowserChildProcessHost::Send(IPC::Message* msg) {
return SendOnChannel(msg);
}
diff --git a/chrome/browser/browser_child_process_host.h b/chrome/browser/browser_child_process_host.h
index cf30973..f70c035 100644
--- a/chrome/browser/browser_child_process_host.h
+++ b/chrome/browser/browser_child_process_host.h
@@ -73,6 +73,10 @@ class BrowserChildProcessHost : public ResourceDispatcherHost::Receiver,
#endif
CommandLine* cmd_line);
+ // Returns the handle of the child process. This must be called only after
+ // OnProcessLaunched is called or it will be invalid and may crash.
+ base::ProcessHandle GetChildProcessHandle() const;
+
// ChildProcessLauncher::Client implementation.
virtual void OnProcessLaunched() { }
diff --git a/chrome/browser/ppapi_plugin_process_host.cc b/chrome/browser/ppapi_plugin_process_host.cc
index ba47b86..ded8964 100644
--- a/chrome/browser/ppapi_plugin_process_host.cc
+++ b/chrome/browser/ppapi_plugin_process_host.cc
@@ -29,7 +29,7 @@ void PpapiPluginProcessHost::Init(const FilePath& path,
reply_msg_.reset(reply_msg);
if (!CreateChannel()) {
- ReplyToRenderer(IPC::ChannelHandle());
+ ReplyToRenderer(NULL, IPC::ChannelHandle());
return;
}
@@ -39,7 +39,7 @@ void PpapiPluginProcessHost::Init(const FilePath& path,
FilePath exe_path = ChildProcessHost::GetChildPath(plugin_launcher.empty());
if (exe_path.empty()) {
- ReplyToRenderer(IPC::ChannelHandle());
+ ReplyToRenderer(NULL, IPC::ChannelHandle());
return;
}
@@ -80,25 +80,49 @@ void PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
}
void PpapiPluginProcessHost::OnChannelConnected(int32 peer_pid) {
- PpapiMsg_LoadPlugin* msg = new PpapiMsg_LoadPlugin(plugin_path_,
+#if defined(OS_WIN)
+ base::ProcessHandle plugins_renderer_handle = NULL;
+ ::DuplicateHandle(::GetCurrentProcess(), filter_->handle(),
+ GetChildProcessHandle(), &plugins_renderer_handle,
+ 0, FALSE, DUPLICATE_SAME_ACCESS);
+#elif defined(OS_POSIX)
+ base::ProcessHandle plugins_renderer_handle = filter_->handle();
+#endif
+
+ PpapiMsg_LoadPlugin* msg = new PpapiMsg_LoadPlugin(plugins_renderer_handle,
+ plugin_path_,
filter_->id());
if (!Send(msg)) // Just send an empty handle on failure.
- ReplyToRenderer(IPC::ChannelHandle());
+ ReplyToRenderer(NULL, IPC::ChannelHandle());
// This function will result in OnChannelCreated getting called to finish.
}
void PpapiPluginProcessHost::OnChannelError() {
if (reply_msg_.get())
- ReplyToRenderer(IPC::ChannelHandle());
+ ReplyToRenderer(NULL, IPC::ChannelHandle());
}
-void PpapiPluginProcessHost::OnPluginLoaded(const IPC::ChannelHandle& handle) {
- ReplyToRenderer(handle);
+void PpapiPluginProcessHost::OnPluginLoaded(
+ const IPC::ChannelHandle& channel_handle) {
+ base::ProcessHandle plugin_process = GetChildProcessHandle();
+#if defined(OS_WIN)
+ base::ProcessHandle renderers_plugin_handle = NULL;
+ ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
+ filter_->handle(), &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
+ ReplyToRenderer(renderers_plugin_handle, channel_handle);
}
-void PpapiPluginProcessHost::ReplyToRenderer(const IPC::ChannelHandle& handle) {
+void PpapiPluginProcessHost::ReplyToRenderer(
+ base::ProcessHandle plugin_handle,
+ const IPC::ChannelHandle& channel_handle) {
DCHECK(reply_msg_.get());
ViewHostMsg_OpenChannelToPepperPlugin::WriteReplyParams(reply_msg_.get(),
- handle);
+ plugin_handle,
+ channel_handle);
filter_->Send(reply_msg_.release());
}
diff --git a/chrome/browser/ppapi_plugin_process_host.h b/chrome/browser/ppapi_plugin_process_host.h
index 956148c..dd71b14 100644
--- a/chrome/browser/ppapi_plugin_process_host.h
+++ b/chrome/browser/ppapi_plugin_process_host.h
@@ -39,7 +39,8 @@ class PpapiPluginProcessHost : public BrowserChildProcessHost {
void OnPluginLoaded(const IPC::ChannelHandle& handle);
// Sends the reply_msg_ to the renderer with the given channel info.
- void ReplyToRenderer(const IPC::ChannelHandle& handle);
+ void ReplyToRenderer(base::ProcessHandle plugin_handle,
+ const IPC::ChannelHandle& channel_handle);
ResourceMessageFilter* filter_;
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 34b5bf0..cf9e44f 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1579,15 +1579,16 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_SYNC_MESSAGE_CONTROL2_2(ViewHostMsg_OpenChannelToPlugin,
GURL /* url */,
std::string /* mime_type */,
- IPC::ChannelHandle /* handle to channel */,
+ IPC::ChannelHandle /* channel_handle */,
WebPluginInfo /* info */)
// A renderer sends this to the browser process when it wants to
// create a pepper plugin. The browser will create the plugin process if
// necessary, and will return a handle to the channel on success.
// On error an empty string is returned.
- IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_OpenChannelToPepperPlugin,
+ IPC_SYNC_MESSAGE_CONTROL1_2(ViewHostMsg_OpenChannelToPepperPlugin,
FilePath /* path */,
+ base::ProcessHandle /* plugin_process_handle */,
IPC::ChannelHandle /* handle to channel */)
// A renderer sends this to the browser process when it wants to
diff --git a/chrome/ppapi_plugin/ppapi_thread.cc b/chrome/ppapi_plugin/ppapi_thread.cc
index 36ea9f6..8c4da88 100644
--- a/chrome/ppapi_plugin/ppapi_thread.cc
+++ b/chrome/ppapi_plugin/ppapi_thread.cc
@@ -47,9 +47,11 @@ void PpapiThread::OnMessageReceived(const IPC::Message& msg) {
IPC_END_MESSAGE_MAP()
}
-void PpapiThread::OnLoadPlugin(const FilePath& path, int renderer_id) {
+void PpapiThread::OnLoadPlugin(base::ProcessHandle host_process_handle,
+ const FilePath& path,
+ int renderer_id) {
IPC::ChannelHandle channel_handle;
- if (!LoadPluginLib(path) ||
+ if (!LoadPluginLib(host_process_handle, path) ||
!SetupRendererChannel(renderer_id, &channel_handle)) {
// An empty channel handle indicates error.
Send(new PpapiHostMsg_PluginLoaded(IPC::ChannelHandle()));
@@ -59,7 +61,8 @@ void PpapiThread::OnLoadPlugin(const FilePath& path, int renderer_id) {
Send(new PpapiHostMsg_PluginLoaded(channel_handle));
}
-bool PpapiThread::LoadPluginLib(const FilePath& path) {
+bool PpapiThread::LoadPluginLib(base::ProcessHandle host_process_handle,
+ const FilePath& path) {
base::ScopedNativeLibrary library(base::LoadNativeLibrary(path));
if (!library.is_valid())
return false;
@@ -88,8 +91,8 @@ bool PpapiThread::LoadPluginLib(const FilePath& path) {
library.GetFunctionPointer("PPP_ShutdownModule"));
library_.Reset(library.Release());
- dispatcher_.reset(new pp::proxy::PluginDispatcher(get_interface, init_module,
- shutdown_module));
+ dispatcher_.reset(new pp::proxy::PluginDispatcher(
+ host_process_handle, get_interface, init_module, shutdown_module));
pp::proxy::PluginDispatcher::SetGlobal(dispatcher_.get());
return true;
}
diff --git a/chrome/ppapi_plugin/ppapi_thread.h b/chrome/ppapi_plugin/ppapi_thread.h
index ed7b024..cf49c8b 100644
--- a/chrome/ppapi_plugin/ppapi_thread.h
+++ b/chrome/ppapi_plugin/ppapi_thread.h
@@ -7,6 +7,7 @@
#pragma once
#include "base/basictypes.h"
+#include "base/process.h"
#include "base/scoped_native_library.h"
#include "base/scoped_ptr.h"
#include "build/build_config.h"
@@ -34,9 +35,12 @@ class PpapiThread : public ChildThread {
virtual void OnMessageReceived(const IPC::Message& msg);
// Message handlers.
- void OnLoadPlugin(const FilePath& path, int renderer_id);
+ void OnLoadPlugin(base::ProcessHandle renderer_handle,
+ const FilePath& path,
+ int renderer_id);
- bool LoadPluginLib(const FilePath& path);
+ bool LoadPluginLib(base::ProcessHandle host_process_handle,
+ const FilePath& path);
// Sets up the channel to the given renderer. On success, returns true and
// fills the given ChannelHandle with the information from the new channel.
diff --git a/chrome/renderer/pepper_plugin_delegate_impl.cc b/chrome/renderer/pepper_plugin_delegate_impl.cc
index 3cf9183..c3a85d9 100644
--- a/chrome/renderer/pepper_plugin_delegate_impl.cc
+++ b/chrome/renderer/pepper_plugin_delegate_impl.cc
@@ -426,13 +426,15 @@ PepperPluginDelegateImpl::~PepperPluginDelegateImpl() {
scoped_refptr<pepper::PluginModule>
PepperPluginDelegateImpl::CreateOutOfProcessPepperPlugin(
const FilePath& path) {
+ base::ProcessHandle plugin_process_handle = NULL;
IPC::ChannelHandle channel_handle;
render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin(
- path, &channel_handle));
+ path, &plugin_process_handle, &channel_handle));
if (channel_handle.name.empty())
return scoped_refptr<pepper::PluginModule>(); // Couldn't be initialized.
return pepper::PluginModule::CreateOutOfProcessModule(
ChildProcess::current()->io_message_loop(),
+ plugin_process_handle,
channel_handle,
ChildProcess::current()->GetShutDownEvent());
}