| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/host/host_power_save_blocker.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "remoting/host/host_status_monitor.h" |
| 12 |
| 13 namespace remoting { |
| 14 |
| 15 HostPowerSaveBlocker::HostPowerSaveBlocker( |
| 16 base::WeakPtr<HostStatusMonitor> monitor, |
| 17 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
| 18 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) |
| 19 : monitor_(monitor), |
| 20 ui_task_runner_(ui_task_runner), |
| 21 file_task_runner_(file_task_runner) { |
| 22 DCHECK(monitor_); |
| 23 monitor_->AddStatusObserver(this); |
| 24 } |
| 25 |
| 26 HostPowerSaveBlocker::~HostPowerSaveBlocker() { |
| 27 if (monitor_.get()) { |
| 28 monitor_->RemoveStatusObserver(this); |
| 29 } |
| 30 } |
| 31 |
| 32 void HostPowerSaveBlocker::OnClientConnected(const std::string& jid) { |
| 33 blocker_.reset(new device::PowerSaveBlocker( |
| 34 device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 35 device::PowerSaveBlocker::kReasonOther, |
| 36 "Remoting session is active", |
| 37 ui_task_runner_, |
| 38 file_task_runner_)); |
| 39 } |
| 40 |
| 41 void HostPowerSaveBlocker::OnClientDisconnected(const std::string& jid) { |
| 42 blocker_.reset(); |
| 43 } |
| 44 |
| 45 } // namespace remoting |
| OLD | NEW |