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

Unified Diff: content/utility/utility_main.cc

Issue 2629873002: Do not create base::HighResolutionTimerManager in service utility process (Closed)
Patch Set: Address comments from danakj@ Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/utility/utility_main.cc
diff --git a/content/utility/utility_main.cc b/content/utility/utility_main.cc
index e8acf88ea2b5f98385506762b5ee2662e6a205c0..79341050cdff16d3870927627193ca9e5569a7b2 100644
--- a/content/utility/utility_main.cc
+++ b/content/utility/utility_main.cc
@@ -5,6 +5,8 @@
#include "base/command_line.h"
#include "base/debug/leak_annotations.h"
#include "base/message_loop/message_loop.h"
+#include "base/optional.h"
+#include "base/power_monitor/power_monitor.h"
#include "base/run_loop.h"
#include "base/threading/platform_thread.h"
#include "base/timer/hi_res_timer_manager.h"
@@ -40,7 +42,22 @@ int UtilityMain(const MainFunctionParams& parameters) {
ChildProcess utility_process;
utility_process.set_main_thread(new UtilityThreadImpl());
- base::HighResolutionTimerManager hi_res_timer_manager;
+ // Both utility process and service utility process would come
+ // here, but the later is launched without connection to service manager, so
+ // there has no base::PowerMonitor be created(See ChildThreadImpl::Init()).
+ // As base::PowerMonitor is necessary to base::HighResolutionTimerManager, for
+ // such case we just disable base::HighResolutionTimerManager for now.
+ // Note that disabling base::HighResolutionTimerManager means high resolution
+ // timer is always disabled no matter on battery or not, but it should have
+ // no any bad influence because currently service utility process is not using
+ // any high resolution timer.
+ // TODO(leonhsl): Once http://crbug.com/646833 got resolved, re-enable
+ // base::HighResolutionTimerManager here for future possible usage of high
+ // resolution timer in service utility process.
+ base::Optional<base::HighResolutionTimerManager> hi_res_timer_manager;
+ if (base::PowerMonitor::Get()) {
+ hi_res_timer_manager.emplace();
+ }
#if defined(OS_WIN)
bool no_sandbox = parameters.command_line.HasSwitch(switches::kNoSandbox);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698