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"
15 class MessageLoopProxy
;
20 struct InputHandlerScrollResult
;
25 class WebMouseWheelEvent
;
29 class RendererScheduler
;
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
{
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.
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.
55 const base::WeakPtr
<cc::InputHandler
>& input_handler
,
56 const base::WeakPtr
<RenderViewImpl
>& render_view_impl
);
58 void ObserveWheelEventAndResultOnMainThread(
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();
84 // Called from the compositor's thread.
85 void AddInputHandlerOnCompositorThread(
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(
93 const blink::WebMouseWheelEvent
& wheel_event
,
94 const cc::InputHandlerScrollResult
& scroll_result
);
96 typedef base::ScopedPtrHashMap
<int, // routing_id
97 scoped_ptr
<InputHandlerWrapper
>>
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_