OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 DWORD required_size = 0; | 82 DWORD required_size = 0; |
83 | 83 |
84 // Determime the required size of detail struct. | 84 // Determime the required size of detail struct. |
85 SetupDiGetDeviceInterfaceDetailA(device_info_set, | 85 SetupDiGetDeviceInterfaceDetailA(device_info_set, |
86 &device_interface_data, | 86 &device_interface_data, |
87 NULL, | 87 NULL, |
88 0, | 88 0, |
89 &required_size, | 89 &required_size, |
90 NULL); | 90 NULL); |
91 | 91 |
92 scoped_ptr_malloc<SP_DEVICE_INTERFACE_DETAIL_DATA_A> | 92 scoped_ptr<SP_DEVICE_INTERFACE_DETAIL_DATA_A, base::FreeDeleter> |
93 device_interface_detail_data( | 93 device_interface_detail_data( |
94 reinterpret_cast<SP_DEVICE_INTERFACE_DETAIL_DATA_A*>( | 94 static_cast<SP_DEVICE_INTERFACE_DETAIL_DATA_A*>( |
95 malloc(required_size))); | 95 malloc(required_size))); |
96 device_interface_detail_data->cbSize = | 96 device_interface_detail_data->cbSize = |
97 sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); | 97 sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); |
98 | 98 |
99 // Get the detailed data for this device. | 99 // Get the detailed data for this device. |
100 res = SetupDiGetDeviceInterfaceDetailA(device_info_set, | 100 res = SetupDiGetDeviceInterfaceDetailA(device_info_set, |
101 &device_interface_data, | 101 &device_interface_data, |
102 device_interface_detail_data.get(), | 102 device_interface_detail_data.get(), |
103 required_size, | 103 required_size, |
104 NULL, | 104 NULL, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 scoped_refptr<HidConnectionWin> connection( | 231 scoped_refptr<HidConnectionWin> connection( |
232 new HidConnectionWin(devices_[device_id])); | 232 new HidConnectionWin(devices_[device_id])); |
233 if (!connection->available()) { | 233 if (!connection->available()) { |
234 LOG_GETLASTERROR(ERROR) << "Failed to open device."; | 234 LOG_GETLASTERROR(ERROR) << "Failed to open device."; |
235 return NULL; | 235 return NULL; |
236 } | 236 } |
237 return connection; | 237 return connection; |
238 } | 238 } |
239 | 239 |
240 } // namespace device | 240 } // namespace device |
OLD | NEW |