OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/base_switches.h" | 5 #include "base/base_switches.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/hi_res_timer_manager.h" | 7 #include "base/hi_res_timer_manager.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/system_monitor/system_monitor.h" | 10 #include "base/system_monitor/system_monitor.h" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "content/common/child_process.h" | 12 #include "content/common/child_process.h" |
13 #include "content/public/common/main_function_params.h" | 13 #include "content/public/common/main_function_params.h" |
14 #include "content/public/common/sandbox_init.h" | 14 #include "content/public/common/sandbox_init.h" |
15 #include "content/worker/worker_thread.h" | 15 #include "content/worker/worker_thread.h" |
16 | 16 |
17 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
18 #include "sandbox/win/src/sandbox.h" | 18 #include "sandbox/win/src/sandbox.h" |
19 #endif | 19 #endif |
20 | 20 |
| 21 namespace content { |
| 22 |
21 // Mainline routine for running as the worker process. | 23 // Mainline routine for running as the worker process. |
22 int WorkerMain(const content::MainFunctionParams& parameters) { | 24 int WorkerMain(const MainFunctionParams& parameters) { |
23 // The main message loop of the worker process. | 25 // The main message loop of the worker process. |
24 MessageLoop main_message_loop; | 26 MessageLoop main_message_loop; |
25 base::PlatformThread::SetName("CrWorkerMain"); | 27 base::PlatformThread::SetName("CrWorkerMain"); |
26 | 28 |
27 base::SystemMonitor system_monitor; | 29 base::SystemMonitor system_monitor; |
28 HighResolutionTimerManager hi_res_timer_manager; | 30 HighResolutionTimerManager hi_res_timer_manager; |
29 | 31 |
30 ChildProcess worker_process; | 32 ChildProcess worker_process; |
31 worker_process.set_main_thread(new WorkerThread()); | 33 worker_process.set_main_thread(new WorkerThread()); |
32 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
33 sandbox::TargetServices* target_services = | 35 sandbox::TargetServices* target_services = |
34 parameters.sandbox_info->target_services; | 36 parameters.sandbox_info->target_services; |
35 if (!target_services) | 37 if (!target_services) |
36 return false; | 38 return false; |
37 | 39 |
38 // Cause advapi32 to load before the sandbox is turned on. | 40 // Cause advapi32 to load before the sandbox is turned on. |
39 unsigned int dummy_rand; | 41 unsigned int dummy_rand; |
40 rand_s(&dummy_rand); | 42 rand_s(&dummy_rand); |
41 // Warm up language subsystems before the sandbox is turned on. | 43 // Warm up language subsystems before the sandbox is turned on. |
42 ::GetUserDefaultLangID(); | 44 ::GetUserDefaultLangID(); |
43 ::GetUserDefaultLCID(); | 45 ::GetUserDefaultLCID(); |
44 | 46 |
45 target_services->LowerToken(); | 47 target_services->LowerToken(); |
46 #endif | 48 #endif |
47 | 49 |
48 #if defined(OS_LINUX) | 50 #if defined(OS_LINUX) |
49 content::InitializeSandbox(); | 51 InitializeSandbox(); |
50 #endif | 52 #endif |
51 | 53 |
52 const CommandLine& parsed_command_line = parameters.command_line; | 54 const CommandLine& parsed_command_line = parameters.command_line; |
53 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { | 55 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { |
54 ChildProcess::WaitForDebugger("Worker"); | 56 ChildProcess::WaitForDebugger("Worker"); |
55 } | 57 } |
56 | 58 |
57 // Load the accelerator table from the browser executable and tell the | 59 // Load the accelerator table from the browser executable and tell the |
58 // message loop to use it when translating messages. | 60 // message loop to use it when translating messages. |
59 MessageLoop::current()->Run(); | 61 MessageLoop::current()->Run(); |
60 | 62 |
61 return 0; | 63 return 0; |
62 } | 64 } |
| 65 |
| 66 } // namespace content |
OLD | NEW |