Chromium Code Reviews| Index: components/user_prefs/tracked/pref_hash_store_impl.cc |
| diff --git a/components/user_prefs/tracked/pref_hash_store_impl.cc b/components/user_prefs/tracked/pref_hash_store_impl.cc |
| index 80438d6954a45c9c791a2c7d620e108fdeff3141..c2168403d20748314245766f091b853c7a382bf3 100644 |
| --- a/components/user_prefs/tracked/pref_hash_store_impl.cc |
| +++ b/components/user_prefs/tracked/pref_hash_store_impl.cc |
| @@ -9,9 +9,34 @@ |
| #include "base/logging.h" |
| #include "base/macros.h" |
| -#include "base/metrics/histogram.h" |
| +#include "base/metrics/histogram_macros.h" |
| +#include "components/user_prefs/tracked/device_id.h" |
| #include "components/user_prefs/tracked/hash_store_contents.h" |
| +namespace { |
| + |
| +// Returns a deterministic ID for this machine. |
| +std::string GenerateDeviceId() { |
| + std::string device_id; |
| + MachineIdStatus status = GetDeterministicMachineSpecificId(&device_id); |
| + // TODO(proberge): Remove this histogram once we validate that machine id |
| + // generation is not flaky. |
| + UMA_HISTOGRAM_ENUMERATION("Settings.MachineIdGenerationStatus", status, |
|
gab
2017/01/19 18:52:05
I don't think we want to report not implemented, i
proberge
2017/01/19 20:42:59
Done.
|
| + MachineIdStatus::NUM_STATUS); |
| + |
| + if (status == MachineIdStatus::SUCCESS) |
| + return device_id; |
| + |
| +#if defined(OS_WIN) || defined(OS_MACOSX) |
|
gab
2017/01/19 18:52:05
Use MachineIdStatus::NOT_IMPLEMENTED vs FAILURE in
proberge
2017/01/19 20:42:59
Done.
|
| + // On Windows and MacOSX we need a machine id to validate and sign |
| + // preferences. |
| + DCHECK("Failed to generate machine specific id for tracked preferences."); |
|
gab
2017/01/19 18:52:05
To generate a DCHECK message you need to use << (r
proberge
2017/01/19 20:42:59
doh! Good catch.
Removed the DCHECK for now.
|
| +#endif |
| + return std::string(); |
| +} |
| + |
| +} // namespace |
| + |
| class PrefHashStoreImpl::PrefHashStoreTransactionImpl |
| : public PrefHashStoreTransaction { |
| public: |
| @@ -49,10 +74,10 @@ class PrefHashStoreImpl::PrefHashStoreTransactionImpl |
| }; |
| PrefHashStoreImpl::PrefHashStoreImpl(const std::string& seed, |
| - const std::string& device_id, |
| + const std::string& legacy_device_id, |
| bool use_super_mac) |
| - : pref_hash_calculator_(seed, device_id), use_super_mac_(use_super_mac) { |
| -} |
| + : pref_hash_calculator_(seed, GenerateDeviceId(), legacy_device_id), |
| + use_super_mac_(use_super_mac) {} |
| PrefHashStoreImpl::~PrefHashStoreImpl() { |
| } |