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_win.h" | 5 #include "device/hid/hid_service_win.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 141 } |
142 | 142 |
143 void HidServiceWin::PlatformAddDevice(const std::string& device_path) { | 143 void HidServiceWin::PlatformAddDevice(const std::string& device_path) { |
144 HidDeviceInfo device_info; | 144 HidDeviceInfo device_info; |
145 device_info.device_id = device_path; | 145 device_info.device_id = device_path; |
146 | 146 |
147 // Try to open the device. | 147 // Try to open the device. |
148 base::win::ScopedHandle device_handle( | 148 base::win::ScopedHandle device_handle( |
149 CreateFileA(device_path.c_str(), | 149 CreateFileA(device_path.c_str(), |
150 0, | 150 0, |
151 FILE_SHARE_READ | FILE_SHARE_WRITE, | 151 FILE_SHARE_READ, |
152 NULL, | 152 NULL, |
153 OPEN_EXISTING, | 153 OPEN_EXISTING, |
154 FILE_FLAG_OVERLAPPED, | 154 FILE_FLAG_OVERLAPPED, |
155 0)); | 155 0)); |
156 if (!device_handle.IsValid()) | 156 if (!device_handle.IsValid()) |
157 return; | 157 return; |
158 | 158 |
159 // Get VID/PID pair. | 159 // Get VID/PID pair. |
160 HIDD_ATTRIBUTES attrib = {0}; | 160 HIDD_ATTRIBUTES attrib = {0}; |
161 attrib.Size = sizeof(HIDD_ATTRIBUTES); | 161 attrib.Size = sizeof(HIDD_ATTRIBUTES); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return NULL; | 250 return NULL; |
251 scoped_refptr<HidConnectionWin> connection(new HidConnectionWin(device_info)); | 251 scoped_refptr<HidConnectionWin> connection(new HidConnectionWin(device_info)); |
252 if (!connection->available()) { | 252 if (!connection->available()) { |
253 LOG_GETLASTERROR(ERROR) << "Failed to open device."; | 253 LOG_GETLASTERROR(ERROR) << "Failed to open device."; |
254 return NULL; | 254 return NULL; |
255 } | 255 } |
256 return connection; | 256 return connection; |
257 } | 257 } |
258 | 258 |
259 } // namespace device | 259 } // namespace device |
OLD | NEW |