OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_RESIZING_HOST_OBSERVER_H_ | 5 #ifndef REMOTING_HOST_RESIZING_HOST_OBSERVER_H_ |
6 #define REMOTING_HOST_RESIZING_HOST_OBSERVER_H_ | 6 #define REMOTING_HOST_RESIZING_HOST_OBSERVER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <memory> |
| 11 |
10 #include "base/callback.h" | 12 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
12 #include "base/macros.h" | 14 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
16 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
17 #include "remoting/host/screen_controls.h" | 18 #include "remoting/host/screen_controls.h" |
18 #include "remoting/host/screen_resolution.h" | 19 #include "remoting/host/screen_resolution.h" |
19 | 20 |
20 namespace remoting { | 21 namespace remoting { |
21 | 22 |
22 class DesktopResizer; | 23 class DesktopResizer; |
23 | 24 |
24 // TODO(alexeypa): Rename this class to reflect that it is not | 25 // TODO(alexeypa): Rename this class to reflect that it is not |
25 // HostStatusObserver any more. | 26 // HostStatusObserver any more. |
26 | 27 |
27 // Uses the specified DesktopResizer to match host desktop size to the client | 28 // Uses the specified DesktopResizer to match host desktop size to the client |
28 // view size as closely as is possible. When the connection closes, restores | 29 // view size as closely as is possible. When the connection closes, restores |
29 // the original desktop size. | 30 // the original desktop size. |
30 class ResizingHostObserver : public ScreenControls { | 31 class ResizingHostObserver : public ScreenControls { |
31 public: | 32 public: |
32 explicit ResizingHostObserver(scoped_ptr<DesktopResizer> desktop_resizer); | 33 explicit ResizingHostObserver( |
| 34 std::unique_ptr<DesktopResizer> desktop_resizer); |
33 ~ResizingHostObserver() override; | 35 ~ResizingHostObserver() override; |
34 | 36 |
35 // ScreenControls interface. | 37 // ScreenControls interface. |
36 void SetScreenResolution(const ScreenResolution& resolution) override; | 38 void SetScreenResolution(const ScreenResolution& resolution) override; |
37 | 39 |
38 // Provide a replacement for base::Time::Now so that this class can be | 40 // Provide a replacement for base::Time::Now so that this class can be |
39 // unit-tested in a timely manner. This function will be called exactly | 41 // unit-tested in a timely manner. This function will be called exactly |
40 // once for each call to SetScreenResolution. | 42 // once for each call to SetScreenResolution. |
41 void SetNowFunctionForTesting( | 43 void SetNowFunctionForTesting( |
42 const base::Callback<base::Time(void)>& now_function); | 44 const base::Callback<base::Time(void)>& now_function); |
43 | 45 |
44 private: | 46 private: |
45 scoped_ptr<DesktopResizer> desktop_resizer_; | 47 std::unique_ptr<DesktopResizer> desktop_resizer_; |
46 ScreenResolution original_resolution_; | 48 ScreenResolution original_resolution_; |
47 | 49 |
48 // State to manage rate-limiting of desktop resizes. | 50 // State to manage rate-limiting of desktop resizes. |
49 base::OneShotTimer deferred_resize_timer_; | 51 base::OneShotTimer deferred_resize_timer_; |
50 base::Time previous_resize_time_; | 52 base::Time previous_resize_time_; |
51 base::Callback<base::Time(void)> now_function_; | 53 base::Callback<base::Time(void)> now_function_; |
52 | 54 |
53 base::WeakPtrFactory<ResizingHostObserver> weak_factory_; | 55 base::WeakPtrFactory<ResizingHostObserver> weak_factory_; |
54 | 56 |
55 DISALLOW_COPY_AND_ASSIGN(ResizingHostObserver); | 57 DISALLOW_COPY_AND_ASSIGN(ResizingHostObserver); |
56 }; | 58 }; |
57 | 59 |
58 } // namespace remoting | 60 } // namespace remoting |
59 | 61 |
60 #endif // REMOTING_HOST_RESIZING_HOST_OBSERVER_H_ | 62 #endif // REMOTING_HOST_RESIZING_HOST_OBSERVER_H_ |
OLD | NEW |