OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 BASE_PREFS_JSON_PREF_STORE_H_ | 5 #ifndef BASE_PREFS_JSON_PREF_STORE_H_ |
6 #define BASE_PREFS_JSON_PREF_STORE_H_ | 6 #define BASE_PREFS_JSON_PREF_STORE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/important_file_writer.h" | 15 #include "base/files/important_file_writer.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/scoped_vector.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
18 #include "base/message_loop/message_loop_proxy.h" | 19 #include "base/message_loop/message_loop_proxy.h" |
19 #include "base/observer_list.h" | 20 #include "base/observer_list.h" |
20 #include "base/prefs/base_prefs_export.h" | 21 #include "base/prefs/base_prefs_export.h" |
21 #include "base/prefs/persistent_pref_store.h" | 22 #include "base/prefs/persistent_pref_store.h" |
22 #include "base/threading/non_thread_safe.h" | 23 #include "base/threading/non_thread_safe.h" |
23 | 24 |
24 class PrefFilter; | 25 class PrefFilter; |
25 | 26 |
26 namespace base { | 27 namespace base { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Just like RemoveValue(), but doesn't notify observers. Used when doing some | 92 // Just like RemoveValue(), but doesn't notify observers. Used when doing some |
92 // cleanup that shouldn't otherwise alert observers. | 93 // cleanup that shouldn't otherwise alert observers. |
93 void RemoveValueSilently(const std::string& key); | 94 void RemoveValueSilently(const std::string& key); |
94 | 95 |
95 // Registers |on_next_successful_write| to be called once, on the next | 96 // Registers |on_next_successful_write| to be called once, on the next |
96 // successful write event of |writer_|. | 97 // successful write event of |writer_|. |
97 void RegisterOnNextSuccessfulWriteCallback( | 98 void RegisterOnNextSuccessfulWriteCallback( |
98 const base::Closure& on_next_successful_write); | 99 const base::Closure& on_next_successful_write); |
99 | 100 |
100 private: | 101 private: |
| 102 class WriteCountHistogram; |
| 103 |
101 ~JsonPrefStore() override; | 104 ~JsonPrefStore() override; |
102 | 105 |
103 // This method is called after the JSON file has been read. It then hands | 106 // This method is called after the JSON file has been read. It then hands |
104 // |value| (or an empty dictionary in some read error cases) to the | 107 // |value| (or an empty dictionary in some read error cases) to the |
105 // |pref_filter| if one is set. It also gives a callback pointing at | 108 // |pref_filter| if one is set. It also gives a callback pointing at |
106 // FinalizeFileRead() to that |pref_filter_| which is then responsible for | 109 // FinalizeFileRead() to that |pref_filter_| which is then responsible for |
107 // invoking it when done. If there is no |pref_filter_|, FinalizeFileRead() | 110 // invoking it when done. If there is no |pref_filter_|, FinalizeFileRead() |
108 // is invoked directly. | 111 // is invoked directly. |
109 void OnFileRead(scoped_ptr<ReadResult> read_result); | 112 void OnFileRead(scoped_ptr<ReadResult> read_result); |
110 | 113 |
(...skipping 26 matching lines...) Expand all Loading... |
137 ObserverList<PrefStore::Observer, true> observers_; | 140 ObserverList<PrefStore::Observer, true> observers_; |
138 | 141 |
139 scoped_ptr<ReadErrorDelegate> error_delegate_; | 142 scoped_ptr<ReadErrorDelegate> error_delegate_; |
140 | 143 |
141 bool initialized_; | 144 bool initialized_; |
142 bool filtering_in_progress_; | 145 bool filtering_in_progress_; |
143 PrefReadError read_error_; | 146 PrefReadError read_error_; |
144 | 147 |
145 std::set<std::string> keys_need_empty_value_; | 148 std::set<std::string> keys_need_empty_value_; |
146 | 149 |
| 150 scoped_ptr<WriteCountHistogram> write_count_histogram_; |
| 151 |
147 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 152 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
148 }; | 153 }; |
149 | 154 |
150 #endif // BASE_PREFS_JSON_PREF_STORE_H_ | 155 #endif // BASE_PREFS_JSON_PREF_STORE_H_ |
OLD | NEW |