Index: chrome/browser/prefs/tracked/tracked_preferences_migration.h |
diff --git a/chrome/browser/prefs/tracked/tracked_preferences_migration.h b/chrome/browser/prefs/tracked/tracked_preferences_migration.h |
index 348f844cc00a7bb0ee62c5b5ac80367a830d3fe4..20ef1012a181001c9e5478d8b9f50584b25b4e6d 100644 |
--- a/chrome/browser/prefs/tracked/tracked_preferences_migration.h |
+++ b/chrome/browser/prefs/tracked/tracked_preferences_migration.h |
@@ -9,29 +9,67 @@ |
#include <string> |
#include "base/callback_forward.h" |
+#include "base/memory/scoped_ptr.h" |
-class InterceptablePrefFilter; |
- |
-// Sets up InterceptablePrefFilter::FilterOnLoadInterceptors on |
-// |unprotected_pref_filter| and |protected_pref_filter| which prevents each |
-// filter from running their on load operations until the interceptors decide to |
-// hand the prefs back to them (after migration is complete). | |
-// (un)protected_store_cleaner| and |
-// |register_on_successful_(un)protected_store_write_callback| are used to do |
-// post-migration cleanup tasks. Those should be bound to weak pointers to avoid |
-// blocking shutdown. The migration framework is resilient to a failed cleanup |
-// (it will simply try again in the next Chrome run). |
+namespace base { |
+class DictionaryValue; |
+} // namespace base |
+ |
+class PrefHashStore; |
+ |
+// Provides methods used to migrate preference values and MACs to/from a pref |
+// store. The underlying pref store may become invalid (i.e. during shutdown). |
+// In that case, IsValid() returns fase, GetPrefHashStore() returns NULL, and |
+// all other methods are no-ops. |
+class TrackedPreferencesMigrationDelegate { |
+ public: |
+ virtual ~TrackedPreferencesMigrationDelegate() {} |
+ |
+ typedef base::Callback<void(bool prefs_altered)> InterceptCompletionCallback; |
+ |
+ // A callback to be invoked from FilterOnLoad. It takes ownership of prefs |
+ // and may modify them before handing them back to this |
+ // InterceptablePrefFilter via |finalize_filter_on_load|. |
+ typedef base::Callback< |
+ void(const InterceptCompletionCallback& completion_callback, |
+ base::DictionaryValue* prefs)> Intercept; |
+ |
+ // Returns true if the delegate is operational. |
+ virtual bool IsValid() = 0; |
+ |
+ // Removes the preference named by |key| from the underlying PrefStore. |
+ virtual void CleanPreference(const std::string& key) = 0; |
+ |
+ // Registers |on_successful_write| to be notified when the underlying |
+ // PrefStore is next successfully persisted. |
+ virtual void NotifyOnSuccessfulWrite( |
+ const base::Closure& on_successful_write) = 0; |
+ |
+ // Registers |intercept| to receive the contents of the underlying PrefStore |
+ // as they are loaded from disk. |
+ virtual void InterceptLoadedPreferences(const Intercept& intercept) = 0; |
+ |
+ // Returns the PrefHashStore responsible for storing/retrieving MACs that |
+ // protect preferences in the underlying PrefStore. |
+ virtual PrefHashStore* GetPrefHashStore() = 0; |
+}; |
+ |
+// Uses |unprotected_delegate| and |protected_delegate| to intercept the |
+// contents of the Preferences and Protected Preferences files |
+// (respectively). Blocks the loading of the first loaded store, and migrates |
+// preferences and MACs upon interception of the second loaded store. |
+// |unprotected_pref_names| and |protected_pref_names| determine which |
+// preferences and MACs will be migrated. Prior to migration, MACs may be either |
+// colocated with their protected preferences or located in |
+// |legacy_pref_hash_store|. Post migration all MACs will be colocated with |
+// their protected preferences. |
+// If the migration is interrupted at any point it should resume successfully in |
+// a subsequent attempt. |
void SetupTrackedPreferencesMigration( |
const std::set<std::string>& unprotected_pref_names, |
const std::set<std::string>& protected_pref_names, |
- const base::Callback<void(const std::string& key)>& |
- unprotected_store_cleaner, |
- const base::Callback<void(const std::string& key)>& protected_store_cleaner, |
- const base::Callback<void(const base::Closure&)>& |
- register_on_successful_unprotected_store_write_callback, |
- const base::Callback<void(const base::Closure&)>& |
- register_on_successful_protected_store_write_callback, |
- InterceptablePrefFilter* unprotected_pref_filter, |
- InterceptablePrefFilter* protected_pref_filter); |
+ scoped_ptr<TrackedPreferencesMigrationDelegate> unprotected_delegate, |
+ scoped_ptr<TrackedPreferencesMigrationDelegate> protected_delegate, |
+ scoped_ptr<PrefHashStore> legacy_pref_hash_store); |
#endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ |