OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/nacl/nacl_listener.h" | 5 #include "chrome/nacl/nacl_listener.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } else { | 165 } else { |
166 // This thread does not own the channel. | 166 // This thread does not own the channel. |
167 return filter_->Send(msg); | 167 return filter_->Send(msg); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 void NaClListener::Listen() { | 171 void NaClListener::Listen() { |
172 std::string channel_name = | 172 std::string channel_name = |
173 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 173 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
174 switches::kProcessChannelID); | 174 switches::kProcessChannelID); |
175 channel_.reset(new IPC::SyncChannel(this, io_thread_.message_loop_proxy(), | 175 channel_.reset( |
176 &shutdown_event_)); | 176 new IPC::SyncChannel(this, io_thread_.message_loop_proxy().get(), |
| 177 &shutdown_event_)); |
177 filter_ = new IPC::SyncMessageFilter(&shutdown_event_); | 178 filter_ = new IPC::SyncMessageFilter(&shutdown_event_); |
178 channel_->AddFilter(filter_.get()); | 179 channel_->AddFilter(filter_.get()); |
179 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); | 180 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); |
180 main_loop_ = MessageLoop::current(); | 181 main_loop_ = MessageLoop::current(); |
181 main_loop_->Run(); | 182 main_loop_->Run(); |
182 } | 183 } |
183 | 184 |
184 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { | 185 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { |
185 bool handled = true; | 186 bool handled = true; |
186 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) | 187 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) |
(...skipping 10 matching lines...) Expand all Loading... |
197 return; | 198 return; |
198 } | 199 } |
199 | 200 |
200 if (params.enable_ipc_proxy) { | 201 if (params.enable_ipc_proxy) { |
201 // Create the initial PPAPI IPC channel between the NaCl IRT and the | 202 // Create the initial PPAPI IPC channel between the NaCl IRT and the |
202 // browser process. The IRT uses this channel to communicate with the | 203 // browser process. The IRT uses this channel to communicate with the |
203 // browser and to create additional IPC channels to renderer processes. | 204 // browser and to create additional IPC channels to renderer processes. |
204 IPC::ChannelHandle handle = | 205 IPC::ChannelHandle handle = |
205 IPC::Channel::GenerateVerifiedChannelID("nacl"); | 206 IPC::Channel::GenerateVerifiedChannelID("nacl"); |
206 scoped_refptr<NaClIPCAdapter> ipc_adapter( | 207 scoped_refptr<NaClIPCAdapter> ipc_adapter( |
207 new NaClIPCAdapter(handle, io_thread_.message_loop_proxy())); | 208 new NaClIPCAdapter(handle, io_thread_.message_loop_proxy().get())); |
208 // Pass a NaClDesc to the untrusted side. This will hold a ref to the | 209 // Pass a NaClDesc to the untrusted side. This will hold a ref to the |
209 // NaClIPCAdapter. | 210 // NaClIPCAdapter. |
210 args->initial_ipc_desc = ipc_adapter->MakeNaClDesc(); | 211 args->initial_ipc_desc = ipc_adapter->MakeNaClDesc(); |
211 #if defined(OS_POSIX) | 212 #if defined(OS_POSIX) |
212 handle.socket = base::FileDescriptor( | 213 handle.socket = base::FileDescriptor( |
213 ipc_adapter->TakeClientFileDescriptor(), true); | 214 ipc_adapter->TakeClientFileDescriptor(), true); |
214 #endif | 215 #endif |
215 if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(handle))) | 216 if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(handle))) |
216 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; | 217 LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost."; |
217 } | 218 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 #if defined(OS_WIN) | 268 #if defined(OS_WIN) |
268 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 269 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
269 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 270 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
270 #endif | 271 #endif |
271 #if defined(OS_LINUX) | 272 #if defined(OS_LINUX) |
272 args->prereserved_sandbox_size = prereserved_sandbox_size_; | 273 args->prereserved_sandbox_size = prereserved_sandbox_size_; |
273 #endif | 274 #endif |
274 NaClChromeMainStart(args); | 275 NaClChromeMainStart(args); |
275 NOTREACHED(); | 276 NOTREACHED(); |
276 } | 277 } |
OLD | NEW |