Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / remoting / host / resizing_host_observer.h
blobc6ad714835ac391f6d1c963e99dbb85fca598092
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_HOST_RESIZING_HOST_OBSERVER_H_
6 #define REMOTING_HOST_RESIZING_HOST_OBSERVER_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h"
14 #include "base/timer/timer.h"
15 #include "remoting/host/screen_controls.h"
16 #include "remoting/host/screen_resolution.h"
18 namespace remoting {
20 class DesktopResizer;
22 // TODO(alexeypa): Rename this class to reflect that it is not
23 // HostStatusObserver any more.
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
27 // the original desktop size.
28 class ResizingHostObserver : public ScreenControls {
29 public:
30 explicit ResizingHostObserver(scoped_ptr<DesktopResizer> desktop_resizer);
31 virtual ~ResizingHostObserver();
33 // ScreenControls interface.
34 virtual void SetScreenResolution(const ScreenResolution& resolution) OVERRIDE;
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
38 // once for each call to SetScreenResolution.
39 void SetNowFunctionForTesting(
40 const base::Callback<base::Time(void)>& now_function);
42 private:
43 scoped_ptr<DesktopResizer> desktop_resizer_;
44 ScreenResolution original_resolution_;
46 // State to manage rate-limiting of desktop resizes.
47 base::OneShotTimer<ResizingHostObserver> deferred_resize_timer_;
48 base::Time previous_resize_time_;
49 base::Callback<base::Time(void)> now_function_;
51 base::WeakPtrFactory<ResizingHostObserver> weak_factory_;
53 DISALLOW_COPY_AND_ASSIGN(ResizingHostObserver);
56 } // namespace remoting
58 #endif // REMOTING_HOST_RESIZING_HOST_OBSERVER_H_