summaryrefslogtreecommitdiffstats
path: root/chrome/browser
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/browser
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/browser')
-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
4 files changed, 47 insertions, 10 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_;