Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/nacl/loader/nacl_listener.h" | 5 #include "components/nacl/loader/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) | 10 #if defined(OS_POSIX) |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 private: | 195 private: |
| 196 // The listener never dies, otherwise this might be a dangling reference. | 196 // The listener never dies, otherwise this might be a dangling reference. |
| 197 NaClListener* listener_; | 197 NaClListener* listener_; |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 | 200 |
| 201 NaClListener::NaClListener() : shutdown_event_(true, false), | 201 NaClListener::NaClListener() : shutdown_event_(true, false), |
| 202 io_thread_("NaCl_IOThread"), | 202 io_thread_("NaCl_IOThread"), |
| 203 #if defined(OS_LINUX) | 203 #if defined(OS_LINUX) |
| 204 prereserved_sandbox_size_(0), | 204 prereserved_sandbox_size_(0), |
| 205 uses_nonsfi_mode_(false), | |
| 205 #endif | 206 #endif |
| 206 #if defined(OS_POSIX) | 207 #if defined(OS_POSIX) |
| 207 number_of_cores_(-1), // unknown/error | 208 number_of_cores_(-1), // unknown/error |
| 208 #endif | 209 #endif |
| 209 main_loop_(NULL) { | 210 main_loop_(NULL) { |
| 210 io_thread_.StartWithOptions( | 211 io_thread_.StartWithOptions( |
| 211 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 212 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 212 #if defined(OS_WIN) | 213 #if defined(OS_WIN) |
| 213 DCHECK(g_listener == NULL); | 214 DCHECK(g_listener == NULL); |
| 214 g_listener = this; | 215 g_listener = this; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 void NaClListener::OnStart(const nacl::NaClStartParams& params) { | 260 void NaClListener::OnStart(const nacl::NaClStartParams& params) { |
| 260 #if defined(OS_LINUX) || defined(OS_MACOSX) | 261 #if defined(OS_LINUX) || defined(OS_MACOSX) |
| 261 int urandom_fd = dup(base::GetUrandomFD()); | 262 int urandom_fd = dup(base::GetUrandomFD()); |
| 262 if (urandom_fd < 0) { | 263 if (urandom_fd < 0) { |
| 263 LOG(ERROR) << "Failed to dup() the urandom FD"; | 264 LOG(ERROR) << "Failed to dup() the urandom FD"; |
| 264 return; | 265 return; |
| 265 } | 266 } |
| 266 NaClChromeMainSetUrandomFd(urandom_fd); | 267 NaClChromeMainSetUrandomFd(urandom_fd); |
| 267 #endif | 268 #endif |
| 268 | 269 |
| 270 // TODO(hamaji): Add NaClChromeMainInitForNonSfi and use it when | |
|
Mark Seaborn
2014/03/28 15:38:42
Can you remove this comment? See other review...
hamaji
2014/03/30 03:31:35
OK, it's easier :) I'll withdraw the patch for nat
| |
| 271 // uses_nonsfi_mode_ is true. | |
| 269 NaClChromeMainInit(); | 272 NaClChromeMainInit(); |
| 270 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); | 273 struct NaClChromeMainArgs *args = NaClChromeMainArgsCreate(); |
| 271 if (args == NULL) { | 274 if (args == NULL) { |
| 272 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; | 275 LOG(ERROR) << "NaClChromeMainArgsCreate() failed"; |
| 273 return; | 276 return; |
| 274 } | 277 } |
| 275 | 278 |
| 276 struct NaClApp *nap = NaClAppCreate(); | 279 struct NaClApp *nap = NaClAppCreate(); |
| 277 if (nap == NULL) { | 280 if (nap == NULL) { |
| 278 LOG(ERROR) << "NaClAppCreate() failed"; | 281 LOG(ERROR) << "NaClAppCreate() failed"; |
| 279 return; | 282 return; |
| 280 } | 283 } |
| 281 | 284 |
| 282 IPC::ChannelHandle browser_handle; | 285 IPC::ChannelHandle browser_handle; |
| 283 IPC::ChannelHandle ppapi_renderer_handle; | 286 IPC::ChannelHandle ppapi_renderer_handle; |
| 284 | 287 |
| 285 if (params.enable_ipc_proxy) { | 288 if (params.enable_ipc_proxy) { |
| 286 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 289 browser_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 287 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); | 290 ppapi_renderer_handle = IPC::Channel::GenerateVerifiedChannelID("nacl"); |
| 288 | 291 |
| 289 #if defined(OS_LINUX) | 292 #if defined(OS_LINUX) |
| 290 if (params.uses_nonsfi_mode) { | 293 if (uses_nonsfi_mode_) { |
| 291 // In non-SFI mode, we neither intercept nor rewrite the message using | 294 // In non-SFI mode, we neither intercept nor rewrite the message using |
| 292 // NaClIPCAdapter, and the channels are connected between the plugin and | 295 // NaClIPCAdapter, and the channels are connected between the plugin and |
| 293 // the hosts directly. So, the IPC::Channel instances will be created in | 296 // the hosts directly. So, the IPC::Channel instances will be created in |
| 294 // the plugin side, because the IPC::Listener needs to live on the | 297 // the plugin side, because the IPC::Listener needs to live on the |
| 295 // plugin's main thread. However, on initialization (i.e. before loading | 298 // plugin's main thread. However, on initialization (i.e. before loading |
| 296 // the plugin binary), the FD needs to be passed to the hosts. So, here | 299 // the plugin binary), the FD needs to be passed to the hosts. So, here |
| 297 // we create raw FD pairs, and pass the client side FDs to the hosts, | 300 // we create raw FD pairs, and pass the client side FDs to the hosts, |
| 298 // and the server side FDs to the plugin. | 301 // and the server side FDs to the plugin. |
| 299 int browser_server_ppapi_fd; | 302 int browser_server_ppapi_fd; |
| 300 int browser_client_ppapi_fd; | 303 int browser_client_ppapi_fd; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 #endif | 417 #endif |
| 415 #if defined(OS_WIN) | 418 #if defined(OS_WIN) |
| 416 args->broker_duplicate_handle_func = BrokerDuplicateHandle; | 419 args->broker_duplicate_handle_func = BrokerDuplicateHandle; |
| 417 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; | 420 args->attach_debug_exception_handler_func = AttachDebugExceptionHandler; |
| 418 #endif | 421 #endif |
| 419 #if defined(OS_LINUX) | 422 #if defined(OS_LINUX) |
| 420 args->prereserved_sandbox_size = prereserved_sandbox_size_; | 423 args->prereserved_sandbox_size = prereserved_sandbox_size_; |
| 421 #endif | 424 #endif |
| 422 | 425 |
| 423 #if defined(OS_LINUX) | 426 #if defined(OS_LINUX) |
| 424 if (params.uses_nonsfi_mode) { | 427 if (uses_nonsfi_mode_) { |
| 425 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); | 428 nacl::nonsfi::MainStart(args->imc_bootstrap_handle); |
| 426 return; | 429 return; |
| 427 } | 430 } |
| 428 #endif | 431 #endif |
| 429 NaClChromeMainStartApp(nap, args); | 432 NaClChromeMainStartApp(nap, args); |
| 430 NOTREACHED(); | 433 NOTREACHED(); |
| 431 } | 434 } |
| OLD | NEW |