summaryrefslogtreecommitdiffstats
path: root/content/browser/renderer_host/synthetic_gesture_controller.h
blob: 8826aaddf3a1e6387f23760f1a2b679b2f61aa65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_RENDERER_HOST_SYNTHETIC_GESTURE_CONTROLLER_H_
#define CONTENT_BROWSER_RENDERER_HOST_SYNTHETIC_GESTURE_CONTROLLER_H_

#include <map>

#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "content/common/content_export.h"

struct ViewHostMsg_BeginPinch_Params;
struct ViewHostMsg_BeginSmoothScroll_Params;

namespace content {

class RenderWidgetHost;
class RenderWidgetHostViewPort;
class SyntheticGesture;

// Controls SyntheticGestures, used to inject synthetic events
// for performance test harness.
class CONTENT_EXPORT SyntheticGestureController {
 public:
  SyntheticGestureController();
  ~SyntheticGestureController();

  // Initiates a synthetic event stream to simulate a smooth scroll.
  void BeginSmoothScroll(RenderWidgetHostViewPort* view,
                         const ViewHostMsg_BeginSmoothScroll_Params& params);

  // Initiates a synthetic event stream to simulate a pinch-to-zoom.
  void BeginPinch(RenderWidgetHostViewPort* view,
                  const ViewHostMsg_BeginPinch_Params& params);

  base::TimeDelta GetSyntheticGestureMessageInterval() const;

 private:
  // Called periodically to advance the active scroll gesture after being
  // initiated by OnBeginSmoothScroll.
  void OnTimer();

  base::RepeatingTimer<SyntheticGestureController> timer_;

  RenderWidgetHost* rwh_;

  scoped_refptr<SyntheticGesture> pending_synthetic_gesture_;

  DISALLOW_COPY_AND_ASSIGN(SyntheticGestureController);
};

}  // namespace content

#endif  // CONTENT_BROWSER_RENDERER_HOST_SYNTHETIC_GESTURE_CONTROLLER_H_