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

Side by Side Diff: chrome/browser/prefs/tracked/tracked_preferences_migration.h

Issue 324493002: Move preference MACs to the protected preference stores. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to CR comments. Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ 5 #ifndef CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_
6 #define CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ 6 #define CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/memory/scoped_ptr.h"
12 13
13 class InterceptablePrefFilter; 14 namespace base {
15 class DictionaryValue;
16 } // namespace base
14 17
15 // Sets up InterceptablePrefFilter::FilterOnLoadInterceptors on 18 class PrefHashStore;
16 // |unprotected_pref_filter| and |protected_pref_filter| which prevents each 19
17 // filter from running their on load operations until the interceptors decide to 20 // Provides methods used to migrate preference values and MACs to/from a pref
18 // hand the prefs back to them (after migration is complete). | 21 // store. The underlying pref store may become invalid (i.e. during shutdown).
19 // (un)protected_store_cleaner| and 22 // In that case, IsValid() returns fase, GetPrefHashStore() returns NULL, and
20 // |register_on_successful_(un)protected_store_write_callback| are used to do 23 // all other methods are no-ops.
21 // post-migration cleanup tasks. Those should be bound to weak pointers to avoid 24 class TrackedPreferencesMigrationDelegate {
22 // blocking shutdown. The migration framework is resilient to a failed cleanup 25 public:
23 // (it will simply try again in the next Chrome run). 26 virtual ~TrackedPreferencesMigrationDelegate() {}
27
28 typedef base::Callback<void(bool prefs_altered)> InterceptCompletionCallback;
29
30 // A callback to be invoked from FilterOnLoad. It takes ownership of prefs
31 // and may modify them before handing them back to this
32 // InterceptablePrefFilter via |finalize_filter_on_load|.
33 typedef base::Callback<
34 void(const InterceptCompletionCallback& completion_callback,
35 base::DictionaryValue* prefs)> Intercept;
36
37 // Returns true if the delegate is operational.
38 virtual bool IsValid() = 0;
39
40 // Removes the preference named by |key| from the underlying PrefStore.
41 virtual void CleanPreference(const std::string& key) = 0;
42
43 // Registers |on_successful_write| to be notified when the underlying
44 // PrefStore is next successfully persisted.
45 virtual void NotifyOnSuccessfulWrite(
46 const base::Closure& on_successful_write) = 0;
47
48 // Registers |intercept| to receive the contents of the underlying PrefStore
49 // as they are loaded from disk.
50 virtual void InterceptLoadedPreferences(const Intercept& intercept) = 0;
51
52 // Returns the PrefHashStore responsible for storing/retrieving MACs that
53 // protect preferences in the underlying PrefStore.
54 virtual PrefHashStore* GetPrefHashStore() = 0;
55 };
56
57 // Uses |unprotected_delegate| and |protected_delegate| to intercept the
58 // contents of the Preferences and Protected Preferences files
59 // (respectively). Blocks the loading of the first loaded store, and migrates
60 // preferences and MACs upon interception of the second loaded store.
61 // |unprotected_pref_names| and |protected_pref_names| determine which
62 // preferences and MACs will be migrated. Prior to migration, MACs may be either
63 // colocated with their protected preferences or located in
64 // |legacy_pref_hash_store|. Post migration all MACs will be colocated with
65 // their protected preferences.
66 // If the migration is interrupted at any point it should resume successfully in
67 // a subsequent attempt.
24 void SetupTrackedPreferencesMigration( 68 void SetupTrackedPreferencesMigration(
25 const std::set<std::string>& unprotected_pref_names, 69 const std::set<std::string>& unprotected_pref_names,
26 const std::set<std::string>& protected_pref_names, 70 const std::set<std::string>& protected_pref_names,
27 const base::Callback<void(const std::string& key)>& 71 scoped_ptr<TrackedPreferencesMigrationDelegate> unprotected_delegate,
28 unprotected_store_cleaner, 72 scoped_ptr<TrackedPreferencesMigrationDelegate> protected_delegate,
29 const base::Callback<void(const std::string& key)>& protected_store_cleaner, 73 scoped_ptr<PrefHashStore> legacy_pref_hash_store);
30 const base::Callback<void(const base::Closure&)>&
31 register_on_successful_unprotected_store_write_callback,
32 const base::Callback<void(const base::Closure&)>&
33 register_on_successful_protected_store_write_callback,
34 InterceptablePrefFilter* unprotected_pref_filter,
35 InterceptablePrefFilter* protected_pref_filter);
36 74
37 #endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_ 75 #endif // CHROME_BROWSER_PREFS_TRACKED_TRACKED_PREFERENCES_MIGRATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698