| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } else { | 199 } else { |
| 200 // This thread does not own the channel. | 200 // This thread does not own the channel. |
| 201 return filter_->Send(msg); | 201 return filter_->Send(msg); |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 void NaClListener::Listen() { | 205 void NaClListener::Listen() { |
| 206 std::string channel_name = | 206 std::string channel_name = |
| 207 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 207 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 208 switches::kProcessChannelID); | 208 switches::kProcessChannelID); |
| 209 channel_.reset(new IPC::SyncChannel(this, io_thread_.message_loop_proxy(), | 209 channel_.reset(new IPC::SyncChannel( |
| 210 &shutdown_event_)); | 210 this, io_thread_.message_loop_proxy().get(), &shutdown_event_)); |
| 211 filter_ = new IPC::SyncMessageFilter(&shutdown_event_); | 211 filter_ = new IPC::SyncMessageFilter(&shutdown_event_); |
| 212 channel_->AddFilter(filter_.get()); | 212 channel_->AddFilter(filter_.get()); |
| 213 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); | 213 channel_->Init(channel_name, IPC::Channel::MODE_CLIENT, true); |
| 214 main_loop_ = base::MessageLoop::current(); | 214 main_loop_ = base::MessageLoop::current(); |
| 215 main_loop_->Run(); | 215 main_loop_->Run(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { | 218 bool NaClListener::OnMessageReceived(const IPC::Message& msg) { |
| 219 bool handled = true; | 219 bool handled = true; |
| 220 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) | 220 IPC_BEGIN_MESSAGE_MAP(NaClListener, msg) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 231 return; | 231 return; |
| 232 } | 232 } |
| 233 | 233 |
| 234 if (params.enable_ipc_proxy) { | 234 if (params.enable_ipc_proxy) { |
| 235 // Create the initial PPAPI IPC channel between the NaCl IRT and the | 235 // Create the initial PPAPI IPC channel between the NaCl IRT and the |
| 236 // browser process. The IRT uses this channel to communicate with the | 236 // browser process. The IRT uses this channel to communicate with the |
| 237 // browser and to create additional IPC channels to renderer processes. | 237 // browser and to create additional IPC channels to renderer processes. |
| 238 IPC::ChannelHandle handle = | 238 IPC::ChannelHandle handle = |
| 239 IPC::Channel::GenerateVerifiedChannelID("nacl"); | 239 IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 240 scoped_refptr<NaClIPCAdapter> ipc_adapter( | 240 scoped_refptr<NaClIPCAdapter> ipc_adapter( |
| 241 new NaClIPCAdapter(handle, io_thread_.message_loop_proxy())); | 241 new NaClIPCAdapter(handle, io_thread_.message_loop_proxy().get())); |
| 242 ipc_adapter->ConnectChannel(); | 242 ipc_adapter->ConnectChannel(); |
| 243 | 243 |
| 244 // Pass a NaClDesc to the untrusted side. This will hold a ref to the | 244 // Pass a NaClDesc to the untrusted side. This will hold a ref to the |
| 245 // NaClIPCAdapter. | 245 // NaClIPCAdapter. |
| 246 args->initial_ipc_desc = ipc_adapter->MakeNaClDesc(); | 246 args->initial_ipc_desc = ipc_adapter->MakeNaClDesc(); |
| 247 #if defined(OS_POSIX) | 247 #if defined(OS_POSIX) |
| 248 handle.socket = base::FileDescriptor( | 248 handle.socket = base::FileDescriptor( |
| 249 ipc_adapter->TakeClientFileDescriptor(), true); | 249 ipc_adapter->TakeClientFileDescriptor(), true); |
| 250 #endif | 250 #endif |
| 251 if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(handle))) | 251 if (!Send(new NaClProcessHostMsg_PpapiChannelCreated(handle))) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 #if defined(OS_WIN) | 309 #if defined(OS_WIN) |
| 310 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 310 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
| 311 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 311 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
| 312 #endif | 312 #endif |
| 313 #if defined(OS_LINUX) | 313 #if defined(OS_LINUX) |
| 314 args->prereserved_sandbox_size = prereserved_sandbox_size_; | 314 args->prereserved_sandbox_size = prereserved_sandbox_size_; |
| 315 #endif | 315 #endif |
| 316 NaClChromeMainStart(args); | 316 NaClChromeMainStart(args); |
| 317 NOTREACHED(); | 317 NOTREACHED(); |
| 318 } | 318 } |
| OLD | NEW |