| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include "app/hi_res_timer_manager.h" | |
| 12 #include "app/system_monitor.h" | |
| 13 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 14 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 15 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 16 #include "chrome/common/child_process.h" | 14 #include "chrome/common/child_process.h" |
| 17 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 18 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/hi_res_timer_manager.h" |
| 19 #include "chrome/common/logging_chrome.h" | 18 #include "chrome/common/logging_chrome.h" |
| 20 #include "chrome/common/main_function_params.h" | 19 #include "chrome/common/main_function_params.h" |
| 21 #include "chrome/common/result_codes.h" | 20 #include "chrome/common/result_codes.h" |
| 22 #include "chrome/common/sandbox_policy.h" | 21 #include "chrome/common/sandbox_policy.h" |
| 23 #include "chrome/nacl/nacl_main_platform_delegate.h" | 22 #include "chrome/nacl/nacl_main_platform_delegate.h" |
| 24 #include "chrome/nacl/nacl_thread.h" | 23 #include "chrome/nacl/nacl_thread.h" |
| 24 #include "ui/base/system_monitor/system_monitor.h" |
| 25 | 25 |
| 26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 27 #include "chrome/nacl/broker_thread.h" | 27 #include "chrome/nacl/broker_thread.h" |
| 28 #include "chrome/test/injection_test_dll.h" | 28 #include "chrome/test/injection_test_dll.h" |
| 29 #include "sandbox/src/sandbox.h" | 29 #include "sandbox/src/sandbox.h" |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #ifdef _WIN64 | 32 #ifdef _WIN64 |
| 33 | 33 |
| 34 // main() routine for the NaCl broker process. | 34 // main() routine for the NaCl broker process. |
| 35 // This is necessary for supporting NaCl in Chrome on Win64. | 35 // This is necessary for supporting NaCl in Chrome on Win64. |
| 36 int NaClBrokerMain(const MainFunctionParams& parameters) { | 36 int NaClBrokerMain(const MainFunctionParams& parameters) { |
| 37 // The main thread of the broker. | 37 // The main thread of the broker. |
| 38 MessageLoopForIO main_message_loop; | 38 MessageLoopForIO main_message_loop; |
| 39 base::PlatformThread::SetName("CrNaClBrokerMain"); | 39 base::PlatformThread::SetName("CrNaClBrokerMain"); |
| 40 | 40 |
| 41 SystemMonitor system_monitor; | 41 ui::SystemMonitor system_monitor; |
| 42 HighResolutionTimerManager hi_res_timer_manager; | 42 HighResolutionTimerManager hi_res_timer_manager; |
| 43 | 43 |
| 44 const CommandLine& parsed_command_line = parameters.command_line_; | 44 const CommandLine& parsed_command_line = parameters.command_line_; |
| 45 | 45 |
| 46 DVLOG(1) << "Started NaCL broker with " | 46 DVLOG(1) << "Started NaCL broker with " |
| 47 << parsed_command_line.command_line_string(); | 47 << parsed_command_line.command_line_string(); |
| 48 | 48 |
| 49 // NOTE: this code is duplicated from browser_main.cc | 49 // NOTE: this code is duplicated from browser_main.cc |
| 50 // IMPORTANT: This piece of code needs to run as early as possible in the | 50 // IMPORTANT: This piece of code needs to run as early as possible in the |
| 51 // process because it will initialize the sandbox broker, which requires the | 51 // process because it will initialize the sandbox broker, which requires the |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // This function allows pausing execution using the --nacl-startup-dialog | 95 // This function allows pausing execution using the --nacl-startup-dialog |
| 96 // flag allowing us to attach a debugger. | 96 // flag allowing us to attach a debugger. |
| 97 // Do not move this function down since that would mean we can't easily debug | 97 // Do not move this function down since that would mean we can't easily debug |
| 98 // whatever occurs before it. | 98 // whatever occurs before it. |
| 99 HandleNaClTestParameters(parsed_command_line); | 99 HandleNaClTestParameters(parsed_command_line); |
| 100 | 100 |
| 101 // The main thread of the plugin services IO. | 101 // The main thread of the plugin services IO. |
| 102 MessageLoopForIO main_message_loop; | 102 MessageLoopForIO main_message_loop; |
| 103 base::PlatformThread::SetName("CrNaClMain"); | 103 base::PlatformThread::SetName("CrNaClMain"); |
| 104 | 104 |
| 105 SystemMonitor system_monitor; | 105 ui::SystemMonitor system_monitor; |
| 106 HighResolutionTimerManager hi_res_timer_manager; | 106 HighResolutionTimerManager hi_res_timer_manager; |
| 107 | 107 |
| 108 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) | 108 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) |
| 109 NaClMainPlatformDelegate platform(parameters); | 109 NaClMainPlatformDelegate platform(parameters); |
| 110 | 110 |
| 111 platform.PlatformInitialize(); | 111 platform.PlatformInitialize(); |
| 112 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); | 112 bool no_sandbox = parsed_command_line.HasSwitch(switches::kNoSandbox); |
| 113 platform.InitSandboxTests(no_sandbox); | 113 platform.InitSandboxTests(no_sandbox); |
| 114 | 114 |
| 115 if (!no_sandbox) { | 115 if (!no_sandbox) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 129 // require waiting for a timeout. | 129 // require waiting for a timeout. |
| 130 VLOG(1) << "Sandbox test failed: Not launching NaCl process"; | 130 VLOG(1) << "Sandbox test failed: Not launching NaCl process"; |
| 131 } | 131 } |
| 132 #else | 132 #else |
| 133 NOTIMPLEMENTED() << " not implemented startup, plugin startup dialog etc."; | 133 NOTIMPLEMENTED() << " not implemented startup, plugin startup dialog etc."; |
| 134 #endif | 134 #endif |
| 135 | 135 |
| 136 platform.PlatformUninitialize(); | 136 platform.PlatformUninitialize(); |
| 137 return 0; | 137 return 0; |
| 138 } | 138 } |
| OLD | NEW |