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..11a56d6fc03c409a09264703f84c74c8b1d5eed9 100644 |
| --- a/components/user_prefs/tracked/pref_hash_store_impl.cc |
| +++ b/components/user_prefs/tracked/pref_hash_store_impl.cc |
| @@ -9,9 +9,35 @@ |
| #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() { |
| + static std::string cached_device_id; |
| + if (cached_device_id.length() > 0) |
|
gab
2017/01/24 20:32:05
!empty()
proberge
2017/01/24 20:44:35
Done.
|
| + return cached_device_id; |
| + |
| + std::string device_id; |
| + MachineIdStatus status = GetDeterministicMachineSpecificId(&device_id); |
| + // TODO(proberge): Remove this histogram once we validate that machine id |
| + // generation is not flaky and consider adding a CHECK or DCHECK. |
| + UMA_HISTOGRAM_BOOLEAN("Settings.MachineIdGenerationSuccess", |
| + status == MachineIdStatus::SUCCESS); |
|
gab
2017/01/24 20:32:05
Put behind != NOT_IMPLEMENTED
proberge
2017/01/24 20:44:35
Done.
|
| + |
| + if (status == MachineIdStatus::SUCCESS) { |
| + cached_device_id = device_id; |
| + return device_id; |
| + } |
| + |
| + return std::string(); |
| +} |
| + |
| +} // namespace |
| + |
| class PrefHashStoreImpl::PrefHashStoreTransactionImpl |
| : public PrefHashStoreTransaction { |
| public: |
| @@ -49,10 +75,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() { |
| } |