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

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

Issue 14238013: Set up NaClChromeMainArgs number_of_cores member so apps can size threadpools appropriately (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR fb Created 7 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
« no previous file with comments | « chrome/nacl/nacl_listener.h ('k') | chrome/nacl/nacl_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #if defined(OS_POSIX)
11 #include <unistd.h>
12 #endif
13
10 #include "base/command_line.h" 14 #include "base/command_line.h"
11 #include "base/logging.h" 15 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 17 #include "base/message_loop.h"
14 #include "base/rand_util.h" 18 #include "base/rand_util.h"
15 #include "chrome/common/nacl_messages.h" 19 #include "chrome/common/nacl_messages.h"
16 #include "chrome/nacl/nacl_ipc_adapter.h" 20 #include "chrome/nacl/nacl_ipc_adapter.h"
17 #include "chrome/nacl/nacl_validation_db.h" 21 #include "chrome/nacl/nacl_validation_db.h"
18 #include "chrome/nacl/nacl_validation_query.h" 22 #include "chrome/nacl/nacl_validation_query.h"
19 #include "ipc/ipc_channel_handle.h" 23 #include "ipc/ipc_channel_handle.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // The listener never dies, otherwise this might be a dangling reference. 138 // The listener never dies, otherwise this might be a dangling reference.
135 NaClListener* listener_; 139 NaClListener* listener_;
136 }; 140 };
137 141
138 142
139 NaClListener::NaClListener() : shutdown_event_(true, false), 143 NaClListener::NaClListener() : shutdown_event_(true, false),
140 io_thread_("NaCl_IOThread"), 144 io_thread_("NaCl_IOThread"),
141 #if defined(OS_LINUX) 145 #if defined(OS_LINUX)
142 prereserved_sandbox_size_(0), 146 prereserved_sandbox_size_(0),
143 #endif 147 #endif
148 #if defined(OS_POSIX)
149 number_of_cores_(-1), // unknown/error
150 #endif
144 main_loop_(NULL) { 151 main_loop_(NULL) {
145 io_thread_.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); 152 io_thread_.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0));
146 #if defined(OS_WIN) 153 #if defined(OS_WIN)
147 DCHECK(g_listener == NULL); 154 DCHECK(g_listener == NULL);
148 g_listener = this; 155 g_listener = this;
149 #endif 156 #endif
150 } 157 }
151 158
152 NaClListener::~NaClListener() { 159 NaClListener::~NaClListener() {
153 NOTREACHED(); 160 NOTREACHED();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 } 226 }
220 227
221 std::vector<nacl::FileDescriptor> handles = params.handles; 228 std::vector<nacl::FileDescriptor> handles = params.handles;
222 229
223 #if defined(OS_LINUX) || defined(OS_MACOSX) 230 #if defined(OS_LINUX) || defined(OS_MACOSX)
224 args->urandom_fd = dup(base::GetUrandomFD()); 231 args->urandom_fd = dup(base::GetUrandomFD());
225 if (args->urandom_fd < 0) { 232 if (args->urandom_fd < 0) {
226 LOG(ERROR) << "Failed to dup() the urandom FD"; 233 LOG(ERROR) << "Failed to dup() the urandom FD";
227 return; 234 return;
228 } 235 }
236 args->number_of_cores = number_of_cores_;
229 args->create_memory_object_func = CreateMemoryObject; 237 args->create_memory_object_func = CreateMemoryObject;
230 # if defined(OS_MACOSX) 238 # if defined(OS_MACOSX)
231 CHECK(handles.size() >= 1); 239 CHECK(handles.size() >= 1);
232 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]); 240 g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]);
233 handles.pop_back(); 241 handles.pop_back();
234 # endif 242 # endif
235 #endif 243 #endif
236 244
237 if (params.uses_irt) { 245 if (params.uses_irt) {
238 CHECK(handles.size() >= 1); 246 CHECK(handles.size() >= 1);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 #if defined(OS_WIN) 282 #if defined(OS_WIN)
275 args->broker_duplicate_handle_func = BrokerDuplicateHandle; 283 args->broker_duplicate_handle_func = BrokerDuplicateHandle;
276 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; 284 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler;
277 #endif 285 #endif
278 #if defined(OS_LINUX) 286 #if defined(OS_LINUX)
279 args->prereserved_sandbox_size = prereserved_sandbox_size_; 287 args->prereserved_sandbox_size = prereserved_sandbox_size_;
280 #endif 288 #endif
281 NaClChromeMainStart(args); 289 NaClChromeMainStart(args);
282 NOTREACHED(); 290 NOTREACHED();
283 } 291 }
OLDNEW
« no previous file with comments | « chrome/nacl/nacl_listener.h ('k') | chrome/nacl/nacl_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698