OLD | NEW |
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 #include <string> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
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 | 45 |
46 // PrefStore implementation | 46 // PrefStore implementation |
47 virtual void AddObserver(Observer* observer) OVERRIDE; | 47 virtual void AddObserver(Observer* observer) override; |
48 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 48 virtual void RemoveObserver(Observer* observer) override; |
49 virtual bool HasObservers() const OVERRIDE; | 49 virtual bool HasObservers() const override; |
50 virtual bool IsInitializationComplete() const OVERRIDE; | 50 virtual bool IsInitializationComplete() const override; |
51 virtual bool GetValue(const std::string& key, | 51 virtual bool GetValue(const std::string& key, |
52 const base::Value** result) const OVERRIDE; | 52 const base::Value** result) const override; |
53 | 53 |
54 // WriteablePrefStore implementation | 54 // WriteablePrefStore implementation |
55 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; | 55 virtual void SetValue(const std::string& key, base::Value* value) override; |
56 virtual void RemoveValue(const std::string& key) OVERRIDE; | 56 virtual void RemoveValue(const std::string& key) override; |
57 | 57 |
58 // PersistentPrefStore implementation | 58 // PersistentPrefStore implementation |
59 virtual bool GetMutableValue(const std::string& key, | 59 virtual bool GetMutableValue(const std::string& key, |
60 base::Value** result) OVERRIDE; | 60 base::Value** result) override; |
61 virtual void ReportValueChanged(const std::string& key) OVERRIDE; | 61 virtual void ReportValueChanged(const std::string& key) override; |
62 virtual void SetValueSilently(const std::string& key, | 62 virtual void SetValueSilently(const std::string& key, |
63 base::Value* value) OVERRIDE; | 63 base::Value* value) override; |
64 virtual bool ReadOnly() const OVERRIDE; | 64 virtual bool ReadOnly() const override; |
65 virtual PrefReadError GetReadError() const OVERRIDE; | 65 virtual PrefReadError GetReadError() const override; |
66 virtual PrefReadError ReadPrefs() OVERRIDE; | 66 virtual PrefReadError ReadPrefs() override; |
67 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) OVERRIDE; | 67 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override; |
68 virtual void CommitPendingWrite() OVERRIDE; | 68 virtual void CommitPendingWrite() override; |
69 | 69 |
70 private: | 70 private: |
71 // Aggregates events from the underlying stores and synthesizes external | 71 // Aggregates events from the underlying stores and synthesizes external |
72 // events via |on_initialization|, |read_error_delegate_|, and |observers_|. | 72 // events via |on_initialization|, |read_error_delegate_|, and |observers_|. |
73 class AggregatingObserver : public PrefStore::Observer { | 73 class AggregatingObserver : public PrefStore::Observer { |
74 public: | 74 public: |
75 explicit AggregatingObserver(SegregatedPrefStore* outer); | 75 explicit AggregatingObserver(SegregatedPrefStore* outer); |
76 | 76 |
77 // PrefStore::Observer implementation | 77 // PrefStore::Observer implementation |
78 virtual void OnPrefValueChanged(const std::string& key) OVERRIDE; | 78 virtual void OnPrefValueChanged(const std::string& key) override; |
79 virtual void OnInitializationCompleted(bool succeeded) OVERRIDE; | 79 virtual void OnInitializationCompleted(bool succeeded) override; |
80 | 80 |
81 private: | 81 private: |
82 SegregatedPrefStore* outer_; | 82 SegregatedPrefStore* outer_; |
83 int failed_sub_initializations_; | 83 int failed_sub_initializations_; |
84 int successful_sub_initializations_; | 84 int successful_sub_initializations_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(AggregatingObserver); | 86 DISALLOW_COPY_AND_ASSIGN(AggregatingObserver); |
87 }; | 87 }; |
88 | 88 |
89 virtual ~SegregatedPrefStore(); | 89 virtual ~SegregatedPrefStore(); |
90 | 90 |
91 // Returns |selected_pref_store| if |key| is selected and |default_pref_store| | 91 // Returns |selected_pref_store| if |key| is selected and |default_pref_store| |
92 // otherwise. | 92 // otherwise. |
93 PersistentPrefStore* StoreForKey(const std::string& key); | 93 PersistentPrefStore* StoreForKey(const std::string& key); |
94 const PersistentPrefStore* StoreForKey(const std::string& key) const; | 94 const PersistentPrefStore* StoreForKey(const std::string& key) const; |
95 | 95 |
96 scoped_refptr<PersistentPrefStore> default_pref_store_; | 96 scoped_refptr<PersistentPrefStore> default_pref_store_; |
97 scoped_refptr<PersistentPrefStore> selected_pref_store_; | 97 scoped_refptr<PersistentPrefStore> selected_pref_store_; |
98 std::set<std::string> selected_preference_names_; | 98 std::set<std::string> selected_preference_names_; |
99 | 99 |
100 scoped_ptr<PersistentPrefStore::ReadErrorDelegate> read_error_delegate_; | 100 scoped_ptr<PersistentPrefStore::ReadErrorDelegate> read_error_delegate_; |
101 ObserverList<PrefStore::Observer, true> observers_; | 101 ObserverList<PrefStore::Observer, true> observers_; |
102 AggregatingObserver aggregating_observer_; | 102 AggregatingObserver aggregating_observer_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(SegregatedPrefStore); | 104 DISALLOW_COPY_AND_ASSIGN(SegregatedPrefStore); |
105 }; | 105 }; |
106 | 106 |
107 #endif // CHROME_BROWSER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ | 107 #endif // CHROME_BROWSER_PREFS_TRACKED_SEGREGATED_PREF_STORE_H_ |
OLD | NEW |