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

Side by Side Diff: blimp/client/core/input/blimp_input_handler_wrapper.cc

Issue 2624903006: Remove all blimp client code. (Closed)
Patch Set: Update buildbot configuration Created 3 years, 11 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 #include "blimp/client/core/input/blimp_input_handler_wrapper.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
11 #include "blimp/client/core/input/blimp_input_manager.h"
12 #include "ui/events/gestures/blink/web_gesture_curve_impl.h"
13
14 namespace blimp {
15 namespace client {
16 namespace {
17
18 void CreateProxyOnCompositorThread(
19 BlimpInputHandlerWrapper* input_handler_wrapper,
20 const base::WeakPtr<cc::InputHandler>& input_handler_weak_ptr) {
21 if (!input_handler_weak_ptr)
22 return;
23
24 // If we have the input handler, the wrapper must be alive. So its safe to
25 // access it.
26 input_handler_wrapper->InitOnCompositorThread(input_handler_weak_ptr.get());
27 }
28
29 } // namespace
30
31 BlimpInputHandlerWrapper::BlimpInputHandlerWrapper(
32 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
33 base::SingleThreadTaskRunner* compositor_task_runner,
34 const base::WeakPtr<BlimpInputManager> input_manager_weak_ptr,
35 const base::WeakPtr<cc::InputHandler>& input_handler_weak_ptr)
36 : main_task_runner_(main_task_runner),
37 input_manager_weak_ptr_(input_manager_weak_ptr),
38 weak_factory_(this) {
39 DCHECK(main_task_runner->BelongsToCurrentThread());
40
41 // Since the object is created on the main thread, detach the thread checker
42 // so it can be bound to the compositor thread, in InitOnCompositorThread.
43 compositor_thread_checker_.DetachFromThread();
44
45 compositor_task_runner->PostTask(
46 FROM_HERE,
47 base::Bind(&CreateProxyOnCompositorThread, this, input_handler_weak_ptr));
48 }
49
50 BlimpInputHandlerWrapper::~BlimpInputHandlerWrapper() = default;
51
52 void BlimpInputHandlerWrapper::HandleWebGestureEvent(
53 const blink::WebGestureEvent& gesture_event) {
54 DCHECK(compositor_thread_checker_.CalledOnValidThread());
55
56 // We might not have the input handler proxy anymore.
57 if (!input_handler_proxy_)
58 return;
59
60 ui::InputHandlerProxy::EventDisposition disposition =
61 input_handler_proxy_->HandleInputEvent(gesture_event);
62
63 bool consumed = false;
64
65 switch (disposition) {
66 case ui::InputHandlerProxy::EventDisposition::DID_HANDLE:
67 case ui::InputHandlerProxy::EventDisposition::DROP_EVENT:
68 consumed = true;
69 break;
70 case ui::InputHandlerProxy::EventDisposition::DID_HANDLE_NON_BLOCKING:
71 case ui::InputHandlerProxy::EventDisposition::DID_NOT_HANDLE:
72 consumed = false;
73 break;
74 case ui::InputHandlerProxy::EventDisposition::
75 DID_NOT_HANDLE_NON_BLOCKING_DUE_TO_FLING:
76 NOTREACHED();
77 break;
78 }
79
80 main_task_runner_->PostTask(
81 FROM_HERE, base::Bind(&BlimpInputManager::DidHandleWebGestureEvent,
82 input_manager_weak_ptr_, gesture_event, consumed));
83 }
84
85 void BlimpInputHandlerWrapper::WillShutdown() {
86 DCHECK(compositor_thread_checker_.CalledOnValidThread());
87
88 input_handler_proxy_.reset();
89 weak_factory_.InvalidateWeakPtrs();
90 }
91
92 void BlimpInputHandlerWrapper::TransferActiveWheelFlingAnimation(
93 const blink::WebActiveWheelFlingParameters& params) {
94 DCHECK(compositor_thread_checker_.CalledOnValidThread());
95
96 NOTIMPLEMENTED()
97 << "Transferring Fling Animations to the engine is not supported";
98 }
99
100 void BlimpInputHandlerWrapper::DispatchNonBlockingEventToMainThread(
101 blink::WebScopedInputEvent event,
102 const ui::LatencyInfo& latency_info) {
103 DCHECK(compositor_thread_checker_.CalledOnValidThread());
104 DCHECK_EQ(event->type, blink::WebInputEvent::MouseWheel);
105
106 NOTIMPLEMENTED()
107 << "Dispatching Non Blocking Events to the engine is not supported";
108 }
109
110 blink::WebGestureCurve* BlimpInputHandlerWrapper::CreateFlingAnimationCurve(
111 blink::WebGestureDevice device_source,
112 const blink::WebFloatPoint& velocity,
113 const blink::WebSize& cumulative_scroll) {
114 DCHECK(compositor_thread_checker_.CalledOnValidThread());
115
116 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve(
117 gfx::Vector2dF(velocity.x, velocity.y),
118 gfx::Vector2dF(cumulative_scroll.width, cumulative_scroll.height),
119 false /* on_main_thread */)
120 .release();
121 }
122
123 void BlimpInputHandlerWrapper::DidOverscroll(
124 const gfx::Vector2dF& accumulated_overscroll,
125 const gfx::Vector2dF& latest_overscroll_delta,
126 const gfx::Vector2dF& current_fling_velocity,
127 const gfx::PointF& causal_event_viewport_point) {
128 DCHECK(compositor_thread_checker_.CalledOnValidThread());
129 }
130
131 void BlimpInputHandlerWrapper::DidStopFlinging() {
132 DCHECK(compositor_thread_checker_.CalledOnValidThread());
133 }
134
135 void BlimpInputHandlerWrapper::DidAnimateForInput() {
136 DCHECK(compositor_thread_checker_.CalledOnValidThread());
137 }
138
139 void BlimpInputHandlerWrapper::InitOnCompositorThread(
140 cc::InputHandler* input_handler) {
141 DCHECK(compositor_thread_checker_.CalledOnValidThread());
142
143 input_handler_proxy_ =
144 base::MakeUnique<ui::InputHandlerProxy>(input_handler, this);
145 main_task_runner_->PostTask(
146 FROM_HERE,
147 base::Bind(&BlimpInputManager::OnInputHandlerWrapperInitialized,
148 input_manager_weak_ptr_, weak_factory_.GetWeakPtr()));
149 }
150
151 } // namespace client
152 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/input/blimp_input_handler_wrapper.h ('k') | blimp/client/core/input/blimp_input_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698