| 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 COMPONENTS_PREFS_JSON_PREF_STORE_H_ | 5 #ifndef COMPONENTS_PREFS_JSON_PREF_STORE_H_ |
| 6 #define COMPONENTS_PREFS_JSON_PREF_STORE_H_ | 6 #define COMPONENTS_PREFS_JSON_PREF_STORE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 friend class base::JsonPrefStoreLossyWriteTest; | 183 friend class base::JsonPrefStoreLossyWriteTest; |
| 184 friend class base::WriteCallbacksObserver; | 184 friend class base::WriteCallbacksObserver; |
| 185 | 185 |
| 186 ~JsonPrefStore() override; | 186 ~JsonPrefStore() override; |
| 187 | 187 |
| 188 // If |write_success| is true, runs |on_next_successful_write_|. | 188 // If |write_success| is true, runs |on_next_successful_write_|. |
| 189 // Otherwise, re-registers |on_next_successful_write_|. | 189 // Otherwise, re-registers |on_next_successful_write_|. |
| 190 void RunOrScheduleNextSuccessfulWriteCallback(bool write_success); | 190 void RunOrScheduleNextSuccessfulWriteCallback(bool write_success); |
| 191 | 191 |
| 192 // Handles the result of a write with result |write_success|. Runs | 192 // Handles the result of a write with result |write_success|. Runs |
| 193 // |on_next_write| callback on the current thread and posts | 193 // |on_next_write_callback| on the current thread and posts |
| 194 // |RunOrScheduleNextSuccessfulWriteCallback| on |reply_task_runner|. | 194 // |on_next_write_reply| on |reply_task_runner|. |
| 195 static void PostWriteCallback( | 195 static void PostWriteCallback( |
| 196 const base::Callback<void(bool success)>& on_next_write_callback, |
| 196 const base::Callback<void(bool success)>& on_next_write_reply, | 197 const base::Callback<void(bool success)>& on_next_write_reply, |
| 197 const base::Callback<void(bool success)>& on_next_write_callback, | |
| 198 scoped_refptr<base::SequencedTaskRunner> reply_task_runner, | 198 scoped_refptr<base::SequencedTaskRunner> reply_task_runner, |
| 199 bool write_success); | 199 bool write_success); |
| 200 | 200 |
| 201 // Registers the |callbacks| pair to be called once synchronously before and | 201 // Registers the |callbacks| pair to be called once synchronously before and |
| 202 // after, respectively, the next write event of |writer_|. | 202 // after, respectively, the next write event of |writer_|. |
| 203 // Both callbacks must be thread-safe. | 203 // Both callbacks must be thread-safe. |
| 204 void RegisterOnNextWriteSynchronousCallbacks(OnWriteCallbackPair callbacks); | 204 void RegisterOnNextWriteSynchronousCallbacks(OnWriteCallbackPair callbacks); |
| 205 | 205 |
| 206 // This method is called after the JSON file has been read. It then hands | 206 // This method is called after the JSON file has been read. It then hands |
| 207 // |value| (or an empty dictionary in some read error cases) to the | 207 // |value| (or an empty dictionary in some read error cases) to the |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 245 |
| 246 std::unique_ptr<ReadErrorDelegate> error_delegate_; | 246 std::unique_ptr<ReadErrorDelegate> error_delegate_; |
| 247 | 247 |
| 248 bool initialized_; | 248 bool initialized_; |
| 249 bool filtering_in_progress_; | 249 bool filtering_in_progress_; |
| 250 bool pending_lossy_write_; | 250 bool pending_lossy_write_; |
| 251 PrefReadError read_error_; | 251 PrefReadError read_error_; |
| 252 | 252 |
| 253 std::set<std::string> keys_need_empty_value_; | 253 std::set<std::string> keys_need_empty_value_; |
| 254 | 254 |
| 255 bool has_pending_successful_write_reply_; | 255 bool has_pending_write_reply_ = true; |
| 256 bool has_pending_write_callbacks_; | |
| 257 base::Closure on_next_successful_write_reply_; | 256 base::Closure on_next_successful_write_reply_; |
| 258 | 257 |
| 259 WriteCountHistogram write_count_histogram_; | 258 WriteCountHistogram write_count_histogram_; |
| 260 | 259 |
| 261 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 260 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
| 262 }; | 261 }; |
| 263 | 262 |
| 264 #endif // COMPONENTS_PREFS_JSON_PREF_STORE_H_ | 263 #endif // COMPONENTS_PREFS_JSON_PREF_STORE_H_ |
| OLD | NEW |