OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "components/arc/input/arc_input_bridge.h" | 5 #include "components/arc/input/arc_input_bridge.h" |
6 | 6 |
7 #include <linux/input.h> | 7 #include <linux/input.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/posix/eintr_wrapper.h" | 14 #include "base/posix/eintr_wrapper.h" |
15 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "components/arc/arc_bridge_service.h" | 17 #include "components/arc/arc_bridge_service.h" |
18 #include "third_party/mojo/src/mojo/edk/embedder/embedder.h" | 18 #include "mojo/edk/embedder/embedder.h" |
19 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
20 #include "ui/aura/env_observer.h" | 20 #include "ui/aura/env_observer.h" |
21 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
22 #include "ui/aura/window_observer.h" | 22 #include "ui/aura/window_observer.h" |
23 #include "ui/events/event.h" | 23 #include "ui/events/event.h" |
24 #include "ui/events/event_handler.h" | 24 #include "ui/events/event_handler.h" |
25 #include "ui/events/event_utils.h" | 25 #include "ui/events/event_utils.h" |
26 #include "ui/events/keycodes/dom/keycode_converter.h" | 26 #include "ui/events/keycodes/dom/keycode_converter.h" |
27 | 27 |
28 namespace { | 28 namespace { |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 base::ScopedFD read_fd(fd[0]); | 339 base::ScopedFD read_fd(fd[0]); |
340 base::ScopedFD write_fd(fd[1]); | 340 base::ScopedFD write_fd(fd[1]); |
341 | 341 |
342 // The read end is sent to the instance, ownership of fd transfers. | 342 // The read end is sent to the instance, ownership of fd transfers. |
343 InputInstance* input_instance = arc_bridge_service()->input_instance(); | 343 InputInstance* input_instance = arc_bridge_service()->input_instance(); |
344 if (!input_instance) { | 344 if (!input_instance) { |
345 VLOG(1) << "ArcBridgeService InputInstance disappeared."; | 345 VLOG(1) << "ArcBridgeService InputInstance disappeared."; |
346 return base::ScopedFD(); | 346 return base::ScopedFD(); |
347 } | 347 } |
348 MojoHandle wrapped_handle; | 348 MojoHandle wrapped_handle; |
349 MojoResult wrap_result = mojo::embedder::CreatePlatformHandleWrapper( | 349 MojoResult wrap_result = mojo::edk::CreatePlatformHandleWrapper( |
350 mojo::embedder::ScopedPlatformHandle( | 350 mojo::edk::ScopedPlatformHandle( |
351 mojo::embedder::PlatformHandle(read_fd.release())), | 351 mojo::edk::PlatformHandle(read_fd.release())), |
352 &wrapped_handle); | 352 &wrapped_handle); |
353 if (wrap_result != MOJO_RESULT_OK) { | 353 if (wrap_result != MOJO_RESULT_OK) { |
354 LOG(WARNING) << "Pipe failed to wrap handles. Closing: " << wrap_result; | 354 LOG(WARNING) << "Pipe failed to wrap handles. Closing: " << wrap_result; |
355 return base::ScopedFD(); | 355 return base::ScopedFD(); |
356 } | 356 } |
357 input_instance->RegisterInputDevice( | 357 input_instance->RegisterInputDevice( |
358 name, device_type, mojo::ScopedHandle(mojo::Handle(wrapped_handle))); | 358 name, device_type, mojo::ScopedHandle(mojo::Handle(wrapped_handle))); |
359 | 359 |
360 // setup write end as non blocking | 360 // setup write end as non blocking |
361 int flags = HANDLE_EINTR(fcntl(write_fd.get(), F_GETFL, 0)); | 361 int flags = HANDLE_EINTR(fcntl(write_fd.get(), F_GETFL, 0)); |
362 if (res < 0) { | 362 if (res < 0) { |
363 VPLOG(1) << "Cannot get file descriptor flags"; | 363 VPLOG(1) << "Cannot get file descriptor flags"; |
364 return base::ScopedFD(); | 364 return base::ScopedFD(); |
365 } | 365 } |
366 | 366 |
367 res = HANDLE_EINTR(fcntl(write_fd.get(), F_SETFL, flags | O_NONBLOCK)); | 367 res = HANDLE_EINTR(fcntl(write_fd.get(), F_SETFL, flags | O_NONBLOCK)); |
368 if (res < 0) { | 368 if (res < 0) { |
369 VPLOG(1) << "Cannot set file descriptor flags"; | 369 VPLOG(1) << "Cannot set file descriptor flags"; |
370 return base::ScopedFD(); | 370 return base::ScopedFD(); |
371 } | 371 } |
372 return write_fd; | 372 return write_fd; |
373 } | 373 } |
374 | 374 |
375 } // namespace arc | 375 } // namespace arc |
OLD | NEW |