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 #ifndef DEVICE_CORE_DEVICE_INFO_QUERY_WIN_H_ | 5 #ifndef DEVICE_BASE_DEVICE_INFO_QUERY_WIN_H_ |
6 #define DEVICE_CORE_DEVICE_INFO_QUERY_WIN_H_ | 6 #define DEVICE_BASE_DEVICE_INFO_QUERY_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <setupapi.h> | 9 #include <setupapi.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "device/core/device_core_export.h" | 14 #include "device/base/device_base_export.h" |
15 | 15 |
16 namespace device { | 16 namespace device { |
17 | 17 |
18 // Wraps HDEVINFO and SP_DEVINFO_DATA into a class that can automatically | 18 // Wraps HDEVINFO and SP_DEVINFO_DATA into a class that can automatically |
19 // release them. Provides interfaces that can add a device using its | 19 // release them. Provides interfaces that can add a device using its |
20 // device path, get device info and get device string property. | 20 // device path, get device info and get device string property. |
21 class DEVICE_CORE_EXPORT DeviceInfoQueryWin { | 21 class DEVICE_BASE_EXPORT DeviceInfoQueryWin { |
22 public: | 22 public: |
23 DeviceInfoQueryWin(); | 23 DeviceInfoQueryWin(); |
24 ~DeviceInfoQueryWin(); | 24 ~DeviceInfoQueryWin(); |
25 | 25 |
26 // Add a device to |device_info_list_| using its |device_path| so that | 26 // Add a device to |device_info_list_| using its |device_path| so that |
27 // its device info can be retrieved. | 27 // its device info can be retrieved. |
28 bool AddDevice(const char* device_path); | 28 bool AddDevice(const char* device_path); |
29 // Get the device info and store it into |device_info_data_|, this function | 29 // Get the device info and store it into |device_info_data_|, this function |
30 // should be called at most once. | 30 // should be called at most once. |
31 bool GetDeviceInfo(); | 31 bool GetDeviceInfo(); |
32 // Get device string property and store it into |property_buffer|. | 32 // Get device string property and store it into |property_buffer|. |
33 bool GetDeviceStringProperty(DWORD property, std::string* property_buffer); | 33 bool GetDeviceStringProperty(DWORD property, std::string* property_buffer); |
34 | 34 |
35 bool device_info_list_valid() { | 35 bool device_info_list_valid() { |
36 return device_info_list_ != INVALID_HANDLE_VALUE; | 36 return device_info_list_ != INVALID_HANDLE_VALUE; |
37 } | 37 } |
38 | 38 |
39 private: | 39 private: |
40 HDEVINFO device_info_list_ = INVALID_HANDLE_VALUE; | 40 HDEVINFO device_info_list_ = INVALID_HANDLE_VALUE; |
41 // When device_info_data_.cbSize != 0, |device_info_data_| is valid. | 41 // When device_info_data_.cbSize != 0, |device_info_data_| is valid. |
42 SP_DEVINFO_DATA device_info_data_; | 42 SP_DEVINFO_DATA device_info_data_; |
43 | 43 |
44 DISALLOW_COPY_AND_ASSIGN(DeviceInfoQueryWin); | 44 DISALLOW_COPY_AND_ASSIGN(DeviceInfoQueryWin); |
45 }; | 45 }; |
46 | 46 |
47 } // namespace device | 47 } // namespace device |
48 | 48 |
49 #endif // DEVICE_CORE_DEVICE_INFO_QUERY_WIN_H_ | 49 #endif // DEVICE_BASE_DEVICE_INFO_QUERY_WIN_H_ |
OLD | NEW |