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

Unified Diff: chrome/browser/prefs/profile_pref_store_manager.cc

Issue 2745563005: Pref service: add support for tracked prefs. (Closed)
Patch Set: Created 3 years, 9 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 | « chrome/browser/prefs/profile_pref_store_manager.h ('k') | components/user_prefs/tracked/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/profile_pref_store_manager.cc
diff --git a/chrome/browser/prefs/profile_pref_store_manager.cc b/chrome/browser/prefs/profile_pref_store_manager.cc
index 4310f9f16f366f67ec5af9f056b45d24c9b46735..ac8f1dc2bb5189505649de51d888c08f6cfdc6b6 100644
--- a/chrome/browser/prefs/profile_pref_store_manager.cc
+++ b/chrome/browser/prefs/profile_pref_store_manager.cc
@@ -23,6 +23,8 @@
#include "components/user_prefs/tracked/pref_hash_store_impl.h"
#include "components/user_prefs/tracked/segregated_pref_store.h"
#include "components/user_prefs/tracked/tracked_preferences_migration.h"
+#include "services/preferences/public/cpp/tracked_persistent_pref_store_factory.h"
+#include "services/preferences/public/interfaces/preferences_configuration.mojom.h"
#if defined(OS_WIN)
#include "chrome/install_static/install_util.h"
@@ -31,14 +33,6 @@
namespace {
-void RemoveValueSilently(const base::WeakPtr<JsonPrefStore> pref_store,
- const std::string& key) {
- if (pref_store) {
- pref_store->RemoveValueSilently(
- key, WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
- }
-}
-
#if defined(OS_WIN)
// Forces a different registry key to be used for storing preference validation
// MACs. See |SetPreferenceValidationRegistryPathForTesting|.
@@ -100,71 +94,26 @@ void ProfilePrefStoreManager::SetPreferenceValidationRegistryPathForTesting(
#endif // OS_WIN
PersistentPrefStore* ProfilePrefStoreManager::CreateProfilePrefStore(
- const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
+ scoped_refptr<base::SequencedTaskRunner> io_task_runner,
const base::Closure& on_reset_on_load,
prefs::mojom::TrackedPreferenceValidationDelegate* validation_delegate) {
- std::unique_ptr<PrefFilter> pref_filter;
if (!kPlatformSupportsPreferenceTracking) {
return new JsonPrefStore(profile_path_.Append(chrome::kPreferencesFilename),
- io_task_runner.get(),
- std::unique_ptr<PrefFilter>());
- }
-
- std::vector<PrefHashFilter::TrackedPreferenceMetadata>
- unprotected_configuration;
- std::vector<PrefHashFilter::TrackedPreferenceMetadata>
- protected_configuration;
- std::set<std::string> protected_pref_names;
- std::set<std::string> unprotected_pref_names;
- for (std::vector<PrefHashFilter::TrackedPreferenceMetadata>::const_iterator
- it = tracking_configuration_.begin();
- it != tracking_configuration_.end();
- ++it) {
- if (it->enforcement_level >
- PrefHashFilter::EnforcementLevel::NO_ENFORCEMENT) {
- protected_configuration.push_back(*it);
- protected_pref_names.insert(it->name);
- } else {
- unprotected_configuration.push_back(*it);
- unprotected_pref_names.insert(it->name);
- }
+ io_task_runner, std::unique_ptr<PrefFilter>());
gab 2017/03/15 15:09:58 std::move here as well (since returning reference
Sam McNally 2017/03/16 07:13:48 Done.
}
-
- std::unique_ptr<PrefHashFilter> unprotected_pref_hash_filter(
- new PrefHashFilter(GetPrefHashStore(false),
- GetExternalVerificationPrefHashStorePair(),
- unprotected_configuration, base::Closure(),
- validation_delegate, reporting_ids_count_, false));
- std::unique_ptr<PrefHashFilter> protected_pref_hash_filter(new PrefHashFilter(
- GetPrefHashStore(true), GetExternalVerificationPrefHashStorePair(),
- protected_configuration, on_reset_on_load, validation_delegate,
- reporting_ids_count_, true));
-
- PrefHashFilter* raw_unprotected_pref_hash_filter =
- unprotected_pref_hash_filter.get();
- PrefHashFilter* raw_protected_pref_hash_filter =
- protected_pref_hash_filter.get();
-
- scoped_refptr<JsonPrefStore> unprotected_pref_store(new JsonPrefStore(
- profile_path_.Append(chrome::kPreferencesFilename), io_task_runner.get(),
- std::move(unprotected_pref_hash_filter)));
- scoped_refptr<JsonPrefStore> protected_pref_store(new JsonPrefStore(
+ return prefs::CreateTrackedPersistentPrefStore(
+ std::move(io_task_runner),
+ profile_path_.Append(chrome::kPreferencesFilename),
profile_path_.Append(chrome::kSecurePreferencesFilename),
- io_task_runner.get(), std::move(protected_pref_hash_filter)));
-
- SetupTrackedPreferencesMigration(
- unprotected_pref_names, protected_pref_names,
- base::Bind(&RemoveValueSilently, unprotected_pref_store->AsWeakPtr()),
- base::Bind(&RemoveValueSilently, protected_pref_store->AsWeakPtr()),
- base::Bind(&JsonPrefStore::RegisterOnNextSuccessfulWriteReply,
- unprotected_pref_store->AsWeakPtr()),
- base::Bind(&JsonPrefStore::RegisterOnNextSuccessfulWriteReply,
- protected_pref_store->AsWeakPtr()),
- GetPrefHashStore(false), GetPrefHashStore(true),
- raw_unprotected_pref_hash_filter, raw_protected_pref_hash_filter);
-
- return new SegregatedPrefStore(unprotected_pref_store, protected_pref_store,
- protected_pref_names);
+ tracking_configuration_, reporting_ids_count_, seed_, legacy_device_id_,
+#if defined(OS_WIN)
+ g_preference_validation_registry_path_for_testing
+ ? *g_preference_validation_registry_path_for_testing
+ : install_static::GetRegistryPath(),
+#else
+ base::string16(),
+#endif
+ validation_delegate, on_reset_on_load);
}
bool ProfilePrefStoreManager::InitializePrefsFromMasterPrefs(
@@ -175,7 +124,7 @@ bool ProfilePrefStoreManager::InitializePrefsFromMasterPrefs(
return false;
if (kPlatformSupportsPreferenceTracking) {
- PrefHashFilter(GetPrefHashStore(false),
+ PrefHashFilter(GetPrefHashStore(),
gab 2017/03/15 15:09:58 inline GetPrefHashStore() here as this is now the
Sam McNally 2017/03/16 07:13:48 Done.
GetExternalVerificationPrefHashStorePair(),
tracking_configuration_, base::Closure(), NULL,
reporting_ids_count_, false)
@@ -198,12 +147,11 @@ bool ProfilePrefStoreManager::InitializePrefsFromMasterPrefs(
return success;
}
-std::unique_ptr<PrefHashStore> ProfilePrefStoreManager::GetPrefHashStore(
- bool use_super_mac) {
+std::unique_ptr<PrefHashStore> ProfilePrefStoreManager::GetPrefHashStore() {
DCHECK(kPlatformSupportsPreferenceTracking);
return std::unique_ptr<PrefHashStore>(
- new PrefHashStoreImpl(seed_, legacy_device_id_, use_super_mac));
+ new PrefHashStoreImpl(seed_, legacy_device_id_, false));
}
std::pair<std::unique_ptr<PrefHashStore>, std::unique_ptr<HashStoreContents>>
« no previous file with comments | « chrome/browser/prefs/profile_pref_store_manager.h ('k') | components/user_prefs/tracked/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698