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

Side by Side Diff: remoting/host/input_injector_win.cc

Issue 1949113005: Fixing an It2Me host crash on debug builds on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/host/input_injector.h" 5 #include "remoting/host/input_injector.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 virtual ~Core(); 194 virtual ~Core();
195 195
196 void HandleKey(const KeyEvent& event); 196 void HandleKey(const KeyEvent& event);
197 void HandleText(const TextEvent& event); 197 void HandleText(const TextEvent& event);
198 void HandleMouse(const MouseEvent& event); 198 void HandleMouse(const MouseEvent& event);
199 void HandleTouch(const TouchEvent& event); 199 void HandleTouch(const TouchEvent& event);
200 200
201 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 201 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
202 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 202 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
203 std::unique_ptr<Clipboard> clipboard_; 203 std::unique_ptr<Clipboard> clipboard_;
204 TouchInjectorWin touch_injector_; 204 std::unique_ptr<TouchInjectorWin> touch_injector_;
205 205
206 DISALLOW_COPY_AND_ASSIGN(Core); 206 DISALLOW_COPY_AND_ASSIGN(Core);
207 }; 207 };
208 208
209 scoped_refptr<Core> core_; 209 scoped_refptr<Core> core_;
210 210
211 DISALLOW_COPY_AND_ASSIGN(InputInjectorWin); 211 DISALLOW_COPY_AND_ASSIGN(InputInjectorWin);
212 }; 212 };
213 213
214 InputInjectorWin::InputInjectorWin( 214 InputInjectorWin::InputInjectorWin(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 void InputInjectorWin::Core::Start( 308 void InputInjectorWin::Core::Start(
309 std::unique_ptr<protocol::ClipboardStub> client_clipboard) { 309 std::unique_ptr<protocol::ClipboardStub> client_clipboard) {
310 if (!ui_task_runner_->BelongsToCurrentThread()) { 310 if (!ui_task_runner_->BelongsToCurrentThread()) {
311 ui_task_runner_->PostTask( 311 ui_task_runner_->PostTask(
312 FROM_HERE, 312 FROM_HERE,
313 base::Bind(&Core::Start, this, base::Passed(&client_clipboard))); 313 base::Bind(&Core::Start, this, base::Passed(&client_clipboard)));
314 return; 314 return;
315 } 315 }
316 316
317 clipboard_->Start(std::move(client_clipboard)); 317 clipboard_->Start(std::move(client_clipboard));
318 touch_injector_.Init(); 318 touch_injector_.reset(new TouchInjectorWin());
319 touch_injector_->Init();
319 } 320 }
320 321
321 void InputInjectorWin::Core::Stop() { 322 void InputInjectorWin::Core::Stop() {
322 if (!ui_task_runner_->BelongsToCurrentThread()) { 323 if (!ui_task_runner_->BelongsToCurrentThread()) {
323 ui_task_runner_->PostTask(FROM_HERE, base::Bind(&Core::Stop, this)); 324 ui_task_runner_->PostTask(FROM_HERE, base::Bind(&Core::Stop, this));
324 return; 325 return;
325 } 326 }
326 327
327 clipboard_.reset(); 328 clipboard_.reset();
328 touch_injector_.Deinitialize(); 329 touch_injector_->Deinitialize();
329 } 330 }
330 331
331 InputInjectorWin::Core::~Core() {} 332 InputInjectorWin::Core::~Core() {}
332 333
333 void InputInjectorWin::Core::HandleKey(const KeyEvent& event) { 334 void InputInjectorWin::Core::HandleKey(const KeyEvent& event) {
334 // HostEventDispatcher should filter events missing the pressed field. 335 // HostEventDispatcher should filter events missing the pressed field.
335 DCHECK(event.has_pressed() && event.has_usb_keycode()); 336 DCHECK(event.has_pressed() && event.has_usb_keycode());
336 337
337 // Reset the system idle suspend timeout. 338 // Reset the system idle suspend timeout.
338 SetThreadExecutionState(ES_SYSTEM_REQUIRED); 339 SetThreadExecutionState(ES_SYSTEM_REQUIRED);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 ParseMouseClickEvent(event, &inputs); 372 ParseMouseClickEvent(event, &inputs);
372 ParseMouseWheelEvent(event, &inputs); 373 ParseMouseWheelEvent(event, &inputs);
373 374
374 if (!inputs.empty()) { 375 if (!inputs.empty()) {
375 if (SendInput(inputs.size(), inputs.data(), sizeof(INPUT)) != inputs.size()) 376 if (SendInput(inputs.size(), inputs.data(), sizeof(INPUT)) != inputs.size())
376 PLOG(ERROR) << "Failed to inject a mouse event"; 377 PLOG(ERROR) << "Failed to inject a mouse event";
377 } 378 }
378 } 379 }
379 380
380 void InputInjectorWin::Core::HandleTouch(const TouchEvent& event) { 381 void InputInjectorWin::Core::HandleTouch(const TouchEvent& event) {
381 touch_injector_.InjectTouchEvent(event); 382 DCHECK(touch_injector_);
383 touch_injector_->InjectTouchEvent(event);
382 } 384 }
383 385
384 } // namespace 386 } // namespace
385 387
386 // static 388 // static
387 std::unique_ptr<InputInjector> InputInjector::Create( 389 std::unique_ptr<InputInjector> InputInjector::Create(
388 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 390 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
389 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 391 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
390 return base::WrapUnique( 392 return base::WrapUnique(
391 new InputInjectorWin(main_task_runner, ui_task_runner)); 393 new InputInjectorWin(main_task_runner, ui_task_runner));
392 } 394 }
393 395
394 // static 396 // static
395 bool InputInjector::SupportsTouchEvents() { 397 bool InputInjector::SupportsTouchEvents() {
396 return TouchInjectorWinDelegate::Create() != nullptr; 398 return TouchInjectorWinDelegate::Create() != nullptr;
397 } 399 }
398 400
399 } // namespace remoting 401 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698