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

Side by Side Diff: chrome/nacl/nacl_listener.cc

Issue 10039001: NaCl: Supply Windows handle-passing function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix + comment Created 8 years, 8 months 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
OLDNEW
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/nacl_messages.h" 14 #include "chrome/common/nacl_messages.h"
15 #include "chrome/nacl/nacl_validation_db.h" 15 #include "chrome/nacl/nacl_validation_db.h"
16 #include "chrome/nacl/nacl_validation_query.h" 16 #include "chrome/nacl/nacl_validation_query.h"
17 #include "ipc/ipc_sync_channel.h" 17 #include "ipc/ipc_sync_channel.h"
18 #include "ipc/ipc_sync_message_filter.h" 18 #include "ipc/ipc_sync_message_filter.h"
19 #include "ipc/ipc_switches.h" 19 #include "ipc/ipc_switches.h"
20 #include "native_client/src/trusted/service_runtime/sel_main_chrome.h" 20 #include "native_client/src/trusted/service_runtime/sel_main_chrome.h"
21 21
22 #if defined(OS_LINUX) 22 #if defined(OS_LINUX)
23 #include "content/public/common/child_process_sandbox_support_linux.h" 23 #include "content/public/common/child_process_sandbox_support_linux.h"
24 #endif 24 #endif
25 25
26 #if defined(OS_WIN) 26 #if defined(OS_WIN)
27 #include <fcntl.h> 27 #include <fcntl.h>
28 #include <io.h> 28 #include <io.h>
29
30 #include "content/public/common/sandbox_init.h"
29 #endif 31 #endif
30 32
31 namespace { 33 namespace {
32 #if defined(OS_MACOSX) 34 #if defined(OS_MACOSX)
33 35
34 // On Mac OS X, shm_open() works in the sandbox but does not give us 36 // On Mac OS X, shm_open() works in the sandbox but does not give us
35 // an FD that we can map as PROT_EXEC. Rather than doing an IPC to 37 // an FD that we can map as PROT_EXEC. Rather than doing an IPC to
36 // get an executable SHM region when CreateMemoryObject() is called, 38 // get an executable SHM region when CreateMemoryObject() is called,
37 // we preallocate one on startup, since NaCl's sel_ldr only needs one 39 // we preallocate one on startup, since NaCl's sel_ldr only needs one
38 // of them. This saves a round trip. 40 // of them. This saves a round trip.
(...skipping 21 matching lines...) Expand all
60 // Fall back to NaCl's default implementation. 62 // Fall back to NaCl's default implementation.
61 return -1; 63 return -1;
62 } 64 }
63 65
64 #elif defined(OS_LINUX) 66 #elif defined(OS_LINUX)
65 67
66 int CreateMemoryObject(size_t size, int executable) { 68 int CreateMemoryObject(size_t size, int executable) {
67 return content::MakeSharedMemorySegmentViaIPC(size, executable); 69 return content::MakeSharedMemorySegmentViaIPC(size, executable);
68 } 70 }
69 71
72 #elif defined(OS_WIN)
73
74 // We wrap the function to convert the bool return value to an int.
75 int BrokerDuplicateHandle(NaClHandle source_handle,
76 uint32_t process_id,
77 NaClHandle* target_handle,
78 uint32_t desired_access,
79 uint32_t options) {
80 return content::BrokerDuplicateHandle(source_handle, process_id,
81 target_handle, desired_access,
82 options);
83 }
84
70 #endif 85 #endif
71 86
72 // Use an env var because command line args are eaten by nacl_helper. 87 // Use an env var because command line args are eaten by nacl_helper.
73 bool CheckEnvVar(const char* name, bool default_value) { 88 bool CheckEnvVar(const char* name, bool default_value) {
74 bool result = default_value; 89 bool result = default_value;
75 const char* var = getenv(name); 90 const char* var = getenv(name);
76 if (var && strlen(var) > 0) { 91 if (var && strlen(var) > 0) {
77 result = var[0] != '0'; 92 result = var[0] != '0';
78 } 93 }
79 return result; 94 return result;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 LOG(INFO) << "NaCl validation cache enabled."; 211 LOG(INFO) << "NaCl validation cache enabled.";
197 // The cache structure is not freed and exists until the NaCl process exits. 212 // The cache structure is not freed and exists until the NaCl process exits.
198 args->validation_cache = CreateValidationCache( 213 args->validation_cache = CreateValidationCache(
199 new BrowserValidationDBProxy(this), validation_cache_key, version); 214 new BrowserValidationDBProxy(this), validation_cache_key, version);
200 } 215 }
201 216
202 CHECK(handles.size() == 1); 217 CHECK(handles.size() == 1);
203 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]); 218 args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]);
204 args->enable_exception_handling = enable_exception_handling; 219 args->enable_exception_handling = enable_exception_handling;
205 args->enable_debug_stub = debug_enabled_; 220 args->enable_debug_stub = debug_enabled_;
221 #if defined(OS_WIN)
222 args->broker_duplicate_handle_func = BrokerDuplicateHandle;
223 #endif
206 NaClChromeMainStart(args); 224 NaClChromeMainStart(args);
207 NOTREACHED(); 225 NOTREACHED();
208 } 226 }
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_process_host.cc ('k') | chrome/renderer/chrome_ppapi_interfaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698