Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: components/user_prefs/tracked/pref_hash_store_impl.cc

Issue 2634403002: Use GetDeterministicMachineSpecificId instead of RLZ for device_id (Closed)
Patch Set: Rebase Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/user_prefs/tracked/pref_hash_store_impl.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bb920ca4c98fdcf7707952d7b4079be3e1b2b9bd 100644
--- a/components/user_prefs/tracked/pref_hash_store_impl.cc
+++ b/components/user_prefs/tracked/pref_hash_store_impl.cc
@@ -9,9 +9,37 @@
#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.empty())
+ return cached_device_id;
+
+ std::string device_id;
+ MachineIdStatus status = GetDeterministicMachineSpecificId(&device_id);
+ if (status != MachineIdStatus::NOT_IMPLEMENTED) {
+ // 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);
+ }
+
+ if (status == MachineIdStatus::SUCCESS) {
+ cached_device_id = device_id;
+ return device_id;
+ }
+
+ return std::string();
+}
+
+} // namespace
+
class PrefHashStoreImpl::PrefHashStoreTransactionImpl
: public PrefHashStoreTransaction {
public:
@@ -49,10 +77,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() {
}
« no previous file with comments | « components/user_prefs/tracked/pref_hash_store_impl.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698