| 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 "components/metrics/machine_id_provider.h" | 5 #include "components/metrics/machine_id_provider.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <winioctl.h> | 8 #include <winioctl.h> |
| 9 | 9 |
| 10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 0, | 53 0, |
| 54 NULL)); | 54 NULL)); |
| 55 | 55 |
| 56 STORAGE_PROPERTY_QUERY query = {}; | 56 STORAGE_PROPERTY_QUERY query = {}; |
| 57 query.PropertyId = StorageDeviceProperty; | 57 query.PropertyId = StorageDeviceProperty; |
| 58 query.QueryType = PropertyStandardQuery; | 58 query.QueryType = PropertyStandardQuery; |
| 59 | 59 |
| 60 // Perform an initial query to get the number of bytes being returned. | 60 // Perform an initial query to get the number of bytes being returned. |
| 61 DWORD bytes_returned; | 61 DWORD bytes_returned; |
| 62 STORAGE_DESCRIPTOR_HEADER header = {}; | 62 STORAGE_DESCRIPTOR_HEADER header = {}; |
| 63 BOOL status = DeviceIoControl(drive_handle, | 63 BOOL status = DeviceIoControl(drive_handle.Get(), |
| 64 IOCTL_STORAGE_QUERY_PROPERTY, | 64 IOCTL_STORAGE_QUERY_PROPERTY, |
| 65 &query, | 65 &query, |
| 66 sizeof(STORAGE_PROPERTY_QUERY), | 66 sizeof(STORAGE_PROPERTY_QUERY), |
| 67 &header, | 67 &header, |
| 68 sizeof(STORAGE_DESCRIPTOR_HEADER), | 68 sizeof(STORAGE_DESCRIPTOR_HEADER), |
| 69 &bytes_returned, | 69 &bytes_returned, |
| 70 NULL); | 70 NULL); |
| 71 | 71 |
| 72 if (!status) | 72 if (!status) |
| 73 return std::string(); | 73 return std::string(); |
| 74 | 74 |
| 75 // Query for the actual serial number. | 75 // Query for the actual serial number. |
| 76 std::vector<int8> output_buf(header.Size); | 76 std::vector<int8> output_buf(header.Size); |
| 77 status = DeviceIoControl(drive_handle, | 77 status = DeviceIoControl(drive_handle.Get(), |
| 78 IOCTL_STORAGE_QUERY_PROPERTY, | 78 IOCTL_STORAGE_QUERY_PROPERTY, |
| 79 &query, | 79 &query, |
| 80 sizeof(STORAGE_PROPERTY_QUERY), | 80 sizeof(STORAGE_PROPERTY_QUERY), |
| 81 &output_buf[0], | 81 &output_buf[0], |
| 82 output_buf.size(), | 82 output_buf.size(), |
| 83 &bytes_returned, | 83 &bytes_returned, |
| 84 NULL); | 84 NULL); |
| 85 | 85 |
| 86 if (!status) | 86 if (!status) |
| 87 return std::string(); | 87 return std::string(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 108 | 108 |
| 109 return std::string(serial_number); | 109 return std::string(serial_number); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // static | 112 // static |
| 113 MachineIdProvider* MachineIdProvider::CreateInstance() { | 113 MachineIdProvider* MachineIdProvider::CreateInstance() { |
| 114 return new MachineIdProvider(); | 114 return new MachineIdProvider(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace metrics | 117 } // namespace metrics |
| OLD | NEW |