OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" |
| 10 |
| 11 namespace ui { |
| 12 |
| 13 namespace { |
| 14 |
| 15 void ForwardGetTouchDeviceStatusReply( |
| 16 scoped_refptr<base::SingleThreadTaskRunner> reply_runner, |
| 17 const GetTouchDeviceStatusReply& reply, |
| 18 scoped_ptr<std::string> status) { |
| 19 // Thread hop back to UI for reply. |
| 20 reply_runner->PostTask(FROM_HERE, base::Bind(reply, base::Passed(&status))); |
| 21 } |
| 22 |
| 23 void ForwardGetTouchEventLogReply( |
| 24 scoped_refptr<base::SingleThreadTaskRunner> reply_runner, |
| 25 const GetTouchEventLogReply& reply, |
| 26 scoped_ptr<std::vector<base::FilePath>> log_paths) { |
| 27 // Thread hop back to UI for reply. |
| 28 reply_runner->PostTask(FROM_HERE, |
| 29 base::Bind(reply, base::Passed(&log_paths))); |
| 30 } |
| 31 |
| 32 } // namespace |
| 33 |
| 34 InputDeviceFactoryEvdevProxy::InputDeviceFactoryEvdevProxy( |
| 35 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 36 base::WeakPtr<InputDeviceFactoryEvdev> input_device_factory) |
| 37 : task_runner_(task_runner), input_device_factory_(input_device_factory) { |
| 38 } |
| 39 |
| 40 InputDeviceFactoryEvdevProxy::~InputDeviceFactoryEvdevProxy() { |
| 41 } |
| 42 |
| 43 void InputDeviceFactoryEvdevProxy::AddInputDevice(int id, |
| 44 const base::FilePath& path) { |
| 45 task_runner_->PostTask(FROM_HERE, |
| 46 base::Bind(&InputDeviceFactoryEvdev::AddInputDevice, |
| 47 input_device_factory_, id, path)); |
| 48 } |
| 49 |
| 50 void InputDeviceFactoryEvdevProxy::RemoveInputDevice( |
| 51 const base::FilePath& path) { |
| 52 task_runner_->PostTask(FROM_HERE, |
| 53 base::Bind(&InputDeviceFactoryEvdev::RemoveInputDevice, |
| 54 input_device_factory_, path)); |
| 55 } |
| 56 |
| 57 void InputDeviceFactoryEvdevProxy::OnStartupScanComplete() { |
| 58 task_runner_->PostTask( |
| 59 FROM_HERE, base::Bind(&InputDeviceFactoryEvdev::OnStartupScanComplete, |
| 60 input_device_factory_)); |
| 61 } |
| 62 |
| 63 void InputDeviceFactoryEvdevProxy::SetCapsLockLed(bool enabled) { |
| 64 task_runner_->PostTask(FROM_HERE, |
| 65 base::Bind(&InputDeviceFactoryEvdev::SetCapsLockLed, |
| 66 input_device_factory_, enabled)); |
| 67 } |
| 68 |
| 69 void InputDeviceFactoryEvdevProxy::UpdateInputDeviceSettings( |
| 70 const InputDeviceSettingsEvdev& settings) { |
| 71 task_runner_->PostTask( |
| 72 FROM_HERE, base::Bind(&InputDeviceFactoryEvdev::UpdateInputDeviceSettings, |
| 73 input_device_factory_, settings)); |
| 74 } |
| 75 |
| 76 void InputDeviceFactoryEvdevProxy::GetTouchDeviceStatus( |
| 77 const GetTouchDeviceStatusReply& reply) { |
| 78 task_runner_->PostTask( |
| 79 FROM_HERE, |
| 80 base::Bind(&InputDeviceFactoryEvdev::GetTouchDeviceStatus, |
| 81 input_device_factory_, |
| 82 base::Bind(&ForwardGetTouchDeviceStatusReply, |
| 83 base::ThreadTaskRunnerHandle::Get(), reply))); |
| 84 } |
| 85 |
| 86 void InputDeviceFactoryEvdevProxy::GetTouchEventLog( |
| 87 const base::FilePath& out_dir, |
| 88 const GetTouchEventLogReply& reply) { |
| 89 task_runner_->PostTask( |
| 90 FROM_HERE, |
| 91 base::Bind(&InputDeviceFactoryEvdev::GetTouchEventLog, |
| 92 input_device_factory_, out_dir, |
| 93 base::Bind(&ForwardGetTouchEventLogReply, |
| 94 base::ThreadTaskRunnerHandle::Get(), reply))); |
| 95 } |
| 96 |
| 97 } // namespace ui |
OLD | NEW |