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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 return; | 227 return; |
228 } | 228 } |
229 args->create_memory_object_func = CreateMemoryObject; | 229 args->create_memory_object_func = CreateMemoryObject; |
230 # if defined(OS_MACOSX) | 230 # if defined(OS_MACOSX) |
231 CHECK(handles.size() >= 1); | 231 CHECK(handles.size() >= 1); |
232 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); | 232 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); |
233 handles.pop_back(); | 233 handles.pop_back(); |
234 # endif | 234 # endif |
235 #endif | 235 #endif |
236 | 236 |
237 CHECK(handles.size() >= 1); | 237 if (params.uses_irt) { |
238 NaClHandle irt_handle = nacl::ToNativeHandle(handles[handles.size() - 1]); | 238 CHECK(handles.size() >= 1); |
239 handles.pop_back(); | 239 NaClHandle irt_handle = nacl::ToNativeHandle(handles[handles.size() - 1]); |
| 240 handles.pop_back(); |
240 | 241 |
241 #if defined(OS_WIN) | 242 #if defined(OS_WIN) |
242 args->irt_fd = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle), | 243 args->irt_fd = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle), |
243 _O_RDONLY | _O_BINARY); | 244 _O_RDONLY | _O_BINARY); |
244 if (args->irt_fd < 0) { | 245 if (args->irt_fd < 0) { |
245 LOG(ERROR) << "_open_osfhandle() failed"; | 246 LOG(ERROR) << "_open_osfhandle() failed"; |
246 return; | 247 return; |
| 248 } |
| 249 #else |
| 250 args->irt_fd = irt_handle; |
| 251 #endif |
| 252 } else { |
| 253 // Otherwise, the IRT handle is not even sent. |
| 254 args->irt_fd = -1; |
247 } | 255 } |
248 #else | |
249 args->irt_fd = irt_handle; | |
250 #endif | |
251 | 256 |
252 if (params.validation_cache_enabled) { | 257 if (params.validation_cache_enabled) { |
253 // SHA256 block size. | 258 // SHA256 block size. |
254 CHECK_EQ(params.validation_cache_key.length(), (size_t) 64); | 259 CHECK_EQ(params.validation_cache_key.length(), (size_t) 64); |
255 // The cache structure is not freed and exists until the NaCl process exits. | 260 // The cache structure is not freed and exists until the NaCl process exits. |
256 args->validation_cache = CreateValidationCache( | 261 args->validation_cache = CreateValidationCache( |
257 new BrowserValidationDBProxy(this), params.validation_cache_key, | 262 new BrowserValidationDBProxy(this), params.validation_cache_key, |
258 params.version); | 263 params.version); |
259 } | 264 } |
260 | 265 |
261 CHECK(handles.size() == 1); | 266 CHECK(handles.size() == 1); |
262 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); | 267 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); |
263 args->enable_exception_handling = params.enable_exception_handling; | 268 args->enable_exception_handling = params.enable_exception_handling; |
264 args->enable_debug_stub = params.enable_debug_stub; | 269 args->enable_debug_stub = params.enable_debug_stub; |
265 #if defined(OS_LINUX) || defined(OS_MACOSX) | 270 #if defined(OS_LINUX) || defined(OS_MACOSX) |
266 args->debug_stub_server_bound_socket_fd = nacl::ToNativeHandle( | 271 args->debug_stub_server_bound_socket_fd = nacl::ToNativeHandle( |
267 params.debug_stub_server_bound_socket); | 272 params.debug_stub_server_bound_socket); |
268 #endif | 273 #endif |
269 #if defined(OS_WIN) | 274 #if defined(OS_WIN) |
270 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 275 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
271 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 276 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
272 #endif | 277 #endif |
273 #if defined(OS_LINUX) | 278 #if defined(OS_LINUX) |
274 args->prereserved_sandbox_size = prereserved_sandbox_size_; | 279 args->prereserved_sandbox_size = prereserved_sandbox_size_; |
275 #endif | 280 #endif |
276 NaClChromeMainStart(args); | 281 NaClChromeMainStart(args); |
277 NOTREACHED(); | 282 NOTREACHED(); |
278 } | 283 } |
OLD | NEW |