Roll WebRTC 9189:9205, Libjingle 9186:9198
[chromium-blink-merge.git] / content / renderer / input / input_handler_manager.h
bloba44dc2dc97ed9b4cf61e2f8f6992865db1e68bb0
1 // Copyright 2013 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 CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_
6 #define CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_
8 #include "base/containers/scoped_ptr_hash_map.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/common/input/input_event_ack_state.h"
12 #include "content/renderer/render_view_impl.h"
14 namespace base {
15 class MessageLoopProxy;
18 namespace cc {
19 class InputHandler;
20 struct InputHandlerScrollResult;
23 namespace blink {
24 class WebInputEvent;
25 class WebMouseWheelEvent;
28 namespace scheduler {
29 class RendererScheduler;
32 namespace content {
34 class InputHandlerWrapper;
35 class InputHandlerManagerClient;
36 struct DidOverscrollParams;
38 // InputHandlerManager class manages InputHandlerProxy instances for
39 // the WebViews in this renderer.
40 class InputHandlerManager {
41 public:
42 // |message_loop_proxy| is the MessageLoopProxy of the compositor thread. The
43 // underlying MessageLoop and supplied |client| and the |renderer_scheduler|
44 // must outlive this object. The RendererScheduler needs to know when input
45 // events and fling animations occur, which is why it's passed in here.
46 InputHandlerManager(
47 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy,
48 InputHandlerManagerClient* client,
49 scheduler::RendererScheduler* renderer_scheduler);
50 ~InputHandlerManager();
52 // Callable from the main thread only.
53 void AddInputHandler(
54 int routing_id,
55 const base::WeakPtr<cc::InputHandler>& input_handler,
56 const base::WeakPtr<RenderViewImpl>& render_view_impl);
58 void ObserveWheelEventAndResultOnMainThread(
59 int routing_id,
60 const blink::WebMouseWheelEvent& wheel_event,
61 const cc::InputHandlerScrollResult& scroll_result);
63 // Callback only from the compositor's thread.
64 void RemoveInputHandler(int routing_id);
66 // Called from the compositor's thread.
67 InputEventAckState HandleInputEvent(int routing_id,
68 const blink::WebInputEvent* input_event,
69 ui::LatencyInfo* latency_info);
71 // Called from the compositor's thread.
72 void DidOverscroll(int routing_id, const DidOverscrollParams& params);
74 // Called from the compositor's thread.
75 void DidStopFlinging(int routing_id);
77 // Called from the compositor's thread.
78 void DidReceiveInputEvent(const blink::WebInputEvent& web_input_event);
80 // Called from the compositor's thread.
81 void DidAnimateForInput();
83 private:
84 // Called from the compositor's thread.
85 void AddInputHandlerOnCompositorThread(
86 int routing_id,
87 const scoped_refptr<base::MessageLoopProxy>& main_loop,
88 const base::WeakPtr<cc::InputHandler>& input_handler,
89 const base::WeakPtr<RenderViewImpl>& render_view_impl);
91 void ObserveWheelEventAndResultOnCompositorThread(
92 int routing_id,
93 const blink::WebMouseWheelEvent& wheel_event,
94 const cc::InputHandlerScrollResult& scroll_result);
96 typedef base::ScopedPtrHashMap<int, // routing_id
97 scoped_ptr<InputHandlerWrapper>>
98 InputHandlerMap;
99 InputHandlerMap input_handlers_;
101 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
102 InputHandlerManagerClient* client_;
103 scheduler::RendererScheduler* renderer_scheduler_; // Not owned.
106 } // namespace content
108 #endif // CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_