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

Side by Side Diff: remoting/client/jni/chromoting_jni_instance.cc

Issue 214173002: Send TextEvent message from Android client (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/client/jni/chromoting_jni_instance.h" 5 #include "remoting/client/jni/chromoting_jni_instance.h"
6 6
7 #include <android/log.h> 7 #include <android/log.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) { 121 if (!jni_runtime_->display_task_runner()->BelongsToCurrentThread()) {
122 jni_runtime_->display_task_runner()->PostTask( 122 jni_runtime_->display_task_runner()->PostTask(
123 FROM_HERE, 123 FROM_HERE,
124 base::Bind(&ChromotingJniInstance::RedrawDesktop, this)); 124 base::Bind(&ChromotingJniInstance::RedrawDesktop, this));
125 return; 125 return;
126 } 126 }
127 127
128 jni_runtime_->RedrawCanvas(); 128 jni_runtime_->RedrawCanvas();
129 } 129 }
130 130
131 void ChromotingJniInstance::PerformMouseAction( 131 void ChromotingJniInstance::SendMouseEvent(
132 int x, int y, 132 int x, int y,
133 protocol::MouseEvent_MouseButton button, 133 protocol::MouseEvent_MouseButton button,
134 bool button_down) { 134 bool button_down) {
135 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { 135 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
136 jni_runtime_->network_task_runner()->PostTask( 136 jni_runtime_->network_task_runner()->PostTask(
137 FROM_HERE, base::Bind(&ChromotingJniInstance::PerformMouseAction, 137 FROM_HERE, base::Bind(&ChromotingJniInstance::SendMouseEvent,
138 this, x, y, button, button_down)); 138 this, x, y, button, button_down));
139 return; 139 return;
140 } 140 }
141 141
142 protocol::MouseEvent action; 142 protocol::MouseEvent event;
143 action.set_x(x); 143 event.set_x(x);
144 action.set_y(y); 144 event.set_y(y);
145 action.set_button(button); 145 event.set_button(button);
146 if (button != protocol::MouseEvent::BUTTON_UNDEFINED) 146 if (button != protocol::MouseEvent::BUTTON_UNDEFINED)
147 action.set_button_down(button_down); 147 event.set_button_down(button_down);
148 148
149 connection_->input_stub()->InjectMouseEvent(action); 149 connection_->input_stub()->InjectMouseEvent(event);
150 } 150 }
151 151
152 void ChromotingJniInstance::PerformMouseWheelDeltaAction(int delta_x, 152 void ChromotingJniInstance::SendMouseWheelEvent(int delta_x, int delta_y) {
153 int delta_y) {
154 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { 153 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
155 jni_runtime_->network_task_runner()->PostTask( 154 jni_runtime_->network_task_runner()->PostTask(
156 FROM_HERE, 155 FROM_HERE,
157 base::Bind(&ChromotingJniInstance::PerformMouseWheelDeltaAction, this, 156 base::Bind(&ChromotingJniInstance::SendMouseWheelEvent, this,
158 delta_x, delta_y)); 157 delta_x, delta_y));
159 return; 158 return;
160 } 159 }
161 160
162 protocol::MouseEvent action; 161 protocol::MouseEvent event;
163 action.set_wheel_delta_x(delta_x); 162 event.set_wheel_delta_x(delta_x);
164 action.set_wheel_delta_y(delta_y); 163 event.set_wheel_delta_y(delta_y);
165 connection_->input_stub()->InjectMouseEvent(action); 164 connection_->input_stub()->InjectMouseEvent(event);
166 } 165 }
167 166
168 void ChromotingJniInstance::PerformKeyboardAction(int key_code, bool key_down) { 167 void ChromotingJniInstance::SendKeyEvent(int key_code, bool key_down) {
169 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { 168 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
170 jni_runtime_->network_task_runner()->PostTask( 169 jni_runtime_->network_task_runner()->PostTask(
171 FROM_HERE, base::Bind(&ChromotingJniInstance::PerformKeyboardAction, 170 FROM_HERE, base::Bind(&ChromotingJniInstance::SendKeyEvent,
172 this, key_code, key_down)); 171 this, key_code, key_down));
173 return; 172 return;
174 } 173 }
175 174
176 uint32 usb_code = AndroidKeycodeToUsbKeycode(key_code); 175 uint32 usb_code = AndroidKeycodeToUsbKeycode(key_code);
177 if (usb_code) { 176 if (usb_code) {
178 protocol::KeyEvent action; 177 protocol::KeyEvent event;
179 action.set_usb_keycode(usb_code); 178 event.set_usb_keycode(usb_code);
180 action.set_pressed(key_down); 179 event.set_pressed(key_down);
181 connection_->input_stub()->InjectKeyEvent(action); 180 connection_->input_stub()->InjectKeyEvent(event);
182 } else { 181 } else {
183 LOG(WARNING) << "Ignoring unknown keycode: " << key_code; 182 LOG(WARNING) << "Ignoring unknown keycode: " << key_code;
184 } 183 }
185 } 184 }
186 185
186 void ChromotingJniInstance::SendTextEvent(const std::string& text) {
187 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
188 jni_runtime_->network_task_runner()->PostTask(
189 FROM_HERE,
190 base::Bind(&ChromotingJniInstance::SendTextEvent, this, text));
191 return;
192 }
193
194 protocol::TextEvent event;
195 event.set_text(text);
196 connection_->input_stub()->InjectTextEvent(event);
197 }
198
187 void ChromotingJniInstance::RecordPaintTime(int64 paint_time_ms) { 199 void ChromotingJniInstance::RecordPaintTime(int64 paint_time_ms) {
188 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) { 200 if (!jni_runtime_->network_task_runner()->BelongsToCurrentThread()) {
189 jni_runtime_->network_task_runner()->PostTask( 201 jni_runtime_->network_task_runner()->PostTask(
190 FROM_HERE, base::Bind(&ChromotingJniInstance::RecordPaintTime, this, 202 FROM_HERE, base::Bind(&ChromotingJniInstance::RecordPaintTime, this,
191 paint_time_ms)); 203 paint_time_ms));
192 return; 204 return;
193 } 205 }
194 206
195 if (stats_logging_enabled_) 207 if (stats_logging_enabled_)
196 video_renderer_->GetStats()->video_paint_ms()->Record(paint_time_ms); 208 video_renderer_->GetStats()->video_paint_ms()->Record(paint_time_ms);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 stats->video_decode_ms()->Average(), 419 stats->video_decode_ms()->Average(),
408 stats->video_paint_ms()->Average(), 420 stats->video_paint_ms()->Average(),
409 stats->round_trip_ms()->Average()); 421 stats->round_trip_ms()->Average());
410 422
411 jni_runtime_->network_task_runner()->PostDelayedTask( 423 jni_runtime_->network_task_runner()->PostDelayedTask(
412 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), 424 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this),
413 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); 425 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs));
414 } 426 }
415 427
416 } // namespace remoting 428 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/jni/chromoting_jni_instance.h ('k') | remoting/client/jni/chromoting_jni_runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698