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 COMPONENTS_PREFS_JSON_PREF_STORE_H_ |
6 #define BASE_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 <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/files/important_file_writer.h" | 16 #include "base/files/important_file_writer.h" |
(...skipping 17 matching lines...) Expand all Loading... |
34 class SequencedTaskRunner; | 34 class SequencedTaskRunner; |
35 class SequencedWorkerPool; | 35 class SequencedWorkerPool; |
36 class Value; | 36 class Value; |
37 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestBasic); | 37 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestBasic); |
38 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestSinglePeriod); | 38 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestSinglePeriod); |
39 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestMultiplePeriods); | 39 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestMultiplePeriods); |
40 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestPeriodWithGaps); | 40 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestPeriodWithGaps); |
41 } | 41 } |
42 | 42 |
43 // A writable PrefStore implementation that is used for user preferences. | 43 // A writable PrefStore implementation that is used for user preferences. |
44 class BASE_PREFS_EXPORT JsonPrefStore | 44 class COMPONENTS_PREFS_EXPORT JsonPrefStore |
45 : public PersistentPrefStore, | 45 : public PersistentPrefStore, |
46 public base::ImportantFileWriter::DataSerializer, | 46 public base::ImportantFileWriter::DataSerializer, |
47 public base::SupportsWeakPtr<JsonPrefStore>, | 47 public base::SupportsWeakPtr<JsonPrefStore>, |
48 public base::NonThreadSafe { | 48 public base::NonThreadSafe { |
49 public: | 49 public: |
50 struct ReadResult; | 50 struct ReadResult; |
51 | 51 |
52 // Returns instance of SequencedTaskRunner which guarantees that file | 52 // Returns instance of SequencedTaskRunner which guarantees that file |
53 // operations on the same file will be executed in sequenced order. | 53 // operations on the same file will be executed in sequenced order. |
54 static scoped_refptr<base::SequencedTaskRunner> GetTaskRunnerForFile( | 54 static scoped_refptr<base::SequencedTaskRunner> GetTaskRunnerForFile( |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 void RemoveValueSilently(const std::string& key, uint32_t flags); | 107 void RemoveValueSilently(const std::string& key, uint32_t flags); |
108 | 108 |
109 // Registers |on_next_successful_write| to be called once, on the next | 109 // Registers |on_next_successful_write| to be called once, on the next |
110 // successful write event of |writer_|. | 110 // successful write event of |writer_|. |
111 void RegisterOnNextSuccessfulWriteCallback( | 111 void RegisterOnNextSuccessfulWriteCallback( |
112 const base::Closure& on_next_successful_write); | 112 const base::Closure& on_next_successful_write); |
113 | 113 |
114 private: | 114 private: |
115 // Represents a histogram for recording the number of writes to the pref file | 115 // Represents a histogram for recording the number of writes to the pref file |
116 // that occur every kHistogramWriteReportIntervalInMins minutes. | 116 // that occur every kHistogramWriteReportIntervalInMins minutes. |
117 class BASE_PREFS_EXPORT WriteCountHistogram { | 117 class COMPONENTS_PREFS_EXPORT WriteCountHistogram { |
118 public: | 118 public: |
119 static const int32_t kHistogramWriteReportIntervalMins; | 119 static const int32_t kHistogramWriteReportIntervalMins; |
120 | 120 |
121 WriteCountHistogram(const base::TimeDelta& commit_interval, | 121 WriteCountHistogram(const base::TimeDelta& commit_interval, |
122 const base::FilePath& path); | 122 const base::FilePath& path); |
123 // Constructor for testing. |clock| is a test Clock that is used to retrieve | 123 // Constructor for testing. |clock| is a test Clock that is used to retrieve |
124 // the time. | 124 // the time. |
125 WriteCountHistogram(const base::TimeDelta& commit_interval, | 125 WriteCountHistogram(const base::TimeDelta& commit_interval, |
126 const base::FilePath& path, | 126 const base::FilePath& path, |
127 scoped_ptr<base::Clock> clock); | 127 scoped_ptr<base::Clock> clock); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 bool pending_lossy_write_; | 219 bool pending_lossy_write_; |
220 PrefReadError read_error_; | 220 PrefReadError read_error_; |
221 | 221 |
222 std::set<std::string> keys_need_empty_value_; | 222 std::set<std::string> keys_need_empty_value_; |
223 | 223 |
224 WriteCountHistogram write_count_histogram_; | 224 WriteCountHistogram write_count_histogram_; |
225 | 225 |
226 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 226 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
227 }; | 227 }; |
228 | 228 |
229 #endif // BASE_PREFS_JSON_PREF_STORE_H_ | 229 #endif // COMPONENTS_PREFS_JSON_PREF_STORE_H_ |
OLD | NEW |