| 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/sequenced_task_runner.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "remoting/host/host_status_monitor.h" |
| 13 |
| 14 namespace remoting { |
| 15 |
| 16 HostPowerSaveBlocker::HostPowerSaveBlocker( |
| 17 base::WeakPtr<HostStatusMonitor> monitor, |
| 18 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, |
| 19 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) |
| 20 : monitor_(monitor), |
| 21 ui_task_runner_(ui_task_runner), |
| 22 file_task_runner_(file_task_runner) { |
| 23 DCHECK(monitor_); |
| 24 monitor_->AddStatusObserver(this); |
| 25 } |
| 26 |
| 27 HostPowerSaveBlocker::~HostPowerSaveBlocker() { |
| 28 if (monitor_.get()) { |
| 29 monitor_->RemoveStatusObserver(this); |
| 30 } |
| 31 } |
| 32 |
| 33 void HostPowerSaveBlocker::OnClientConnected(const std::string& jid) { |
| 34 blocker_.reset(new device::PowerSaveBlocker( |
| 35 device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 36 device::PowerSaveBlocker::kReasonOther, |
| 37 "Remoting session is active", |
| 38 ui_task_runner_, |
| 39 file_task_runner_)); |
| 40 } |
| 41 |
| 42 void HostPowerSaveBlocker::OnClientDisconnected(const std::string& jid) { |
| 43 blocker_.reset(); |
| 44 } |
| 45 |
| 46 } // namespace remoting |
| OLD | NEW |