OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_HOST_HOST_POWER_SAVER_BLOCKER_H_ | 5 #ifndef REMOTING_HOST_HOST_POWER_SAVER_BLOCKER_H_ |
6 #define REMOTING_HOST_HOST_POWER_SAVER_BLOCKER_H_ | 6 #define REMOTING_HOST_HOST_POWER_SAVER_BLOCKER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "device/power_save_blocker/power_save_blocker.h" | 13 #include "device/power_save_blocker/power_save_blocker.h" |
14 #include "remoting/host/host_status_observer.h" | 14 #include "remoting/host/host_status_observer.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
19 | 19 |
20 } // namespace base | 20 } // namespace base |
21 | 21 |
22 namespace remoting { | 22 namespace remoting { |
23 | 23 |
24 class AutoThreadTaskRunner; | |
25 class HostStatusMonitor; | 24 class HostStatusMonitor; |
26 | 25 |
27 // A HostStatusObserver to block screen saver from taking effect during the | 26 // A HostStatusObserver to block screen saver from taking effect during the |
28 // lifetime of a remoting connection. | 27 // lifetime of a remoting connection. |
29 class HostPowerSaveBlocker : public HostStatusObserver { | 28 class HostPowerSaveBlocker : public HostStatusObserver { |
30 public: | 29 public: |
31 HostPowerSaveBlocker( | 30 HostPowerSaveBlocker( |
32 base::WeakPtr<HostStatusMonitor> monitor, | 31 base::WeakPtr<HostStatusMonitor> monitor, |
33 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, | 32 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner, |
34 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); | 33 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner); |
35 | 34 |
36 ~HostPowerSaveBlocker() override; | 35 ~HostPowerSaveBlocker() override; |
37 | 36 |
38 void OnClientConnected(const std::string& jid) override; | 37 void OnClientConnected(const std::string& jid) override; |
39 void OnClientDisconnected(const std::string& jid) override; | 38 void OnClientDisconnected(const std::string& jid) override; |
40 | 39 |
41 private: | 40 private: |
42 friend class HostPowerSaveBlockerTest; | 41 friend class HostPowerSaveBlockerTest; |
43 | 42 |
44 base::WeakPtr<HostStatusMonitor> monitor_; | 43 base::WeakPtr<HostStatusMonitor> monitor_; |
45 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 44 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
46 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | 45 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
47 std::unique_ptr<device::PowerSaveBlocker> blocker_; | 46 std::unique_ptr<device::PowerSaveBlocker> blocker_; |
48 }; | 47 }; |
49 | 48 |
50 } // namespace remoting | 49 } // namespace remoting |
51 | 50 |
52 #endif // REMOTING_HOST_HOST_POWER_SAVER_BLOCKER_H_ | 51 #endif // REMOTING_HOST_HOST_POWER_SAVER_BLOCKER_H_ |
OLD | NEW |