OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "device/hid/hid_service_linux.h" | 5 #include "device/hid/hid_service_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 : observer_(this), service_(service), task_runner_(task_runner) { | 68 : observer_(this), service_(service), task_runner_(task_runner) { |
69 DeviceMonitorLinux* monitor = DeviceMonitorLinux::GetInstance(); | 69 DeviceMonitorLinux* monitor = DeviceMonitorLinux::GetInstance(); |
70 observer_.Add(monitor); | 70 observer_.Add(monitor); |
71 monitor->Enumerate( | 71 monitor->Enumerate( |
72 base::Bind(&Helper::OnDeviceAdded, base::Unretained(this))); | 72 base::Bind(&Helper::OnDeviceAdded, base::Unretained(this))); |
73 task_runner->PostTask( | 73 task_runner->PostTask( |
74 FROM_HERE, | 74 FROM_HERE, |
75 base::Bind(&HidServiceLinux::FirstEnumerationComplete, service_)); | 75 base::Bind(&HidServiceLinux::FirstEnumerationComplete, service_)); |
76 } | 76 } |
77 | 77 |
78 virtual ~Helper() { | 78 ~Helper() override { DCHECK(thread_checker_.CalledOnValidThread()); } |
79 DCHECK(thread_checker_.CalledOnValidThread()); | |
80 } | |
81 | 79 |
82 private: | 80 private: |
83 // DeviceMonitorLinux::Observer: | 81 // DeviceMonitorLinux::Observer: |
84 void OnDeviceAdded(udev_device* device) override { | 82 void OnDeviceAdded(udev_device* device) override { |
85 DCHECK(thread_checker_.CalledOnValidThread()); | 83 DCHECK(thread_checker_.CalledOnValidThread()); |
86 const char* device_path = udev_device_get_syspath(device); | 84 const char* device_path = udev_device_get_syspath(device); |
87 if (!device_path) { | 85 if (!device_path) { |
88 return; | 86 return; |
89 } | 87 } |
90 const char* subsystem = udev_device_get_subsystem(device); | 88 const char* subsystem = udev_device_get_subsystem(device); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 306 |
309 // static | 307 // static |
310 void HidServiceLinux::ConnectImpl(scoped_ptr<ConnectParams> params) { | 308 void HidServiceLinux::ConnectImpl(scoped_ptr<ConnectParams> params) { |
311 DCHECK(params->device_file.IsValid()); | 309 DCHECK(params->device_file.IsValid()); |
312 params->callback.Run(make_scoped_refptr( | 310 params->callback.Run(make_scoped_refptr( |
313 new HidConnectionLinux(params->device_info, params->device_file.Pass(), | 311 new HidConnectionLinux(params->device_info, params->device_file.Pass(), |
314 params->file_task_runner))); | 312 params->file_task_runner))); |
315 } | 313 } |
316 | 314 |
317 } // namespace device | 315 } // namespace device |
OLD | NEW |