Add ICU message format support
[chromium-blink-merge.git] / content / renderer / input / input_handler_manager.h
blob0a8574af0b91a7c97ec3f0db5f8c147bcc5deb09
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 SingleThreadTaskRunner;
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 // |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.
46 InputHandlerManager(
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.
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 DidAnimateForInput();
80 private:
81 // Called from the compositor's thread.
82 void AddInputHandlerOnCompositorThread(
83 int routing_id,
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(
89 int routing_id,
90 const blink::WebMouseWheelEvent& wheel_event,
91 const cc::InputHandlerScrollResult& scroll_result);
93 typedef base::ScopedPtrHashMap<int, // routing_id
94 scoped_ptr<InputHandlerWrapper>>
95 InputHandlerMap;
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_