| 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_helper_win_64.h" | 5 #include "components/nacl/loader/nacl_helper_win_64.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/power_monitor/power_monitor.h" | 13 #include "base/power_monitor/power_monitor.h" |
| 14 #include "base/power_monitor/power_monitor_device_source.h" | 14 #include "base/power_monitor/power_monitor_device_source.h" |
| 15 #include "base/process/launch.h" | 15 #include "base/process/launch.h" |
| 16 #include "base/process/memory.h" | 16 #include "base/process/memory.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/timer/hi_res_timer_manager.h" | 18 #include "base/timer/hi_res_timer_manager.h" |
| 19 #include "base/win/process_startup_helper.h" | 19 #include "base/win/process_startup_helper.h" |
| 20 #include "components/nacl/broker/nacl_broker_listener.h" | 20 #include "components/nacl/broker/nacl_broker_listener.h" |
| 21 #include "components/nacl/common/nacl_switches.h" | 21 #include "components/nacl/common/nacl_switches.h" |
| 22 #include "components/nacl/loader/nacl_listener.h" | 22 #include "components/nacl/loader/nacl_listener.h" |
| 23 #include "components/nacl/loader/nacl_main_platform_delegate.h" | 23 #include "components/nacl/loader/nacl_main_platform_delegate.h" |
| 24 #include "content/public/app/sandbox_helper_win.h" | 24 #include "content/public/app/sandbox_helper_win.h" |
| 25 #include "content/public/common/content_switches.h" | 25 #include "content/public/common/content_switches.h" |
| 26 #include "content/public/common/main_function_params.h" | 26 #include "content/public/common/main_function_params.h" |
| 27 #include "content/public/common/sandbox_init.h" | 27 #include "content/public/common/sandbox_init.h" |
| 28 #include "mojo/edk/embedder/embedder.h" |
| 29 #include "mojo/edk/embedder/platform_channel_pair.h" |
| 30 #include "mojo/edk/embedder/scoped_ipc_support.h" |
| 28 #include "sandbox/win/src/sandbox_types.h" | 31 #include "sandbox/win/src/sandbox_types.h" |
| 29 | 32 |
| 30 extern int NaClMain(const content::MainFunctionParams&); | 33 extern int NaClMain(const content::MainFunctionParams&); |
| 31 | 34 |
| 32 namespace { | 35 namespace { |
| 33 // main() routine for the NaCl broker process. | 36 // main() routine for the NaCl broker process. |
| 34 // This is necessary for supporting NaCl in Chrome on Win64. | 37 // This is necessary for supporting NaCl in Chrome on Win64. |
| 35 int NaClBrokerMain(const content::MainFunctionParams& parameters) { | 38 int NaClBrokerMain(const content::MainFunctionParams& parameters) { |
| 36 base::MessageLoopForIO main_message_loop; | 39 base::MessageLoopForIO main_message_loop; |
| 37 base::PlatformThread::SetName("CrNaClBrokerMain"); | 40 base::PlatformThread::SetName("CrNaClBrokerMain"); |
| 38 | 41 |
| 42 mojo::edk::Init(); |
| 43 mojo::edk::ScopedIPCSupport mojo_ipc_support(main_message_loop.task_runner()); |
| 44 mojo::edk::ScopedPlatformHandle platform_channel( |
| 45 mojo::edk::PlatformChannelPair::PassClientHandleFromParentProcess( |
| 46 *base::CommandLine::ForCurrentProcess())); |
| 47 DCHECK(platform_channel.is_valid()); |
| 48 mojo::edk::SetParentPipeHandle(std::move(platform_channel)); |
| 49 |
| 39 std::unique_ptr<base::PowerMonitorSource> power_monitor_source( | 50 std::unique_ptr<base::PowerMonitorSource> power_monitor_source( |
| 40 new base::PowerMonitorDeviceSource()); | 51 new base::PowerMonitorDeviceSource()); |
| 41 base::PowerMonitor power_monitor(std::move(power_monitor_source)); | 52 base::PowerMonitor power_monitor(std::move(power_monitor_source)); |
| 42 base::HighResolutionTimerManager hi_res_timer_manager; | 53 base::HighResolutionTimerManager hi_res_timer_manager; |
| 43 | 54 |
| 44 NaClBrokerListener listener; | 55 NaClBrokerListener listener; |
| 45 listener.Listen(); | 56 listener.Listen(); |
| 46 | 57 |
| 47 return 0; | 58 return 0; |
| 48 } | 59 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 return NaClMain(main_params); | 92 return NaClMain(main_params); |
| 82 | 93 |
| 83 if (process_type == switches::kNaClBrokerProcess) | 94 if (process_type == switches::kNaClBrokerProcess) |
| 84 return NaClBrokerMain(main_params); | 95 return NaClBrokerMain(main_params); |
| 85 | 96 |
| 86 CHECK(false) << "Unknown NaCl 64 process."; | 97 CHECK(false) << "Unknown NaCl 64 process."; |
| 87 return -1; | 98 return -1; |
| 88 } | 99 } |
| 89 | 100 |
| 90 } // namespace nacl | 101 } // namespace nacl |
| OLD | NEW |