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 "chrome/browser/metrics/machine_id_provider.h" | 5 #include "chrome/browser/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" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/win/scoped_handle.h" | 13 #include "base/win/scoped_handle.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 | 15 |
16 namespace metrics { | 16 namespace metrics { |
17 | 17 |
18 MachineIdProvider::MachineIdProvider() {} | 18 MachineIdProvider::MachineIdProvider() {} |
19 MachineIdProvider::~MachineIdProvider() {} | 19 MachineIdProvider::~MachineIdProvider() {} |
20 | 20 |
21 // On windows, the machine id is based on the serial number of the drive Chrome | 21 // On windows, the machine id is based on the serial number of the drive Chrome |
22 // is running from. | 22 // is running from. |
23 std::string MachineIdProvider::GetMachineId() { | 23 std::string MachineIdProvider::GetMachineId() { |
| 24 DVLOG(2) << "\n\nGetting machine id\n\n"; |
24 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 25 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
25 | 26 |
26 // Use the program's path to get the drive used for the machine id. This means | 27 // Use the program's path to get the drive used for the machine id. This means |
27 // that whenever the underlying drive changes, it's considered a new machine. | 28 // that whenever the underlying drive changes, it's considered a new machine. |
28 // This is fine as we do not support migrating Chrome installs to new drives. | 29 // This is fine as we do not support migrating Chrome installs to new drives. |
29 base::FilePath executable_path; | 30 base::FilePath executable_path; |
30 | 31 |
31 if (!PathService::Get(base::FILE_EXE, &executable_path)) { | 32 if (!PathService::Get(base::FILE_EXE, &executable_path)) { |
32 NOTREACHED(); | 33 NOTREACHED(); |
33 return std::string(); | 34 return std::string(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 98 |
98 return std::string(serial_number); | 99 return std::string(serial_number); |
99 } | 100 } |
100 | 101 |
101 // static | 102 // static |
102 MachineIdProvider* MachineIdProvider::CreateInstance() { | 103 MachineIdProvider* MachineIdProvider::CreateInstance() { |
103 return new MachineIdProvider(); | 104 return new MachineIdProvider(); |
104 } | 105 } |
105 | 106 |
106 } // namespace metrics | 107 } // namespace metrics |
OLD | NEW |