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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: remoting/client/render_stub_proxy.cc
diff --git a/remoting/client/render_stub_proxy.cc b/remoting/client/render_stub_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8642aa9152ea3d7a0790e7a38b3eb0fa46aa0756
--- /dev/null
+++ b/remoting/client/render_stub_proxy.cc
@@ -0,0 +1,58 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#include "remoting/client/render_stub_proxy.h"
+
+#include "base/bind.h"
+#include "remoting/client/queued_task_poster.h"
+#include "remoting/client/view_matrix.h"
+
+namespace remoting {
+
+RenderStubProxy::RenderStubProxy(
+ base::WeakPtr<RenderStub> stub,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner)
+ : stub_(stub),
+ task_runner_(task_runner),
+ ui_task_poster_(new remoting::QueuedTaskPoster(task_runner_)) {}
+
+RenderStubProxy::~RenderStubProxy() {}
+
+void RenderStubProxy::SetTransformation(const ViewMatrix& transformation) {
+ // Viewport and cursor movements need to be synchronized into the same frame.
+ RunTaskOnProperThread(
+ base::Bind(&RenderStub::SetTransformation, stub_, transformation), true);
+}
+
+void RenderStubProxy::SetCursorPosition(float x, float y) {
+ RunTaskOnProperThread(base::Bind(&RenderStub::SetCursorPosition, stub_, x, y),
+ true);
+}
+
+void RenderStubProxy::SetCursorVisibility(bool visible) {
+ RunTaskOnProperThread(
+ base::Bind(&RenderStub::SetCursorVisibility, stub_, visible), false);
+}
+
+void RenderStubProxy::StartInputFeedback(float x, float y, float diameter) {
+ RunTaskOnProperThread(
+ base::Bind(&RenderStub::StartInputFeedback, stub_, x, y, diameter),
+ false);
+}
+
+void RenderStubProxy::RunTaskOnProperThread(const base::Closure& task,
+ bool needs_synchronization) {
+ if (task_runner_->BelongsToCurrentThread()) {
+ task.Run();
+ return;
+ }
+
+ if (needs_synchronization) {
+ ui_task_poster_->AddTask(task);
+ return;
+ }
+
+ task_runner_->PostTask(FROM_HERE, task);
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698