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
;
31 class RendererScheduler
;
33 // InputHandlerManager class manages InputHandlerProxy instances for
34 // the WebViews in this renderer.
35 class InputHandlerManager
{
37 // |message_loop_proxy| is the MessageLoopProxy of the compositor thread. The
38 // underlying MessageLoop and supplied |client| and the |renderer_scheduler|
39 // must outlive this object. The RendererScheduler needs to know when input
40 // events and fling animations occur, which is why it's passed in here.
42 const scoped_refptr
<base::MessageLoopProxy
>& message_loop_proxy
,
43 InputHandlerManagerClient
* client
,
44 RendererScheduler
* renderer_scheduler
);
45 ~InputHandlerManager();
47 // Callable from the main thread only.
50 const base::WeakPtr
<cc::InputHandler
>& input_handler
,
51 const base::WeakPtr
<RenderViewImpl
>& render_view_impl
);
53 // Callback only from the compositor's thread.
54 void RemoveInputHandler(int routing_id
);
56 // Called from the compositor's thread.
57 InputEventAckState
HandleInputEvent(int routing_id
,
58 const blink::WebInputEvent
* input_event
,
59 ui::LatencyInfo
* latency_info
);
61 // Called from the compositor's thread.
62 void DidOverscroll(int routing_id
, const DidOverscrollParams
& params
);
64 // Called from the compositor's thread.
65 void DidStopFlinging(int routing_id
);
67 // Called from the compositor's thread.
68 void DidReceiveInputEvent(blink::WebInputEvent::Type type
);
70 // Called from the compositor's thread.
71 void DidAnimateForInput();
74 // Called from the compositor's thread.
75 void AddInputHandlerOnCompositorThread(
77 const scoped_refptr
<base::MessageLoopProxy
>& main_loop
,
78 const base::WeakPtr
<cc::InputHandler
>& input_handler
,
79 const base::WeakPtr
<RenderViewImpl
>& render_view_impl
);
81 typedef base::ScopedPtrHashMap
<int, // routing_id
82 InputHandlerWrapper
> InputHandlerMap
;
83 InputHandlerMap input_handlers_
;
85 scoped_refptr
<base::MessageLoopProxy
> message_loop_proxy_
;
86 InputHandlerManagerClient
* client_
;
87 RendererScheduler
* renderer_scheduler_
; // Not owned.
90 } // namespace content
92 #endif // CONTENT_RENDERER_INPUT_INPUT_HANDLER_MANAGER_H_