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

Unified Diff: components/user_prefs/tracked/pref_hash_filter.h

Issue 2204943002: Integrate registry_hash_store_contents with the rest of tracked prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and added important_file_writer CL as dependent patchset Created 4 years, 3 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
Index: components/user_prefs/tracked/pref_hash_filter.h
diff --git a/components/user_prefs/tracked/pref_hash_filter.h b/components/user_prefs/tracked/pref_hash_filter.h
index 8652a7f817c545a5b48e1154c60af1427eadbbbb..14ee9c69cdc099ac62012f0c1f4b8e4f88a0b050 100644
--- a/components/user_prefs/tracked/pref_hash_filter.h
+++ b/components/user_prefs/tracked/pref_hash_filter.h
@@ -15,10 +15,13 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/containers/scoped_ptr_hash_map.h"
+#include "base/files/file_path.h"
#include "base/macros.h"
+#include "base/optional.h"
#include "components/user_prefs/tracked/interceptable_pref_filter.h"
#include "components/user_prefs/tracked/tracked_preference.h"
+class HashStoreContents;
class PrefHashStore;
class PrefService;
class PrefStore;
@@ -64,6 +67,9 @@ class PrefHashFilter : public InterceptablePrefFilter {
ValueType value_type;
};
+ using StoreContentsPair = std::pair<std::unique_ptr<PrefHashStore>,
+ std::unique_ptr<HashStoreContents>>;
+
// Constructs a PrefHashFilter tracking the specified |tracked_preferences|
// using |pref_hash_store| to check/store hashes. An optional |delegate| is
// notified of the status of each preference as it is checked.
@@ -73,8 +79,11 @@ class PrefHashFilter : public InterceptablePrefFilter {
// than |tracked_preferences.size()|). If |report_super_mac_validity| is true,
// the state of the super MAC will be reported via UMA during
// FinalizeFilterOnLoad.
+ // |external_validation_hash_store_pair_| will be used (if non-null) to
+ // perform extra validations without triggering resets.
PrefHashFilter(
std::unique_ptr<PrefHashStore> pref_hash_store,
+ StoreContentsPair* external_validation_hash_store_pair_,
const std::vector<TrackedPreferenceMetadata>& tracked_preferences,
const base::Closure& on_reset_on_load,
TrackedPreferenceValidationDelegate* delegate,
@@ -101,7 +110,8 @@ class PrefHashFilter : public InterceptablePrefFilter {
// PrefFilter remaining implementation.
void FilterUpdate(const std::string& path) override;
- void FilterSerializeData(base::DictionaryValue* pref_store_contents) override;
+ base::Callback<void(bool)> FilterSerializeData(
+ base::DictionaryValue* pref_store_contents) override;
private:
// InterceptablePrefFilter implementation.
@@ -110,6 +120,19 @@ class PrefHashFilter : public InterceptablePrefFilter {
std::unique_ptr<base::DictionaryValue> pref_store_contents,
bool prefs_altered) override;
+ // Helper function to generate the callback returned by |FilterSerializeData|.
+ // The returned callback is thread-safe.
+ base::Callback<void(bool)> GetOnWriteSynchronousCallback(
+ base::DictionaryValue* pref_store_contents);
+
+ // Flushes the MACs contained in |changed_paths_and_mac| to
+ // external_hash_store_contents if |write_success|, otherwise discards the
+ // changes.
+ static void PrefHashFilter::FlushToExternalStore(
+ std::unique_ptr<HashStoreContents> external_hash_store_contents,
+ std::unique_ptr<base::DictionaryValue> changed_paths_and_macs,
+ bool write_success);
+
// Callback to be invoked only once (and subsequently reset) on the next
// FilterOnLoad event. It will be allowed to modify the |prefs| handed to
// FilterOnLoad before handing them back to this PrefHashFilter.
@@ -120,12 +143,18 @@ class PrefHashFilter : public InterceptablePrefFilter {
typedef base::ScopedPtrHashMap<std::string,
std::unique_ptr<TrackedPreference>>
TrackedPreferencesMap;
+
// A map from changed paths to their corresponding TrackedPreferences (which
// aren't owned by this map).
typedef std::map<std::string, const TrackedPreference*> ChangedPathsMap;
std::unique_ptr<PrefHashStore> pref_hash_store_;
+ // A store and contents on which to perform extra validations without
+ // triggering resets.
+ // Will be null if the platform does not support external validation.
+ const base::Optional<StoreContentsPair> external_validation_hash_store_pair_;
+
// Invoked if a reset occurs in a call to FilterOnLoad.
const base::Closure on_reset_on_load_;

Powered by Google App Engine
This is Rietveld 408576698