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

Unified Diff: remoting/host/screen_saver_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
Index: remoting/host/screen_saver_blocker.cc
diff --git a/remoting/host/screen_saver_blocker.cc b/remoting/host/screen_saver_blocker.cc
new file mode 100644
index 0000000000000000000000000000000000000000..692de054e498c24b4b6ccc6ad15d89d0f982de29
--- /dev/null
+++ b/remoting/host/screen_saver_blocker.cc
@@ -0,0 +1,43 @@
+// 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/screen_saver_blocker.h"
+
+#include <utility>
+
+#include "base/logging.h"
+#include "remoting/base/auto_thread_task_runner.h"
+#include "remoting/host/host_status_monitor.h"
+
+namespace remoting {
+
+ScreenSaverBlocker::ScreenSaverBlocker(
+ base::WeakPtr<HostStatusMonitor> monitor,
+ std::unique_ptr<ChromotingHostContext>&& context)
+ : monitor_(monitor),
+ context_(std::move(context)) {
+ DCHECK(monitor_);
+ monitor_->AddStatusObserver(this);
+}
+
+ScreenSaverBlocker::~ScreenSaverBlocker() {
+ if (monitor_.get()) {
+ monitor_->RemoveStatusObserver(this);
+ }
+}
+
+void ScreenSaverBlocker::OnClientConnected(const std::string& jid) {
+ blocker_.reset(new device::PowerSaveBlocker(
+ device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
+ device::PowerSaveBlocker::kReasonVideoPlayback,
Sergey Ulanov 2016/07/08 21:31:47 Why not kReasonOther?
Hzj_jie 2016/07/10 22:04:57 Done.
+ "Remoting session is active",
+ context_->ui_task_runner(),
+ context_->file_task_runner()));
+}
+
+void ScreenSaverBlocker::OnClientDisconnected(const std::string& jid) {
+ blocker_.reset();
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698