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

Side by Side Diff: chrome/browser/ppapi_plugin_process_host.cc

Issue 4985001: Initial audio implementation. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ppapi_plugin_process_host.h ('k') | chrome/common/render_messages_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ppapi_plugin_process_host.h" 5 #include "chrome/browser/ppapi_plugin_process_host.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "chrome/browser/renderer_host/resource_message_filter.h" 10 #include "chrome/browser/renderer_host/resource_message_filter.h"
(...skipping 11 matching lines...) Expand all
22 22
23 PpapiPluginProcessHost::~PpapiPluginProcessHost() { 23 PpapiPluginProcessHost::~PpapiPluginProcessHost() {
24 } 24 }
25 25
26 void PpapiPluginProcessHost::Init(const FilePath& path, 26 void PpapiPluginProcessHost::Init(const FilePath& path,
27 IPC::Message* reply_msg) { 27 IPC::Message* reply_msg) {
28 plugin_path_ = path; 28 plugin_path_ = path;
29 reply_msg_.reset(reply_msg); 29 reply_msg_.reset(reply_msg);
30 30
31 if (!CreateChannel()) { 31 if (!CreateChannel()) {
32 ReplyToRenderer(IPC::ChannelHandle()); 32 ReplyToRenderer(NULL, IPC::ChannelHandle());
33 return; 33 return;
34 } 34 }
35 35
36 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 36 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
37 CommandLine::StringType plugin_launcher = 37 CommandLine::StringType plugin_launcher =
38 browser_command_line.GetSwitchValueNative(switches::kPpapiPluginLauncher); 38 browser_command_line.GetSwitchValueNative(switches::kPpapiPluginLauncher);
39 39
40 FilePath exe_path = ChildProcessHost::GetChildPath(plugin_launcher.empty()); 40 FilePath exe_path = ChildProcessHost::GetChildPath(plugin_launcher.empty());
41 if (exe_path.empty()) { 41 if (exe_path.empty()) {
42 ReplyToRenderer(IPC::ChannelHandle()); 42 ReplyToRenderer(NULL, IPC::ChannelHandle());
43 return; 43 return;
44 } 44 }
45 45
46 CommandLine* cmd_line = new CommandLine(exe_path); 46 CommandLine* cmd_line = new CommandLine(exe_path);
47 cmd_line->AppendSwitchASCII(switches::kProcessType, 47 cmd_line->AppendSwitchASCII(switches::kProcessType,
48 switches::kPpapiPluginProcess); 48 switches::kPpapiPluginProcess);
49 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id()); 49 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id());
50 50
51 if (!plugin_launcher.empty()) 51 if (!plugin_launcher.empty())
52 cmd_line->PrependWrapper(plugin_launcher); 52 cmd_line->PrependWrapper(plugin_launcher);
(...skipping 19 matching lines...) Expand all
72 return NULL; 72 return NULL;
73 } 73 }
74 74
75 void PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { 75 void PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) {
76 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) 76 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg)
77 IPC_MESSAGE_HANDLER(PpapiHostMsg_PluginLoaded, OnPluginLoaded) 77 IPC_MESSAGE_HANDLER(PpapiHostMsg_PluginLoaded, OnPluginLoaded)
78 IPC_MESSAGE_UNHANDLED_ERROR(); 78 IPC_MESSAGE_UNHANDLED_ERROR();
79 IPC_END_MESSAGE_MAP() 79 IPC_END_MESSAGE_MAP()
80 } 80 }
81 81
82 void PpapiPluginProcessHost::OnChannelConnected(int32 peer_pid) { 82 void PpapiPluginProcessHost::OnChannelConnected(int32 peer_pid) {
brettw 2010/12/01 00:23:05 The changes in this component are to support sendi
83 PpapiMsg_LoadPlugin* msg = new PpapiMsg_LoadPlugin(plugin_path_, 83 #if defined(OS_WIN)
84 base::ProcessHandle plugins_renderer_handle = NULL;
85 ::DuplicateHandle(::GetCurrentProcess(), filter_->handle(),
86 GetChildProcessHandle(), &plugins_renderer_handle,
87 0, FALSE, DUPLICATE_SAME_ACCESS);
88 #elif defined(OS_POSIX)
89 base::ProcessHandle plugins_renderer_handle = filter_->handle();
90 #endif
91
92 PpapiMsg_LoadPlugin* msg = new PpapiMsg_LoadPlugin(plugins_renderer_handle,
93 plugin_path_,
84 filter_->id()); 94 filter_->id());
85 if (!Send(msg)) // Just send an empty handle on failure. 95 if (!Send(msg)) // Just send an empty handle on failure.
86 ReplyToRenderer(IPC::ChannelHandle()); 96 ReplyToRenderer(NULL, IPC::ChannelHandle());
87 // This function will result in OnChannelCreated getting called to finish. 97 // This function will result in OnChannelCreated getting called to finish.
88 } 98 }
89 99
90 void PpapiPluginProcessHost::OnChannelError() { 100 void PpapiPluginProcessHost::OnChannelError() {
91 if (reply_msg_.get()) 101 if (reply_msg_.get())
92 ReplyToRenderer(IPC::ChannelHandle()); 102 ReplyToRenderer(NULL, IPC::ChannelHandle());
93 } 103 }
94 104
95 void PpapiPluginProcessHost::OnPluginLoaded(const IPC::ChannelHandle& handle) { 105 void PpapiPluginProcessHost::OnPluginLoaded(
96 ReplyToRenderer(handle); 106 const IPC::ChannelHandle& channel_handle) {
107 base::ProcessHandle plugin_process = GetChildProcessHandle();
108 #if defined(OS_WIN)
109 base::ProcessHandle renderers_plugin_handle = NULL;
110 ::DuplicateHandle(::GetCurrentProcess(), plugin_process,
111 filter_->handle(), &renderers_plugin_handle,
112 0, FALSE, DUPLICATE_SAME_ACCESS);
113 #elif defined(OS_POSIX)
114 // Don't need to duplicate anything on POSIX since it's just a PID.
115 base::ProcessHandle renderers_plugin_handle = plugin_process;
116 #endif
117 ReplyToRenderer(renderers_plugin_handle, channel_handle);
97 } 118 }
98 119
99 void PpapiPluginProcessHost::ReplyToRenderer(const IPC::ChannelHandle& handle) { 120 void PpapiPluginProcessHost::ReplyToRenderer(
121 base::ProcessHandle plugin_handle,
122 const IPC::ChannelHandle& channel_handle) {
100 DCHECK(reply_msg_.get()); 123 DCHECK(reply_msg_.get());
101 ViewHostMsg_OpenChannelToPepperPlugin::WriteReplyParams(reply_msg_.get(), 124 ViewHostMsg_OpenChannelToPepperPlugin::WriteReplyParams(reply_msg_.get(),
102 handle); 125 plugin_handle,
126 channel_handle);
103 filter_->Send(reply_msg_.release()); 127 filter_->Send(reply_msg_.release());
104 } 128 }
OLDNEW
« no previous file with comments | « chrome/browser/ppapi_plugin_process_host.h ('k') | chrome/common/render_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698