| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/power_monitor/power_monitor.h" | 8 #include "base/power_monitor/power_monitor.h" |
| 9 #include "base/power_monitor/power_monitor_device_source.h" | 9 #include "base/power_monitor/power_monitor_device_source.h" |
| 10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
| 11 #include "base/process/memory.h" | 11 #include "base/process/memory.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/timer/hi_res_timer_manager.h" | 13 #include "base/timer/hi_res_timer_manager.h" |
| 14 #include "components/nacl/broker/nacl_broker_listener.h" | 14 #include "components/nacl/broker/nacl_broker_listener.h" |
| 15 #include "components/nacl/common/nacl_switches.h" | 15 #include "components/nacl/common/nacl_switches.h" |
| 16 #include "components/nacl/loader/nacl_listener.h" | 16 #include "components/nacl/loader/nacl_listener.h" |
| 17 #include "components/nacl/loader/nacl_main_platform_delegate.h" | 17 #include "components/nacl/loader/nacl_main_platform_delegate.h" |
| 18 #include "content/public/app/startup_helper_win.h" | 18 #include "content/public/app/startup_helper_win.h" |
| 19 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 20 #include "content/public/common/main_function_params.h" | 20 #include "content/public/common/main_function_params.h" |
| 21 #include "content/public/common/sandbox_init.h" | 21 #include "content/public/common/sandbox_init.h" |
| 22 #include "sandbox/win/src/sandbox_types.h" | 22 #include "sandbox/win/src/sandbox_types.h" |
| 23 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | |
| 24 #include "third_party/mojo/src/mojo/edk/embedder/simple_platform_support.h" | |
| 25 | 23 |
| 26 extern int NaClMain(const content::MainFunctionParams&); | 24 extern int NaClMain(const content::MainFunctionParams&); |
| 27 | 25 |
| 28 namespace { | 26 namespace { |
| 29 // main() routine for the NaCl broker process. | 27 // main() routine for the NaCl broker process. |
| 30 // This is necessary for supporting NaCl in Chrome on Win64. | 28 // This is necessary for supporting NaCl in Chrome on Win64. |
| 31 int NaClBrokerMain(const content::MainFunctionParams& parameters) { | 29 int NaClBrokerMain(const content::MainFunctionParams& parameters) { |
| 32 base::MessageLoopForIO main_message_loop; | 30 base::MessageLoopForIO main_message_loop; |
| 33 base::PlatformThread::SetName("CrNaClBrokerMain"); | 31 base::PlatformThread::SetName("CrNaClBrokerMain"); |
| 34 | 32 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 57 command_line.GetSwitchValueASCII(switches::kProcessType); | 55 command_line.GetSwitchValueASCII(switches::kProcessType); |
| 58 | 56 |
| 59 // Copy what ContentMain() does. | 57 // Copy what ContentMain() does. |
| 60 base::EnableTerminationOnHeapCorruption(); | 58 base::EnableTerminationOnHeapCorruption(); |
| 61 base::EnableTerminationOnOutOfMemory(); | 59 base::EnableTerminationOnOutOfMemory(); |
| 62 content::RegisterInvalidParamHandler(); | 60 content::RegisterInvalidParamHandler(); |
| 63 content::SetupCRT(command_line); | 61 content::SetupCRT(command_line); |
| 64 // Route stdio to parent console (if any) or create one. | 62 // Route stdio to parent console (if any) or create one. |
| 65 if (command_line.HasSwitch(switches::kEnableLogging)) | 63 if (command_line.HasSwitch(switches::kEnableLogging)) |
| 66 base::RouteStdioToConsole(); | 64 base::RouteStdioToConsole(); |
| 67 mojo::embedder::Init( | |
| 68 make_scoped_ptr(new mojo::embedder::SimplePlatformSupport())); | |
| 69 | 65 |
| 70 // Initialize the sandbox for this process. | 66 // Initialize the sandbox for this process. |
| 71 bool sandbox_initialized_ok = content::InitializeSandbox(&sandbox_info); | 67 bool sandbox_initialized_ok = content::InitializeSandbox(&sandbox_info); |
| 72 // Die if the sandbox can't be enabled. | 68 // Die if the sandbox can't be enabled. |
| 73 CHECK(sandbox_initialized_ok) << "Error initializing sandbox for " | 69 CHECK(sandbox_initialized_ok) << "Error initializing sandbox for " |
| 74 << process_type; | 70 << process_type; |
| 75 content::MainFunctionParams main_params(command_line); | 71 content::MainFunctionParams main_params(command_line); |
| 76 main_params.sandbox_info = &sandbox_info; | 72 main_params.sandbox_info = &sandbox_info; |
| 77 | 73 |
| 78 if (process_type == switches::kNaClLoaderProcess) | 74 if (process_type == switches::kNaClLoaderProcess) |
| 79 return NaClMain(main_params); | 75 return NaClMain(main_params); |
| 80 | 76 |
| 81 if (process_type == switches::kNaClBrokerProcess) | 77 if (process_type == switches::kNaClBrokerProcess) |
| 82 return NaClBrokerMain(main_params); | 78 return NaClBrokerMain(main_params); |
| 83 | 79 |
| 84 CHECK(false) << "Unknown NaCl 64 process."; | 80 CHECK(false) << "Unknown NaCl 64 process."; |
| 85 return -1; | 81 return -1; |
| 86 } | 82 } |
| 87 | 83 |
| 88 } // namespace nacl | 84 } // namespace nacl |
| OLD | NEW |