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

Side by Side Diff: content/utility/utility_main.cc

Issue 17074009: Created multi-process-friendly PowerMonitor interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing windows unit test errors Created 7 years, 4 months 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
« no previous file with comments | « content/renderer/renderer_main.cc ('k') | content/worker/worker_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/power_monitor/power_monitor.h"
8 #include "base/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
9 #include "base/timer/hi_res_timer_manager.h" 8 #include "base/timer/hi_res_timer_manager.h"
10 #include "content/child/child_process.h" 9 #include "content/child/child_process.h"
11 #include "content/common/sandbox_linux.h" 10 #include "content/common/sandbox_linux.h"
12 #include "content/public/common/content_switches.h" 11 #include "content/public/common/content_switches.h"
13 #include "content/public/common/main_function_params.h" 12 #include "content/public/common/main_function_params.h"
14 #include "content/public/common/sandbox_init.h" 13 #include "content/public/common/sandbox_init.h"
15 #include "content/utility/utility_thread_impl.h" 14 #include "content/utility/utility_thread_impl.h"
16 15
17 #if defined(OS_WIN) 16 #if defined(OS_WIN)
18 #include "sandbox/win/src/sandbox.h" 17 #include "sandbox/win/src/sandbox.h"
19 #endif 18 #endif
20 19
21 namespace content { 20 namespace content {
22 21
23 // Mainline routine for running as the utility process. 22 // Mainline routine for running as the utility process.
24 int UtilityMain(const MainFunctionParams& parameters) { 23 int UtilityMain(const MainFunctionParams& parameters) {
25 // The main message loop of the utility process. 24 // The main message loop of the utility process.
26 base::MessageLoop main_message_loop; 25 base::MessageLoop main_message_loop;
27 base::PlatformThread::SetName("CrUtilityMain"); 26 base::PlatformThread::SetName("CrUtilityMain");
28 27
29 base::PowerMonitor power_monitor;
30 base::HighResolutionTimerManager hi_res_timer_manager;
31
32 #if defined(OS_LINUX) 28 #if defined(OS_LINUX)
33 // Initialize the sandbox before any thread is created. 29 // Initialize the sandbox before any thread is created.
34 LinuxSandbox::InitializeSandbox(); 30 LinuxSandbox::InitializeSandbox();
35 #endif 31 #endif
36 32
37 ChildProcess utility_process; 33 ChildProcess utility_process;
38 utility_process.set_main_thread(new UtilityThreadImpl()); 34 utility_process.set_main_thread(new UtilityThreadImpl());
39 35
36 base::HighResolutionTimerManager hi_res_timer_manager;
37
40 #if defined(OS_WIN) 38 #if defined(OS_WIN)
41 bool no_sandbox = parameters.command_line.HasSwitch(switches::kNoSandbox); 39 bool no_sandbox = parameters.command_line.HasSwitch(switches::kNoSandbox);
42 if (!no_sandbox) { 40 if (!no_sandbox) {
43 sandbox::TargetServices* target_services = 41 sandbox::TargetServices* target_services =
44 parameters.sandbox_info->target_services; 42 parameters.sandbox_info->target_services;
45 if (!target_services) 43 if (!target_services)
46 return false; 44 return false;
47 target_services->LowerToken(); 45 target_services->LowerToken();
48 } 46 }
49 #endif 47 #endif
50 48
51 base::MessageLoop::current()->Run(); 49 base::MessageLoop::current()->Run();
52 50
53 return 0; 51 return 0;
54 } 52 }
55 53
56 } // namespace content 54 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/renderer_main.cc ('k') | content/worker/worker_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698