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

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

Issue 257003007: Introduce a new framework for back-and-forth tracked/protected preferences migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment nit Created 6 years, 7 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_SEGREGATED_PREF_STORE_H_ 5 #ifndef CHROME_BROWSER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_
6 #define CHROME_BROWSER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ 6 #define CHROME_BROWSER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string>
9 10
10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/prefs/persistent_pref_store.h" 16 #include "base/prefs/persistent_pref_store.h"
17 17
18 // Provides a unified PersistentPrefStore implementation that splits its storage 18 // Provides a unified PersistentPrefStore implementation that splits its storage
19 // and retrieval between two underlying PersistentPrefStore instances: a set of 19 // and retrieval between two underlying PersistentPrefStore instances: a set of
20 // preference names is used to partition the preferences. 20 // preference names is used to partition the preferences.
(...skipping 13 matching lines...) Expand all
34 // preferences named in |selected_pref_names| and to |default_pref_store| 34 // preferences named in |selected_pref_names| and to |default_pref_store|
35 // for all others. If an unselected preference is present in 35 // for all others. If an unselected preference is present in
36 // |selected_pref_store| (i.e. because it was previously selected) it will 36 // |selected_pref_store| (i.e. because it was previously selected) it will
37 // be migrated back to |default_pref_store| upon access via a non-const 37 // be migrated back to |default_pref_store| upon access via a non-const
38 // method. 38 // method.
39 // |on_initialization| will be invoked when both stores have been initialized, 39 // |on_initialization| will be invoked when both stores have been initialized,
40 // before observers of the SegregatedPrefStore store are notified. 40 // before observers of the SegregatedPrefStore store are notified.
41 SegregatedPrefStore( 41 SegregatedPrefStore(
42 const scoped_refptr<PersistentPrefStore>& default_pref_store, 42 const scoped_refptr<PersistentPrefStore>& default_pref_store,
43 const scoped_refptr<PersistentPrefStore>& selected_pref_store, 43 const scoped_refptr<PersistentPrefStore>& selected_pref_store,
44 const std::set<std::string>& selected_pref_names, 44 const std::set<std::string>& selected_pref_names);
45 const base::Closure& on_initialization);
46 45
47 // PrefStore implementation 46 // PrefStore implementation
48 virtual void AddObserver(Observer* observer) OVERRIDE; 47 virtual void AddObserver(Observer* observer) OVERRIDE;
49 virtual void RemoveObserver(Observer* observer) OVERRIDE; 48 virtual void RemoveObserver(Observer* observer) OVERRIDE;
50 virtual bool HasObservers() const OVERRIDE; 49 virtual bool HasObservers() const OVERRIDE;
51 virtual bool IsInitializationComplete() const OVERRIDE; 50 virtual bool IsInitializationComplete() const OVERRIDE;
52 virtual bool GetValue(const std::string& key, 51 virtual bool GetValue(const std::string& key,
53 const base::Value** result) const OVERRIDE; 52 const base::Value** result) const OVERRIDE;
54 53
55 // WriteablePrefStore implementation 54 // WriteablePrefStore implementation
(...skipping 26 matching lines...) Expand all
82 private: 81 private:
83 SegregatedPrefStore* outer_; 82 SegregatedPrefStore* outer_;
84 int failed_sub_initializations_; 83 int failed_sub_initializations_;
85 int successful_sub_initializations_; 84 int successful_sub_initializations_;
86 85
87 DISALLOW_COPY_AND_ASSIGN(AggregatingObserver); 86 DISALLOW_COPY_AND_ASSIGN(AggregatingObserver);
88 }; 87 };
89 88
90 virtual ~SegregatedPrefStore(); 89 virtual ~SegregatedPrefStore();
91 90
92 // Returns |selected_pref_store| if |key| is selected or a value is present 91 // Returns |selected_pref_store| if |key| is selected and |default_pref_store|
93 // in |selected_pref_store|. This could happen if |key| was previously 92 // otherwise.
94 // selected. 93 PersistentPrefStore* StoreForKey(const std::string& key);
95 const PersistentPrefStore* StoreForKey(const std::string& key) const; 94 const PersistentPrefStore* StoreForKey(const std::string& key) const;
96 95
97 // Returns |selected_pref_store| if |key| is selected. If |key| is
98 // unselected but has a value in |selected_pref_store|, moves the value to
99 // |default_pref_store| before returning |default_pref_store|.
100 PersistentPrefStore* StoreForKey(const std::string& key);
101
102 scoped_refptr<PersistentPrefStore> default_pref_store_; 96 scoped_refptr<PersistentPrefStore> default_pref_store_;
103 scoped_refptr<PersistentPrefStore> selected_pref_store_; 97 scoped_refptr<PersistentPrefStore> selected_pref_store_;
104 std::set<std::string> selected_preference_names_; 98 std::set<std::string> selected_preference_names_;
105 base::Closure on_initialization_;
106 99
107 scoped_ptr<PersistentPrefStore::ReadErrorDelegate> read_error_delegate_; 100 scoped_ptr<PersistentPrefStore::ReadErrorDelegate> read_error_delegate_;
108 ObserverList<PrefStore::Observer, true> observers_; 101 ObserverList<PrefStore::Observer, true> observers_;
109 AggregatingObserver aggregating_observer_; 102 AggregatingObserver aggregating_observer_;
110 103
111 DISALLOW_COPY_AND_ASSIGN(SegregatedPrefStore); 104 DISALLOW_COPY_AND_ASSIGN(SegregatedPrefStore);
112 }; 105 };
113 106
114 #endif // CHROME_BROWSER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ 107 #endif // CHROME_BROWSER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/profile_pref_store_manager_unittest.cc ('k') | chrome/browser/prefs/tracked/segregated_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698