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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <X11/Xlib.h> 5 #include <X11/Xlib.h>
6 #include <X11/extensions/dpms.h> 6 #include <X11/extensions/dpms.h>
7 #include <X11/extensions/scrnsaver.h> 7 #include <X11/extensions/scrnsaver.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 14 matching lines...) Expand all
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/macros.h" 26 #include "base/macros.h"
27 #include "base/memory/ref_counted.h" 27 #include "base/memory/ref_counted.h"
28 #include "base/memory/singleton.h" 28 #include "base/memory/singleton.h"
29 #include "base/nix/xdg_util.h" 29 #include "base/nix/xdg_util.h"
30 #include "base/synchronization/lock.h" 30 #include "base/synchronization/lock.h"
31 #include "dbus/bus.h" 31 #include "dbus/bus.h"
32 #include "dbus/message.h" 32 #include "dbus/message.h"
33 #include "dbus/object_path.h" 33 #include "dbus/object_path.h"
34 #include "dbus/object_proxy.h" 34 #include "dbus/object_proxy.h"
35 #include "ui/gfx/switches.h"
35 #include "ui/gfx/x/x11_types.h" 36 #include "ui/gfx/x/x11_types.h"
36 37
37 namespace { 38 namespace {
38 39
39 enum DBusAPI { 40 enum DBusAPI {
40 NO_API, // Disable. No supported API available. 41 NO_API, // Disable. No supported API available.
41 GNOME_API, // Use the GNOME API. (Supports more features.) 42 GNOME_API, // Use the GNOME API. (Supports more features.)
42 FREEDESKTOP_API, // Use the FreeDesktop API, for KDE4, KDE5, and XFCE. 43 FREEDESKTOP_API, // Use the FreeDesktop API, for KDE4, KDE5, and XFCE.
43 }; 44 };
44 45
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 const std::string& description, 480 const std::string& description,
480 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, 481 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
481 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner) 482 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner)
482 : delegate_(new Delegate(type, 483 : delegate_(new Delegate(type,
483 description, 484 description,
484 false /* freedesktop_only */, 485 false /* freedesktop_only */,
485 ui_task_runner, 486 ui_task_runner,
486 blocking_task_runner)), 487 blocking_task_runner)),
487 ui_task_runner_(ui_task_runner), 488 ui_task_runner_(ui_task_runner),
488 blocking_task_runner_(blocking_task_runner) { 489 blocking_task_runner_(blocking_task_runner) {
490 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless))
hashimoto 2017/01/17 02:08:12 1. Instead of adding if to the ctor and the dtor,
Sami 2017/01/17 13:44:29 Good idea, done. (Note that I had to do the same t
491 return;
489 delegate_->Init(); 492 delegate_->Init();
490 493
491 if (type == kPowerSaveBlockPreventDisplaySleep) { 494 if (type == kPowerSaveBlockPreventDisplaySleep) {
492 freedesktop_suspend_delegate_ = new Delegate( 495 freedesktop_suspend_delegate_ = new Delegate(
493 kPowerSaveBlockPreventAppSuspension, description, 496 kPowerSaveBlockPreventAppSuspension, description,
494 true /* freedesktop_only */, ui_task_runner, blocking_task_runner); 497 true /* freedesktop_only */, ui_task_runner, blocking_task_runner);
495 freedesktop_suspend_delegate_->Init(); 498 freedesktop_suspend_delegate_->Init();
496 } 499 }
497 } 500 }
498 501
499 PowerSaveBlocker::~PowerSaveBlocker() { 502 PowerSaveBlocker::~PowerSaveBlocker() {
503 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kHeadless))
504 return;
500 delegate_->CleanUp(); 505 delegate_->CleanUp();
501 if (freedesktop_suspend_delegate_) 506 if (freedesktop_suspend_delegate_)
502 freedesktop_suspend_delegate_->CleanUp(); 507 freedesktop_suspend_delegate_->CleanUp();
503 } 508 }
504 509
505 } // namespace device 510 } // namespace device
OLDNEW
« device/power_save_blocker/DEPS ('K') | « device/power_save_blocker/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698