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
;
28 class InputHandlerWrapper
;
29 class InputHandlerManagerClient
;
30 struct DidOverscrollParams
;
32 // InputHandlerManager class manages InputHandlerProxy instances for
33 // the WebViews in this renderer.
34 class InputHandlerManager
{
36 // |message_loop_proxy| is the MessageLoopProxy of the compositor thread. Both
37 // the underlying MessageLoop and supplied |client| must outlive this object.
39 const scoped_refptr
<base::MessageLoopProxy
>& message_loop_proxy
,
40 InputHandlerManagerClient
* client
);
41 ~InputHandlerManager();
43 // Callable from the main thread only.
46 const base::WeakPtr
<cc::InputHandler
>& input_handler
,
47 const base::WeakPtr
<RenderViewImpl
>& render_view_impl
);
49 // Callback only from the compositor's thread.
50 void RemoveInputHandler(int routing_id
);
52 // Called from the compositor's thread.
53 InputEventAckState
HandleInputEvent(int routing_id
,
54 const blink::WebInputEvent
* input_event
,
55 ui::LatencyInfo
* latency_info
);
57 // Called from the compositor's thread.
58 void DidOverscroll(int routing_id
, const DidOverscrollParams
& params
);
60 // Called from the compositor's thread.
61 void DidStopFlinging(int routing_id
);
64 // Called from the compositor's thread.
65 void AddInputHandlerOnCompositorThread(
67 const scoped_refptr
<base::MessageLoopProxy
>& main_loop
,
68 const base::WeakPtr
<cc::InputHandler
>& input_handler
,
69 const base::WeakPtr
<RenderViewImpl
>& render_view_impl
);
71 typedef base::ScopedPtrHashMap
<int, // routing_id
72 InputHandlerWrapper
> InputHandlerMap
;
73 InputHandlerMap input_handlers_
;
75 scoped_refptr
<base::MessageLoopProxy
> message_loop_proxy_
;
76 InputHandlerManagerClient
* client_
;
79 } // namespace content
81 #endif // CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_