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 <linux/hidraw.h> | 7 #include <linux/hidraw.h> |
8 #include <sys/ioctl.h> | 8 #include <sys/ioctl.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 namespace { | 34 namespace { |
35 | 35 |
36 const char kHidrawSubsystem[] = "hidraw"; | 36 const char kHidrawSubsystem[] = "hidraw"; |
37 const char kHIDID[] = "HID_ID"; | 37 const char kHIDID[] = "HID_ID"; |
38 const char kHIDName[] = "HID_NAME"; | 38 const char kHIDName[] = "HID_NAME"; |
39 const char kHIDUnique[] = "HID_UNIQ"; | 39 const char kHIDUnique[] = "HID_UNIQ"; |
40 | 40 |
41 } // namespace | 41 } // namespace |
42 | 42 |
43 HidServiceLinux::HidServiceLinux( | 43 HidServiceLinux::HidServiceLinux( |
44 scoped_refptr<base::MessageLoopProxy> ui_message_loop) | 44 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) |
45 : ui_message_loop_(ui_message_loop), | 45 : ui_task_runner_(ui_task_runner), |
46 weak_factory_(this) { | 46 weak_factory_(this) { |
47 DeviceMonitorLinux* monitor = DeviceMonitorLinux::GetInstance(); | 47 DeviceMonitorLinux* monitor = DeviceMonitorLinux::GetInstance(); |
48 monitor->AddObserver(this); | 48 monitor->AddObserver(this); |
49 monitor->Enumerate( | 49 monitor->Enumerate( |
50 base::Bind(&HidServiceLinux::OnDeviceAdded, weak_factory_.GetWeakPtr())); | 50 base::Bind(&HidServiceLinux::OnDeviceAdded, weak_factory_.GetWeakPtr())); |
51 } | 51 } |
52 | 52 |
53 scoped_refptr<HidConnection> HidServiceLinux::Connect( | 53 scoped_refptr<HidConnection> HidServiceLinux::Connect( |
54 const HidDeviceId& device_id) { | 54 const HidDeviceId& device_id) { |
55 HidDeviceInfo device_info; | 55 HidDeviceInfo device_info; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 #if defined(OS_CHROMEOS) | 125 #if defined(OS_CHROMEOS) |
126 // ChromeOS builds on non-ChromeOS machines (dev) should not attempt to | 126 // ChromeOS builds on non-ChromeOS machines (dev) should not attempt to |
127 // use permission broker. | 127 // use permission broker. |
128 if (base::SysInfo::IsRunningOnChromeOS()) { | 128 if (base::SysInfo::IsRunningOnChromeOS()) { |
129 chromeos::PermissionBrokerClient* client = | 129 chromeos::PermissionBrokerClient* client = |
130 chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient(); | 130 chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient(); |
131 DCHECK(client) << "Could not get permission broker client."; | 131 DCHECK(client) << "Could not get permission broker client."; |
132 if (!client) { | 132 if (!client) { |
133 return; | 133 return; |
134 } | 134 } |
135 ui_message_loop_->PostTask( | 135 ui_task_runner_->PostTask( |
136 FROM_HERE, | 136 FROM_HERE, |
137 base::Bind(&chromeos::PermissionBrokerClient::RequestPathAccess, | 137 base::Bind(&chromeos::PermissionBrokerClient::RequestPathAccess, |
138 base::Unretained(client), | 138 base::Unretained(client), |
139 dev_node, | 139 dev_node, |
140 -1, | 140 -1, |
141 base::Bind(&HidServiceLinux::OnRequestAccessComplete, | 141 base::Bind(&HidServiceLinux::OnRequestAccessComplete, |
142 weak_factory_.GetWeakPtr(), | 142 weak_factory_.GetWeakPtr(), |
143 dev_node, | 143 dev_node, |
144 base::Passed(&device_info)))); | 144 base::Passed(&device_info)))); |
145 } else { | 145 } else { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 report_descriptor.GetDetails(&device_info->collections, | 192 report_descriptor.GetDetails(&device_info->collections, |
193 &device_info->has_report_id, | 193 &device_info->has_report_id, |
194 &device_info->max_input_report_size, | 194 &device_info->max_input_report_size, |
195 &device_info->max_output_report_size, | 195 &device_info->max_output_report_size, |
196 &device_info->max_feature_report_size); | 196 &device_info->max_feature_report_size); |
197 | 197 |
198 AddDevice(*device_info); | 198 AddDevice(*device_info); |
199 } | 199 } |
200 | 200 |
201 } // namespace device | 201 } // namespace device |
OLD | NEW |