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

Side by Side Diff: remoting/client/render_stub_proxy.cc

Issue 2879743002: [CRD iOS] Hook the touch input feedback (Closed)
Patch Set: Use the ui task poster Created 3 years, 7 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 2017 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 #include "remoting/client/render_stub_proxy.h"
5
6 #include "base/bind.h"
7 #include "remoting/client/queued_task_poster.h"
8 #include "remoting/client/view_matrix.h"
9
10 namespace remoting {
11
12 RenderStubProxy::RenderStubProxy(
13 base::WeakPtr<RenderStub> stub,
14 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
15 : stub_(stub),
16 task_runner_(task_runner),
17 ui_task_poster_(new remoting::QueuedTaskPoster(task_runner_)) {}
18
19 RenderStubProxy::~RenderStubProxy() {}
20
21 void RenderStubProxy::SetTransformation(const ViewMatrix& transformation) {
22 // Viewport and cursor movements need to be synchronized into the same frame.
23 RunTaskOnProperThread(
24 base::Bind(&RenderStub::SetTransformation, stub_, transformation), true);
25 }
26
27 void RenderStubProxy::SetCursorPosition(float x, float y) {
28 RunTaskOnProperThread(base::Bind(&RenderStub::SetCursorPosition, stub_, x, y),
29 true);
30 }
31
32 void RenderStubProxy::SetCursorVisibility(bool visible) {
33 RunTaskOnProperThread(
34 base::Bind(&RenderStub::SetCursorVisibility, stub_, visible), false);
35 }
36
37 void RenderStubProxy::StartInputFeedback(float x, float y, float diameter) {
38 RunTaskOnProperThread(
39 base::Bind(&RenderStub::StartInputFeedback, stub_, x, y, diameter),
40 false);
41 }
42
43 void RenderStubProxy::RunTaskOnProperThread(const base::Closure& task,
44 bool needs_synchronization) {
45 if (task_runner_->BelongsToCurrentThread()) {
46 task.Run();
47 return;
48 }
49
50 if (needs_synchronization) {
51 ui_task_poster_->AddTask(task);
52 return;
53 }
54
55 task_runner_->PostTask(FROM_HERE, task);
56 }
57
58 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698