Chromium Code Reviews| 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 |