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

Unified Diff: remoting/host/host_power_save_blocker.cc

Issue 2080723008: [Chromoting] Use device::PowerSaveBlocker to block screen saver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments Created 4 years, 5 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 | « remoting/host/host_power_save_blocker.h ('k') | remoting/host/host_power_save_blocker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/host_power_save_blocker.cc
diff --git a/remoting/host/host_power_save_blocker.cc b/remoting/host/host_power_save_blocker.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c93f71c74e3bc94d2add624106ef341eb9794fa8
--- /dev/null
+++ b/remoting/host/host_power_save_blocker.cc
@@ -0,0 +1,45 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/host_power_save_blocker.h"
+
+#include <utility>
+
+#include "base/logging.h"
+#include "base/single_thread_task_runner.h"
+#include "remoting/host/host_status_monitor.h"
+
+namespace remoting {
+
+HostPowerSaveBlocker::HostPowerSaveBlocker(
+ base::WeakPtr<HostStatusMonitor> monitor,
+ const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
+ const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner)
+ : monitor_(monitor),
+ ui_task_runner_(ui_task_runner),
+ file_task_runner_(file_task_runner) {
+ DCHECK(monitor_);
+ monitor_->AddStatusObserver(this);
+}
+
+HostPowerSaveBlocker::~HostPowerSaveBlocker() {
+ if (monitor_.get()) {
+ monitor_->RemoveStatusObserver(this);
+ }
+}
+
+void HostPowerSaveBlocker::OnClientConnected(const std::string& jid) {
+ blocker_.reset(new device::PowerSaveBlocker(
+ device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
+ device::PowerSaveBlocker::kReasonOther,
+ "Remoting session is active",
+ ui_task_runner_,
+ file_task_runner_));
+}
+
+void HostPowerSaveBlocker::OnClientDisconnected(const std::string& jid) {
+ blocker_.reset();
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/host_power_save_blocker.h ('k') | remoting/host/host_power_save_blocker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698