1 // Copyright 2014 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_METRICS_MACHINE_ID_PROVIDER_H_ 6 #define COMPONENTS_METRICS_MACHINE_ID_PROVIDER_H_ 7 8 #include <string> 9 10 namespace metrics { 11 12 // Provides machine characteristics used as a machine id. The implementation is 13 // platform specific. GetMachineId() must be called on a thread which allows 14 // I/O. GetMachineId() must not be called if HasId() returns false on this 15 // platform. 16 class MachineIdProvider { 17 public: 18 MachineIdProvider() = delete; 19 MachineIdProvider(const MachineIdProvider&) = delete; 20 MachineIdProvider& operator=(const MachineIdProvider&) = delete; 21 22 // Returns true if this platform provides a non-empty GetMachineId(). This is 23 // useful to avoid an async call to GetMachineId() on platforms with no 24 // implementation. 25 static bool HasId(); 26 27 // Get a string containing machine characteristics, to be used as a machine 28 // id. The implementation is split into Windows and non-Windows. The former 29 // returns the drive serial number and the latter returns the hardware 30 // model name. Should not be called if HasId() returns false. 31 // The return value should not be stored to disk or transmitted. 32 static std::string GetMachineId(); 33 }; 34 35 } // namespace metrics 36 37 #endif // COMPONENTS_METRICS_MACHINE_ID_PROVIDER_H_ 38