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

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

Issue 1636163002: Restructure contents of blimp/client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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 namespace client {
19
20 class BlimpInputManagerClient {
21 public:
22 virtual void SendWebInputEvent(
23 const blink::WebInputEvent& input_event) = 0;
24 };
25
26 // The BlimpInputManager handles input events for a specific web widget. The
27 // class processes ui::events to generate web input events which are forwarded
28 // to the compositor to be handled on the compositor thread. If the event can
29 // not be handled locally by the compositor, it is given to the
30 // BlimpInputManagerClient to be sent to the engine.
31 //
32 // The BlimpInputManager is created and destroyed on the main thread but can be
33 // called from the main or compositor thread. It is safe for the
34 // BlimpInputManager to be called on the compositor thread because:
35 // 1) The only compositor threaded callers of the BlimpInputManager are the
36 // BlimpInputManager itself.
37 // 2) BlimpInputManager blocks the main thread in its dtor to ensure that all
38 // tasks queued to call it on the compositor thread have been run before it is
39 // destroyed on the main thread.
40 //
41 // It is *important* to destroy the cc::InputHandler on the compositor thread
42 // before destroying the BlimpInputManager.
43
44 class BlimpInputManager : public ui::GestureProviderClient {
45 public:
46 static scoped_ptr<BlimpInputManager> Create(
47 BlimpInputManagerClient* client,
48 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
49 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
50 const base::WeakPtr<cc::InputHandler>& input_handler);
51
52 ~BlimpInputManager() override;
53
54 // Called to process a ui::MotionEvent. Returns true if the event was
55 // successfully processed.
56 bool OnTouchEvent(const ui::MotionEvent& motion_event);
57
58 // Called by the BlimpInputHandlerWrapper after an input event was handled on
59 // the compositor thread.
60 // |consumed| is false if the event was not handled by the compositor and
61 // should be sent to the engine.
62 void DidHandleWebInputEvent(scoped_ptr<blink::WebInputEvent> input_event,
63 bool consumed);
64
65 private:
66 BlimpInputManager(
67 BlimpInputManagerClient* client,
68 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
69 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
70 const base::WeakPtr<cc::InputHandler>& input_handler);
71
72 // ui::GestureProviderClient implementation.
73 void OnGestureEvent(const ui::GestureEventData& gesture) override;
74
75 // Called on the compositor thread.
76 void CreateInputHandlerWrapperOnCompositorThread(
77 base::WeakPtr<BlimpInputManager> input_manager_weak_ptr,
78 const base::WeakPtr<cc::InputHandler>& input_handler);
79 void HandleWebInputEventOnCompositorThread(
80 scoped_ptr<blink::WebInputEvent> input_event);
81 void ShutdownOnCompositorThread(base::WaitableEvent* shutdown_event);
82
83 bool IsMainThread() const;
84 bool IsCompositorThread() const;
85
86 BlimpInputManagerClient* client_;
87
88 ui::FilteredGestureProvider gesture_provider_;
89
90 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
91 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
92
93 // Used for debug assertions to ensure that the main thread is blocked during
94 // shutdown. Set in the destructor before the main thread is blocked and
95 // read in ShutdownOnCompositorThread.
96 bool main_thread_blocked_;
97
98 scoped_ptr<BlimpInputHandlerWrapper> input_handler_wrapper_;
99
100 base::WeakPtrFactory<BlimpInputManager> weak_factory_;
101
102 DISALLOW_COPY_AND_ASSIGN(BlimpInputManager);
103 };
104
105 } // namespace client
106 } // namespace blimp
107
108 #endif // BLIMP_CLIENT_INPUT_BLIMP_INPUT_MANAGER_H_
OLDNEW
« no previous file with comments | « blimp/client/input/blimp_input_handler_wrapper.cc ('k') | blimp/client/input/blimp_input_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698