| 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/system_monitor/system_monitor.h" | 9 #include "base/system_monitor/system_monitor.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| 11 #include "content/common/child_process.h" | 11 #include "content/common/child_process.h" |
| 12 #include "content/common/hi_res_timer_manager.h" | 12 #include "content/common/hi_res_timer_manager.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/worker/worker_thread.h" | 15 #include "content/worker/worker_thread.h" |
| 15 | 16 |
| 16 #if defined(OS_WIN) | 17 #if defined(OS_WIN) |
| 17 #include "content/public/common/sandbox_init.h" | |
| 18 #include "sandbox/src/sandbox.h" | 18 #include "sandbox/src/sandbox.h" |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 // Mainline routine for running as the worker process. | 21 // Mainline routine for running as the worker process. |
| 22 int WorkerMain(const content::MainFunctionParams& parameters) { | 22 int WorkerMain(const content::MainFunctionParams& parameters) { |
| 23 // The main message loop of the worker process. | 23 // The main message loop of the worker process. |
| 24 MessageLoop main_message_loop; | 24 MessageLoop main_message_loop; |
| 25 base::PlatformThread::SetName("CrWorkerMain"); | 25 base::PlatformThread::SetName("CrWorkerMain"); |
| 26 | 26 |
| 27 base::SystemMonitor system_monitor; | 27 base::SystemMonitor system_monitor; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 // Cause advapi32 to load before the sandbox is turned on. | 38 // Cause advapi32 to load before the sandbox is turned on. |
| 39 unsigned int dummy_rand; | 39 unsigned int dummy_rand; |
| 40 rand_s(&dummy_rand); | 40 rand_s(&dummy_rand); |
| 41 // Warm up language subsystems before the sandbox is turned on. | 41 // Warm up language subsystems before the sandbox is turned on. |
| 42 ::GetUserDefaultLangID(); | 42 ::GetUserDefaultLangID(); |
| 43 ::GetUserDefaultLCID(); | 43 ::GetUserDefaultLCID(); |
| 44 | 44 |
| 45 target_services->LowerToken(); | 45 target_services->LowerToken(); |
| 46 #endif | 46 #endif |
| 47 | 47 |
| 48 #if defined(OS_LINUX) |
| 49 content::InitializeSandbox(); |
| 50 #endif |
| 51 |
| 48 const CommandLine& parsed_command_line = parameters.command_line; | 52 const CommandLine& parsed_command_line = parameters.command_line; |
| 49 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { | 53 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { |
| 50 ChildProcess::WaitForDebugger("Worker"); | 54 ChildProcess::WaitForDebugger("Worker"); |
| 51 } | 55 } |
| 52 | 56 |
| 53 // Load the accelerator table from the browser executable and tell the | 57 // Load the accelerator table from the browser executable and tell the |
| 54 // message loop to use it when translating messages. | 58 // message loop to use it when translating messages. |
| 55 MessageLoop::current()->Run(); | 59 MessageLoop::current()->Run(); |
| 56 | 60 |
| 57 return 0; | 61 return 0; |
| 58 } | 62 } |
| OLD | NEW |