| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/power_monitor/power_monitor.h" | 9 #include "base/power_monitor/power_monitor.h" |
| 10 #include "base/power_monitor/power_monitor_device_source.h" | 10 #include "base/power_monitor/power_monitor_device_source.h" |
| 11 #include "base/timer/hi_res_timer_manager.h" | 11 #include "base/timer/hi_res_timer_manager.h" |
| 12 #include "components/nacl/loader/nacl_listener.h" | 12 #include "components/nacl/loader/nacl_listener.h" |
| 13 #include "components/nacl/loader/nacl_main_platform_delegate.h" | 13 #include "components/nacl/loader/nacl_main_platform_delegate.h" |
| 14 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 15 #include "content/public/common/main_function_params.h" | 15 #include "content/public/common/main_function_params.h" |
| 16 #include "ipc/attachment_broker.h" |
| 17 |
| 18 #if defined(OS_WIN) |
| 19 #include "ipc/attachment_broker_win.h" |
| 20 #endif |
| 16 | 21 |
| 17 // main() routine for the NaCl loader process. | 22 // main() routine for the NaCl loader process. |
| 18 int NaClMain(const content::MainFunctionParams& parameters) { | 23 int NaClMain(const content::MainFunctionParams& parameters) { |
| 19 const base::CommandLine& parsed_command_line = parameters.command_line; | 24 const base::CommandLine& parsed_command_line = parameters.command_line; |
| 20 | 25 |
| 21 // The main thread of the plugin services IO. | 26 // The main thread of the plugin services IO. |
| 22 base::MessageLoopForIO main_message_loop; | 27 base::MessageLoopForIO main_message_loop; |
| 23 base::PlatformThread::SetName("CrNaClMain"); | 28 base::PlatformThread::SetName("CrNaClMain"); |
| 24 | 29 |
| 25 scoped_ptr<base::PowerMonitorSource> power_monitor_source( | 30 scoped_ptr<base::PowerMonitorSource> power_monitor_source( |
| 26 new base::PowerMonitorDeviceSource()); | 31 new base::PowerMonitorDeviceSource()); |
| 27 base::PowerMonitor power_monitor(power_monitor_source.Pass()); | 32 base::PowerMonitor power_monitor(power_monitor_source.Pass()); |
| 28 base::HighResolutionTimerManager hi_res_timer_manager; | 33 base::HighResolutionTimerManager hi_res_timer_manager; |
| 29 | 34 |
| 30 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ | 35 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) || \ |
| 31 defined(OS_ANDROID) | 36 defined(OS_ANDROID) |
| 32 NaClMainPlatformDelegate platform(parameters); | 37 NaClMainPlatformDelegate platform(parameters); |
| 33 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); | 38 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); |
| 34 | 39 |
| 35 #if defined(OS_POSIX) | 40 #if defined(OS_POSIX) |
| 36 // The number of cores must be obtained before the invocation of | 41 // The number of cores must be obtained before the invocation of |
| 37 // platform.EnableSandbox(), so cannot simply be inlined below. | 42 // platform.EnableSandbox(), so cannot simply be inlined below. |
| 38 int number_of_cores = sysconf(_SC_NPROCESSORS_ONLN); | 43 int number_of_cores = sysconf(_SC_NPROCESSORS_ONLN); |
| 39 #endif | 44 #endif |
| 40 | 45 |
| 41 if (!no_sandbox) { | 46 if (!no_sandbox) { |
| 42 platform.EnableSandbox(); | 47 platform.EnableSandbox(); |
| 43 } | 48 } |
| 44 NaClListener listener; | 49 |
| 50 scoped_ptr<IPC::AttachmentBroker> attachment_broker; |
| 51 #if defined(OS_WIN) |
| 52 attachment_broker.reset(new IPC::AttachmentBrokerWin()); |
| 53 #endif |
| 54 |
| 55 NaClListener listener(attachment_broker.get()); |
| 45 #if defined(OS_POSIX) | 56 #if defined(OS_POSIX) |
| 46 listener.set_number_of_cores(number_of_cores); | 57 listener.set_number_of_cores(number_of_cores); |
| 47 #endif | 58 #endif |
| 48 | 59 |
| 49 listener.Listen(); | 60 listener.Listen(); |
| 50 #else | 61 #else |
| 51 NOTIMPLEMENTED() << " not implemented startup, plugin startup dialog etc."; | 62 NOTIMPLEMENTED() << " not implemented startup, plugin startup dialog etc."; |
| 52 #endif | 63 #endif |
| 53 return 0; | 64 return 0; |
| 54 } | 65 } |
| OLD | NEW |