machine_id_provider.h 1.4 KB

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