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 "ui/events/ozone/evdev/event_thread_evdev.h" | 5 #include "ui/events/ozone/evdev/event_thread_evdev.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
10 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
11 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
12 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
13 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" | 15 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
14 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" | 16 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" |
15 #include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h" | 17 #include "ui/events/ozone/evdev/input_device_factory_evdev_proxy.h" |
16 | 18 |
17 namespace ui { | 19 namespace ui { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 // Internal base::Thread subclass for events thread. | 23 // Internal base::Thread subclass for events thread. |
22 class EvdevThread : public base::Thread { | 24 class EvdevThread : public base::Thread { |
23 public: | 25 public: |
24 EvdevThread(scoped_ptr<DeviceEventDispatcherEvdev> dispatcher, | 26 EvdevThread(scoped_ptr<DeviceEventDispatcherEvdev> dispatcher, |
25 CursorDelegateEvdev* cursor, | 27 CursorDelegateEvdev* cursor, |
26 const EventThreadStartCallback& callback) | 28 const EventThreadStartCallback& callback) |
27 : base::Thread("evdev"), | 29 : base::Thread("evdev"), |
28 dispatcher_(dispatcher.Pass()), | 30 dispatcher_(std::move(dispatcher)), |
29 cursor_(cursor), | 31 cursor_(cursor), |
30 init_callback_(callback), | 32 init_callback_(callback), |
31 init_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 33 init_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
32 ~EvdevThread() override { Stop(); } | 34 ~EvdevThread() override { Stop(); } |
33 | 35 |
34 void Init() override { | 36 void Init() override { |
35 TRACE_EVENT0("evdev", "EvdevThread::Init"); | 37 TRACE_EVENT0("evdev", "EvdevThread::Init"); |
36 input_device_factory_ = | 38 input_device_factory_ = |
37 new InputDeviceFactoryEvdev(dispatcher_.Pass(), cursor_); | 39 new InputDeviceFactoryEvdev(std::move(dispatcher_), cursor_); |
38 | 40 |
39 scoped_ptr<InputDeviceFactoryEvdevProxy> proxy( | 41 scoped_ptr<InputDeviceFactoryEvdevProxy> proxy( |
40 new InputDeviceFactoryEvdevProxy(base::ThreadTaskRunnerHandle::Get(), | 42 new InputDeviceFactoryEvdevProxy(base::ThreadTaskRunnerHandle::Get(), |
41 input_device_factory_->GetWeakPtr())); | 43 input_device_factory_->GetWeakPtr())); |
42 | 44 |
43 init_runner_->PostTask(FROM_HERE, | 45 init_runner_->PostTask(FROM_HERE, |
44 base::Bind(init_callback_, base::Passed(&proxy))); | 46 base::Bind(init_callback_, base::Passed(&proxy))); |
45 } | 47 } |
46 | 48 |
47 void CleanUp() override { | 49 void CleanUp() override { |
(...skipping 17 matching lines...) Expand all Loading... |
65 EventThreadEvdev::EventThreadEvdev() { | 67 EventThreadEvdev::EventThreadEvdev() { |
66 } | 68 } |
67 | 69 |
68 EventThreadEvdev::~EventThreadEvdev() { | 70 EventThreadEvdev::~EventThreadEvdev() { |
69 } | 71 } |
70 | 72 |
71 void EventThreadEvdev::Start(scoped_ptr<DeviceEventDispatcherEvdev> dispatcher, | 73 void EventThreadEvdev::Start(scoped_ptr<DeviceEventDispatcherEvdev> dispatcher, |
72 CursorDelegateEvdev* cursor, | 74 CursorDelegateEvdev* cursor, |
73 const EventThreadStartCallback& callback) { | 75 const EventThreadStartCallback& callback) { |
74 TRACE_EVENT0("evdev", "EventThreadEvdev::Start"); | 76 TRACE_EVENT0("evdev", "EventThreadEvdev::Start"); |
75 thread_.reset(new EvdevThread(dispatcher.Pass(), cursor, callback)); | 77 thread_.reset(new EvdevThread(std::move(dispatcher), cursor, callback)); |
76 if (!thread_->StartWithOptions( | 78 if (!thread_->StartWithOptions( |
77 base::Thread::Options(base::MessageLoop::TYPE_UI, 0))) | 79 base::Thread::Options(base::MessageLoop::TYPE_UI, 0))) |
78 LOG(FATAL) << "Failed to create input thread"; | 80 LOG(FATAL) << "Failed to create input thread"; |
79 } | 81 } |
80 | 82 |
81 } // namespace ui | 83 } // namespace ui |
OLD | NEW |