Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: content/worker/worker_main.cc

Issue 8414020: Expose the sandbox related code through the content API. I did a bit of cleanup while I was doing... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/common/main_function_params.h" 13 #include "content/common/main_function_params.h"
14 #include "content/worker/worker_thread.h" 14 #include "content/worker/worker_thread.h"
15 15
16 #if defined(OS_WIN) 16 #if defined(OS_WIN)
17 #include "content/common/sandbox_init_wrapper.h" 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 MainFunctionParams& parameters) { 22 int WorkerMain(const 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;
28 HighResolutionTimerManager hi_res_timer_manager; 28 HighResolutionTimerManager hi_res_timer_manager;
29 29
30 ChildProcess worker_process; 30 ChildProcess worker_process;
31 worker_process.set_main_thread(new WorkerThread()); 31 worker_process.set_main_thread(new WorkerThread());
32 #if defined(OS_WIN) 32 #if defined(OS_WIN)
33 sandbox::TargetServices* target_services = 33 sandbox::TargetServices* target_services =
34 parameters.sandbox_info_.TargetServices(); 34 parameters.sandbox_info->target_services;
35 if (!target_services) 35 if (!target_services)
36 return false; 36 return false;
37 37
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 const CommandLine& parsed_command_line = parameters.command_line_; 48 const CommandLine& parsed_command_line = parameters.command_line;
49 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) { 49 if (parsed_command_line.HasSwitch(switches::kWaitForDebugger)) {
50 ChildProcess::WaitForDebugger("Worker"); 50 ChildProcess::WaitForDebugger("Worker");
51 } 51 }
52 52
53 // Load the accelerator table from the browser executable and tell the 53 // Load the accelerator table from the browser executable and tell the
54 // message loop to use it when translating messages. 54 // message loop to use it when translating messages.
55 MessageLoop::current()->Run(); 55 MessageLoop::current()->Run();
56 56
57 return 0; 57 return 0;
58 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698