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

Side by Side Diff: blimp/client/feature/compositor/blimp_input_manager.h

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

Powered by Google App Engine
This is Rietveld 408576698