Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: blimp/client/input/blimp_input_manager.h

Issue 1430623004: blimp: Add support for input handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move all input handling on compositor thread to BlimpInputHandlerWrapper. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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.
4
5 #ifndef BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_
6 #define BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/synchronization/waitable_event.h"
12 #include "blimp/client/input/blimp_input_handler_wrapper.h"
13 #include "third_party/WebKit/public/web/WebInputEvent.h"
14 #include "ui/events/gesture_detection/filtered_gesture_provider.h"
15 #include "ui/events/gesture_detection/motion_event.h"
16
17 namespace blimp {
18
19 class BlimpInputManagerClient {
20 public:
21 virtual void SendWebInputEvent(
22 const blink::WebInputEvent& input_event) = 0;
23 };
24
25 // The BlimpInputManager handles input events for a specific render widget. The
26 // class processes ui::events to generate web input events which are forwarded
27 // to the compositor to be handled on the compositor thread. If the event can
28 // not be handled locally by the compositor, it is given to the
29 // BlimpInputManagerClient to be sent to the engine.
30 //
31 // The BlimpInputManager is created and destroyed on the main thread but can be
32 // called from the main or compositor thread. It is safe for the
33 // BlimpInputManager to be called on the compositor thread because:
34 // 1) The only compositor threaded callers of the BlimpInputManager are the
35 // BlimpInputManager itself.
36 // 2) BlimpInputManager blocks the main thread in its dtor to ensure that all
37 // tasks queued to call it on the compositor thread have been run before it is
38 // destroyed on the main thread.
39 class BlimpInputManager : public ui::GestureProviderClient {
40 public:
41 static scoped_ptr<BlimpInputManager> Create(
42 BlimpInputManagerClient* client,
43 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
44 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
45 const base::WeakPtr<cc::InputHandler>& input_handler);
46
47 ~BlimpInputManager();
48
49 // Called to process a ui::MotionEvent. Returns true if the event was
50 // successfully processed.
51 bool OnTouchEvent(const ui::MotionEvent& motion_event);
52
53 // Called by the BlimpInputHandlerWrapper after an input event was handled on
54 // the compositor thread.
55 // consumed is false if the event was not handled by the compositor and should
nyquist 2015/12/05 01:54:42 |consumed|
Khushal 2015/12/07 23:01:22 Done.
56 // be sent to the engine.
57 void DidHandleWebInputEvent(const blink::WebInputEvent& input_event,
58 bool consumed);
59
60 private:
61 BlimpInputManager(
62 BlimpInputManagerClient* client,
63 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
64 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
65 const base::WeakPtr<cc::InputHandler>& input_handler);
66
67 // ui::GestureProviderClient implementation.
68 void OnGestureEvent(const ui::GestureEventData& gesture) override;
69
70 // called on the compositor thread.
nyquist 2015/12/05 01:54:42 Nit: Called
Khushal 2015/12/07 23:01:22 Done.
71 void CreateInputHandlerWrapperOnCompositorThread(
72 base::WeakPtr<BlimpInputManager> input_manager_weak_ptr,
73 const base::WeakPtr<cc::InputHandler>& input_handler);
74 void HandleWebInputEventOnCompositorThread(
75 const blink::WebInputEvent& input_event);
76 void ShutdownOnCompositorThread(base::WaitableEvent* shutdown_event);
77
78 bool IsMainThread() const;
79 bool IsCompositorThread() const;
80
81 BlimpInputManagerClient* client_;
82
83 ui::FilteredGestureProvider gesture_provider_;
84
85 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
86 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
87
88 // Used for debug assertions to ensure that the main thread is blocked during
89 // shutdown. Set in the destructor before the main thread is blocked and
90 // read in ShutdownOnCompositorThread.
91 bool main_thread_blocked_;
92
93 scoped_ptr<BlimpInputHandlerWrapper> input_handler_;
nyquist 2015/12/05 01:54:42 should this be input_handler_wrapper_?
Khushal 2015/12/07 23:01:22 Yeah, that will keep things clearer. Done.
94
95 base::WeakPtrFactory<BlimpInputManager> weak_factory_;
96
97 DISALLOW_COPY_AND_ASSIGN(BlimpInputManager);
98 };
99
100 } // namespace blimp
101
102 #endif // BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698