Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: remoting/host/resizing_host_observer.h

Issue 15927033: Add host-side rate-limiting to desktop resize events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/me2me_desktop_environment.cc ('k') | remoting/host/resizing_host_observer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/resizing_host_observer.h
diff --git a/remoting/host/resizing_host_observer.h b/remoting/host/resizing_host_observer.h
index 2682d76627d8ee208030646f61de3983a0052f42..301321ce0a40ca9387abaa113f16723f0368022b 100644
--- a/remoting/host/resizing_host_observer.h
+++ b/remoting/host/resizing_host_observer.h
@@ -6,15 +6,19 @@
#define REMOTING_HOST_RESIZING_HOST_OBSERVER_H_
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/time.h"
+#include "base/timer.h"
#include "remoting/host/screen_controls.h"
+#include "remoting/host/screen_resolution.h"
#include "third_party/skia/include/core/SkSize.h"
namespace remoting {
class DesktopResizer;
-class ScreenResolution;
// TODO(alexeypa): Rename this class to reflect that it is not
// HostStatusObserver any more.
@@ -30,10 +34,23 @@ class ResizingHostObserver : public ScreenControls {
// ScreenControls interface.
virtual void SetScreenResolution(const ScreenResolution& resolution) OVERRIDE;
+ // Provide a replacement for base::Time::Now so that this class can be
+ // unit-tested in a timely manner. This function will be called exactly
+ // once for each call to SetScreenResolution.
+ void SetNowFunctionForTesting(
+ const base::Callback<base::Time(void)>& now_function);
+
private:
scoped_ptr<DesktopResizer> desktop_resizer_;
SkISize original_size_;
+ // State to manage rate-limiting of desktop resizes.
+ base::OneShotTimer<ResizingHostObserver> deferred_resize_timer_;
+ base::Time previous_resize_time_;
+ base::Callback<base::Time(void)> now_function_;
+
+ base::WeakPtrFactory<ResizingHostObserver> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ResizingHostObserver);
};
« no previous file with comments | « remoting/host/me2me_desktop_environment.cc ('k') | remoting/host/resizing_host_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698