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

Unified Diff: device/power_save_blocker/power_save_blocker_x11.cc

Issue 2631153003: power save blocker: Don't try to block power saving in headless mode (Closed)
Patch Set: Add comments 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 | « device/power_save_blocker/DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/power_save_blocker/power_save_blocker_x11.cc
diff --git a/device/power_save_blocker/power_save_blocker_x11.cc b/device/power_save_blocker/power_save_blocker_x11.cc
index 286e042b9bd588f93515a6820beaecace9ee8532..8c96590eaab5f29bf88ce0662560af775c9dc893 100644
--- a/device/power_save_blocker/power_save_blocker_x11.cc
+++ b/device/power_save_blocker/power_save_blocker_x11.cc
@@ -32,6 +32,7 @@
#include "dbus/message.h"
#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
+#include "ui/gfx/switches.h"
#include "ui/gfx/x/x11_types.h"
namespace {
@@ -436,6 +437,9 @@ bool PowerSaveBlocker::Delegate::DPMSEnabled() {
bool PowerSaveBlocker::Delegate::XSSAvailable() {
DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
+ // X Screen Saver isn't accessible in headless mode.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless))
+ return false;
XDisplay* display = gfx::GetXDisplay();
int dummy;
int major;
@@ -452,6 +456,9 @@ bool PowerSaveBlocker::Delegate::XSSAvailable() {
DBusAPI PowerSaveBlocker::Delegate::SelectAPI() {
DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
+ // Power saving APIs are not accessible in headless mode.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless))
+ return NO_API;
std::unique_ptr<base::Environment> env(base::Environment::Create());
switch (base::nix::GetDesktopEnvironment(env.get())) {
case base::nix::DESKTOP_ENVIRONMENT_GNOME:
« no previous file with comments | « device/power_save_blocker/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698