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

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: Also filter 'empty loads' as in new run or corrupted pref file scenarios. 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
« no previous file with comments | « chrome/browser/prefs/pref_service_browsertest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index d8c3ce3b0f6ba2bd86d8af156bd7c31c13556694..41dea64da3ce6f781a64b43d6920d7a1d6a0209d 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -60,6 +60,7 @@
#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_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"
@@ -93,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"
@@ -118,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)
@@ -257,6 +262,33 @@ void SchedulePrefsFileVerification(const base::FilePath& prefs_file) {
#endif
}
+scoped_ptr<PrefHashStore> GetPrefHashStore(Profile* profile) {
+ // TODO(erikwright): Enable this on Android when race condition is sorted out.
+#if defined(OS_ANDROID)
+ return scoped_ptr<PrefHashStore>();
+#else
+ 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 (http://crbug.com/276485) 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(
+ profile->GetPath().AsUTF8Unsafe(),
+ seed,
+ device_id,
+ g_browser_process->local_state()));
+#endif
+}
+
} // namespace
// static
@@ -460,6 +492,7 @@ ProfileImpl::ProfileImpl(
sequenced_task_runner,
profile_policy_connector_->policy_service(),
managed_user_settings,
+ GetPrefHashStore(this),
new ExtensionPrefStore(
ExtensionPrefValueMapFactory::GetForBrowserContext(this), false),
pref_registry_,
« no previous file with comments | « chrome/browser/prefs/pref_service_browsertest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698