Chromium Code Reviews| 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..544926e7b7f22e69c88676ed875ff26e32d4af75 |
| --- /dev/null |
| +++ b/remoting/host/host_power_save_blocker.cc |
| @@ -0,0 +1,44 @@ |
| +// 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 "remoting/base/auto_thread_task_runner.h" |
| +#include "remoting/host/host_status_monitor.h" |
| + |
| +namespace remoting { |
| + |
| +HostPowerSaveBlocker::HostPowerSaveBlocker( |
| + base::WeakPtr<HostStatusMonitor> monitor, |
| + const ChromotingHostContext& context) |
|
Sergey Ulanov
2016/07/13 04:57:05
Please replace this parameter with two task runner
Hzj_jie
2016/07/13 20:27:13
Done.
|
| + : monitor_(monitor), |
| + ui_task_runner_(context.ui_task_runner()), |
| + file_task_runner_(context.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 |