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

Unified Diff: chrome/browser/profiles/profile_impl.cc

Issue 90563003: Fix a race condition in preference metric reporting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to Gab's comments. Created 7 years 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
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index d9010a7ebfa1a7ca45657e62d4ef76a8035f7d77..41232fe05bf6731318f32cbcb1c3157d074f0b74 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -60,6 +60,8 @@
#include "chrome/browser/policy/profile_policy_connector_factory.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
+#include "chrome/browser/prefs/pref_hash_calculator.h"
+#include "chrome/browser/prefs/pref_hash_store_impl.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/prerender/prerender_manager_factory.h"
#include "chrome/browser/profiles/bookmark_model_loaded_observer.h"
@@ -92,6 +94,7 @@
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/common/content_constants.h"
+#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -117,6 +120,9 @@
#if defined(OS_WIN)
#include "chrome/browser/profiles/file_path_verifier_win.h"
#include "chrome/installer/util/install_util.h"
+#if defined(ENABLE_RLZ)
+#include "rlz/lib/machine_id.h"
+#endif
#endif
#if defined(OS_CHROMEOS)
@@ -256,6 +262,27 @@ void SchedulePrefsFileVerification(const base::FilePath& prefs_file) {
#endif
}
+scoped_ptr<PrefHashStore> GetPrefHashStore(Profile* profile) {
+ std::string seed = ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_PREF_HASH_SEED_BIN).as_string();
+ std::string device_id;
+
+#if defined(OS_WIN) && defined(ENABLE_RLZ)
+ // This is used by
+ // chrome/browser/extensions/api/music_manager_private/device_id_win.cc
+ // but that API is private and other platforms are not available
+ // synchronously.
+ // As part of improving pref metrics on other platforms we may want to find
+ // ways to defer preference loading until the device ID can be used.
+ rlz_lib::GetMachineId(&device_id);
+#endif
+
+ return scoped_ptr<PrefHashStore>(new PrefHashStoreImpl(
+ PrefHashCalculator(seed, device_id),
+ g_browser_process->local_state(),
+ profile->GetPath().AsUTF8Unsafe()));
+}
+
} // namespace
// static
@@ -452,6 +479,7 @@ ProfileImpl::ProfileImpl(
sequenced_task_runner,
profile_policy_connector_->policy_service(),
managed_user_settings,
+ GetPrefHashStore(this),
new ExtensionPrefStore(
ExtensionPrefValueMapFactory::GetForBrowserContext(this), false),
pref_registry_,

Powered by Google App Engine
This is Rietveld 408576698