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 SingleThreadTaskRunner
;
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 // |task_runner| is the SingleThreadTaskRunner 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::SingleThreadTaskRunner
>& task_runner
,
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 DidAnimateForInput();
81 // Called from the compositor's thread.
82 void AddInputHandlerOnCompositorThread(
84 const scoped_refptr
<base::SingleThreadTaskRunner
>& main_task_runner
,
85 const base::WeakPtr
<cc::InputHandler
>& input_handler
,
86 const base::WeakPtr
<RenderViewImpl
>& render_view_impl
);
88 void ObserveWheelEventAndResultOnCompositorThread(
90 const blink::WebMouseWheelEvent
& wheel_event
,
91 const cc::InputHandlerScrollResult
& scroll_result
);
93 typedef base::ScopedPtrHashMap
<int, // routing_id
94 scoped_ptr
<InputHandlerWrapper
>>
96 InputHandlerMap input_handlers_
;
98 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
99 InputHandlerManagerClient
* client_
;
100 scheduler::RendererScheduler
* renderer_scheduler_
; // Not owned.
103 } // namespace content
105 #endif // CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_