| 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> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/files/important_file_writer.h" | 17 #include "base/files/important_file_writer.h" |
| 18 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 21 #include "base/observer_list.h" | 21 #include "base/observer_list.h" |
| 22 #include "base/sequence_checker.h" |
| 22 #include "base/task_scheduler/post_task.h" | 23 #include "base/task_scheduler/post_task.h" |
| 23 #include "base/threading/non_thread_safe.h" | |
| 24 #include "components/prefs/base_prefs_export.h" | 24 #include "components/prefs/base_prefs_export.h" |
| 25 #include "components/prefs/persistent_pref_store.h" | 25 #include "components/prefs/persistent_pref_store.h" |
| 26 #include "components/prefs/pref_filter.h" | 26 #include "components/prefs/pref_filter.h" |
| 27 | 27 |
| 28 class PrefFilter; | 28 class PrefFilter; |
| 29 | 29 |
| 30 namespace base { | 30 namespace base { |
| 31 class Clock; | 31 class Clock; |
| 32 class DictionaryValue; | 32 class DictionaryValue; |
| 33 class FilePath; | 33 class FilePath; |
| 34 class HistogramBase; | 34 class HistogramBase; |
| 35 class JsonPrefStoreCallbackTest; | 35 class JsonPrefStoreCallbackTest; |
| 36 class JsonPrefStoreLossyWriteTest; | 36 class JsonPrefStoreLossyWriteTest; |
| 37 class SequencedTaskRunner; | 37 class SequencedTaskRunner; |
| 38 class SequencedWorkerPool; | 38 class SequencedWorkerPool; |
| 39 class WriteCallbacksObserver; | 39 class WriteCallbacksObserver; |
| 40 class Value; | 40 class Value; |
| 41 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestBasic); | 41 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestBasic); |
| 42 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestSinglePeriod); | 42 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestSinglePeriod); |
| 43 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestMultiplePeriods); | 43 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestMultiplePeriods); |
| 44 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestPeriodWithGaps); | 44 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestPeriodWithGaps); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // A writable PrefStore implementation that is used for user preferences. | 47 // A writable PrefStore implementation that is used for user preferences. |
| 48 class COMPONENTS_PREFS_EXPORT JsonPrefStore | 48 class COMPONENTS_PREFS_EXPORT JsonPrefStore |
| 49 : public PersistentPrefStore, | 49 : public PersistentPrefStore, |
| 50 public base::ImportantFileWriter::DataSerializer, | 50 public base::ImportantFileWriter::DataSerializer, |
| 51 public base::SupportsWeakPtr<JsonPrefStore>, | 51 public base::SupportsWeakPtr<JsonPrefStore> { |
| 52 public base::NonThreadSafe { | |
| 53 public: | 52 public: |
| 54 struct ReadResult; | 53 struct ReadResult; |
| 55 | 54 |
| 56 // A pair of callbacks to call before and after the preference file is written | 55 // A pair of callbacks to call before and after the preference file is written |
| 57 // to disk. | 56 // to disk. |
| 58 using OnWriteCallbackPair = | 57 using OnWriteCallbackPair = |
| 59 std::pair<base::Closure, base::Callback<void(bool success)>>; | 58 std::pair<base::Closure, base::Callback<void(bool success)>>; |
| 60 | 59 |
| 61 // Returns instance of SequencedTaskRunner which guarantees that file | 60 // Returns instance of SequencedTaskRunner which guarantees that file |
| 62 // operations on the same file will be executed in sequenced order. | 61 // operations on the same file will be executed in sequenced order. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 bool pending_lossy_write_; | 245 bool pending_lossy_write_; |
| 247 PrefReadError read_error_; | 246 PrefReadError read_error_; |
| 248 | 247 |
| 249 std::set<std::string> keys_need_empty_value_; | 248 std::set<std::string> keys_need_empty_value_; |
| 250 | 249 |
| 251 bool has_pending_write_reply_ = true; | 250 bool has_pending_write_reply_ = true; |
| 252 base::Closure on_next_successful_write_reply_; | 251 base::Closure on_next_successful_write_reply_; |
| 253 | 252 |
| 254 WriteCountHistogram write_count_histogram_; | 253 WriteCountHistogram write_count_histogram_; |
| 255 | 254 |
| 255 SEQUENCE_CHECKER(sequence_checker_); |
| 256 |
| 256 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 257 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
| 257 }; | 258 }; |
| 258 | 259 |
| 259 #endif // COMPONENTS_PREFS_JSON_PREF_STORE_H_ | 260 #endif // COMPONENTS_PREFS_JSON_PREF_STORE_H_ |
| OLD | NEW |