| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 // Uses the specified DesktopResizer to match host desktop size to the client | 25 // Uses the specified DesktopResizer to match host desktop size to the client |
| 26 // view size as closely as is possible. When the connection closes, restores | 26 // view size as closely as is possible. When the connection closes, restores |
| 27 // the original desktop size. | 27 // the original desktop size. |
| 28 class ResizingHostObserver : public ScreenControls { | 28 class ResizingHostObserver : public ScreenControls { |
| 29 public: | 29 public: |
| 30 explicit ResizingHostObserver(scoped_ptr<DesktopResizer> desktop_resizer); | 30 explicit ResizingHostObserver(scoped_ptr<DesktopResizer> desktop_resizer); |
| 31 virtual ~ResizingHostObserver(); | 31 virtual ~ResizingHostObserver(); |
| 32 | 32 |
| 33 // ScreenControls interface. | 33 // ScreenControls interface. |
| 34 virtual void SetScreenResolution(const ScreenResolution& resolution) OVERRIDE; | 34 virtual void SetScreenResolution(const ScreenResolution& resolution) override; |
| 35 | 35 |
| 36 // Provide a replacement for base::Time::Now so that this class can be | 36 // Provide a replacement for base::Time::Now so that this class can be |
| 37 // unit-tested in a timely manner. This function will be called exactly | 37 // unit-tested in a timely manner. This function will be called exactly |
| 38 // once for each call to SetScreenResolution. | 38 // once for each call to SetScreenResolution. |
| 39 void SetNowFunctionForTesting( | 39 void SetNowFunctionForTesting( |
| 40 const base::Callback<base::Time(void)>& now_function); | 40 const base::Callback<base::Time(void)>& now_function); |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 scoped_ptr<DesktopResizer> desktop_resizer_; | 43 scoped_ptr<DesktopResizer> desktop_resizer_; |
| 44 ScreenResolution original_resolution_; | 44 ScreenResolution original_resolution_; |
| 45 | 45 |
| 46 // State to manage rate-limiting of desktop resizes. | 46 // State to manage rate-limiting of desktop resizes. |
| 47 base::OneShotTimer<ResizingHostObserver> deferred_resize_timer_; | 47 base::OneShotTimer<ResizingHostObserver> deferred_resize_timer_; |
| 48 base::Time previous_resize_time_; | 48 base::Time previous_resize_time_; |
| 49 base::Callback<base::Time(void)> now_function_; | 49 base::Callback<base::Time(void)> now_function_; |
| 50 | 50 |
| 51 base::WeakPtrFactory<ResizingHostObserver> weak_factory_; | 51 base::WeakPtrFactory<ResizingHostObserver> weak_factory_; |
| 52 | 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(ResizingHostObserver); | 53 DISALLOW_COPY_AND_ASSIGN(ResizingHostObserver); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace remoting | 56 } // namespace remoting |
| 57 | 57 |
| 58 #endif // REMOTING_HOST_RESIZING_HOST_OBSERVER_H_ | 58 #endif // REMOTING_HOST_RESIZING_HOST_OBSERVER_H_ |
| OLD | NEW |