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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "chrome/common/chrome_switches.h" | |
14 #include "chrome/common/nacl_messages.h" | 15 #include "chrome/common/nacl_messages.h" |
15 #include "chrome/nacl/nacl_validation_db.h" | 16 #include "chrome/nacl/nacl_validation_db.h" |
16 #include "chrome/nacl/nacl_validation_query.h" | 17 #include "chrome/nacl/nacl_validation_query.h" |
18 #include "ipc/ipc_channel_handle.h" | |
19 #include "ipc/ipc_switches.h" | |
17 #include "ipc/ipc_sync_channel.h" | 20 #include "ipc/ipc_sync_channel.h" |
18 #include "ipc/ipc_sync_message_filter.h" | 21 #include "ipc/ipc_sync_message_filter.h" |
19 #include "ipc/ipc_switches.h" | |
20 #include "native_client/src/trusted/service_runtime/sel_main_chrome.h" | 22 #include "native_client/src/trusted/service_runtime/sel_main_chrome.h" |
21 | 23 |
22 #if defined(OS_LINUX) | 24 #if defined(OS_LINUX) |
23 #include "content/public/common/child_process_sandbox_support_linux.h" | 25 #include "content/public/common/child_process_sandbox_support_linux.h" |
24 #endif | 26 #endif |
25 | 27 |
26 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
27 #include <fcntl.h> | 29 #include <fcntl.h> |
28 #include <io.h> | 30 #include <io.h> |
29 | 31 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 | 137 |
136 private: | 138 private: |
137 // The listener never dies, otherwise this might be a dangling reference. | 139 // The listener never dies, otherwise this might be a dangling reference. |
138 NaClListener* listener_; | 140 NaClListener* listener_; |
139 }; | 141 }; |
140 | 142 |
141 | 143 |
142 NaClListener::NaClListener() : shutdown_event_(true, false), | 144 NaClListener::NaClListener() : shutdown_event_(true, false), |
143 io_thread_("NaCl_IOThread"), | 145 io_thread_("NaCl_IOThread"), |
144 main_loop_(NULL), | 146 main_loop_(NULL), |
147 nacl_ppapi_channel_(NULL), | |
145 debug_enabled_(false) { | 148 debug_enabled_(false) { |
146 io_thread_.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); | 149 io_thread_.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); |
150 nacl_ipc_manager_.Init(io_thread_.message_loop_proxy()); | |
147 #if defined(OS_WIN) | 151 #if defined(OS_WIN) |
148 DCHECK(g_listener == NULL); | 152 DCHECK(g_listener == NULL); |
149 g_listener = this; | 153 g_listener = this; |
150 #endif | 154 #endif |
151 } | 155 } |
152 | 156 |
153 NaClListener::~NaClListener() { | 157 NaClListener::~NaClListener() { |
154 NOTREACHED(); | 158 NOTREACHED(); |
155 shutdown_event_.Signal(); | 159 shutdown_event_.Signal(); |
156 #if defined(OS_WIN) | 160 #if defined(OS_WIN) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 return handled; | 195 return handled; |
192 } | 196 } |
193 | 197 |
194 void NaClListener::OnMsgStart(const nacl::NaClStartParams& params) { | 198 void NaClListener::OnMsgStart(const nacl::NaClStartParams& params) { |
195 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); | 199 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); |
196 if (args == NULL) { | 200 if (args == NULL) { |
197 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; | 201 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; |
198 return; | 202 return; |
199 } | 203 } |
200 | 204 |
205 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
206 switches::kEnableNaClIPCProxy)) { | |
207 // Create the server side of the channel and notify the process host so it | |
208 // can reply to the renderer, which will then try to connect as client. | |
dmichael (off chromium)
2012/05/10 19:38:58
heh... I think I'm going to need to draw a sequen
bbudge
2012/05/11 01:21:16
I couldn't get it to work creating the channels in
| |
209 IPC::ChannelHandle channel_handle = | |
210 IPC::Channel::GenerateVerifiedChannelID("nacl"); | |
211 nacl_ppapi_channel_ = nacl_ipc_manager_.CreateChannel(channel_handle); | |
212 | |
213 Send(new NaClProcessHostMsg_PpapiChannelCreated(channel_handle)); | |
214 } | |
215 | |
201 std::vector<nacl::FileDescriptor> handles = params.handles; | 216 std::vector<nacl::FileDescriptor> handles = params.handles; |
202 | 217 |
203 #if defined(OS_LINUX) || defined(OS_MACOSX) | 218 #if defined(OS_LINUX) || defined(OS_MACOSX) |
204 args->create_memory_object_func = CreateMemoryObject; | 219 args->create_memory_object_func = CreateMemoryObject; |
205 # if defined(OS_MACOSX) | 220 # if defined(OS_MACOSX) |
206 CHECK(handles.size() >= 1); | 221 CHECK(handles.size() >= 1); |
207 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); | 222 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); |
208 handles.pop_back(); | 223 handles.pop_back(); |
209 # endif | 224 # endif |
210 #endif | 225 #endif |
(...skipping 25 matching lines...) Expand all Loading... | |
236 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); | 251 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); |
237 args->enable_exception_handling = params.enable_exception_handling; | 252 args->enable_exception_handling = params.enable_exception_handling; |
238 args->enable_debug_stub = debug_enabled_; | 253 args->enable_debug_stub = debug_enabled_; |
239 #if defined(OS_WIN) | 254 #if defined(OS_WIN) |
240 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 255 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
241 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 256 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
242 #endif | 257 #endif |
243 NaClChromeMainStart(args); | 258 NaClChromeMainStart(args); |
244 NOTREACHED(); | 259 NOTREACHED(); |
245 } | 260 } |
OLD | NEW |