| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/base_switches.h" | |
| 6 #include "base/command_line.h" | |
| 7 #include "base/message_loop.h" | |
| 8 #include "base/string_util.h" | |
| 9 #include "base/threading/platform_thread.h" | |
| 10 #include "chrome/worker/worker_thread.h" | |
| 11 #include "content/common/child_process.h" | |
| 12 #include "content/common/hi_res_timer_manager.h" | |
| 13 #include "content/common/main_function_params.h" | |
| 14 #include "ui/base/system_monitor/system_monitor.h" | |
| 15 | |
| 16 #if defined(OS_WIN) | |
| 17 #include "content/common/sandbox_init_wrapper.h" | |
| 18 #include "sandbox/src/sandbox.h" | |
| 19 #endif | |
| 20 | |
| 21 // Mainline routine for running as the worker process. | |
| 22 int WorkerMain(const MainFunctionParams& parameters) { | |
| 23 // The main message loop of the worker process. | |
| 24 MessageLoop main_message_loop; | |
| 25 base::PlatformThread::SetName("CrWorkerMain"); | |
| 26 | |
| 27 ui::SystemMonitor system_monitor; | |
| 28 HighResolutionTimerManager hi_res_timer_manager; | |
| 29 | |
| 30 ChildProcess worker_process; | |
| 31 worker_process.set_main_thread(new WorkerThread()); | |
| 32 #if defined(OS_WIN) | |
| 33 sandbox::TargetServices* target_services = | |
| 34 parameters.sandbox_info_.TargetServices(); | |
| 35 if (!target_services) | |
| 36 return false; | |
| 37 | |
| 38 // Cause advapi32 to load before the sandbox is turned on. | |
| 39 unsigned int dummy_rand; | |
| 40 rand_s(&dummy_rand); | |
| 41 | |
| 42 target_services->LowerToken(); | |
| 43 #endif | |
| 44 | |
| 45 const CommandLine& parsed_command_line = parameters.command_line_; | |
| 46 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { | |
| 47 ChildProcess::WaitForDebugger("Worker"); | |
| 48 } | |
| 49 | |
| 50 // Load the accelerator table from the browser executable and tell the | |
| 51 // message loop to use it when translating messages. | |
| 52 MessageLoop::current()->Run(); | |
| 53 | |
| 54 return 0; | |
| 55 } | |
| OLD | NEW |