OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_FILESYSTEM_PUBLIC_CPP_PREFS_FILESYSTEM_JSON_PREF_STORE_H_ | 5 #ifndef COMPONENTS_FILESYSTEM_PUBLIC_CPP_PREFS_FILESYSTEM_JSON_PREF_STORE_H_ |
6 #define COMPONENTS_FILESYSTEM_PUBLIC_CPP_PREFS_FILESYSTEM_JSON_PREF_STORE_H_ | 6 #define COMPONENTS_FILESYSTEM_PUBLIC_CPP_PREFS_FILESYSTEM_JSON_PREF_STORE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Opens the filesystem and calls |callback| when completed, whether | 133 // Opens the filesystem and calls |callback| when completed, whether |
134 // successfully or unsuccessfully. | 134 // successfully or unsuccessfully. |
135 void OpenFilesystem(base::Closure callback); | 135 void OpenFilesystem(base::Closure callback); |
136 | 136 |
137 // Callback method which verifies that there were no errors on opening the | 137 // Callback method which verifies that there were no errors on opening the |
138 // filesystem, and if there aren't, invokes the passed in callback. | 138 // filesystem, and if there aren't, invokes the passed in callback. |
139 void OnOpenFilesystem(base::Closure callback, FileError err); | 139 void OnOpenFilesystem(base::Closure callback, FileError err); |
140 | 140 |
141 // Asynchronous implementation details of PerformWrite(). | 141 // Asynchronous implementation details of PerformWrite(). |
142 void OnTempFileWriteStart(); | 142 void OnTempFileWriteStart(); |
143 void OnTempFileWrite(FileError err); | 143 void OnTempFileOpened(FileError err); |
| 144 void OnTempFileWrite(FileError err, uint32_t num_bytes_written); |
| 145 void OnTempFileClosed(FileError err); |
144 void OnTempFileRenamed(FileError err); | 146 void OnTempFileRenamed(FileError err); |
145 | 147 |
146 // Asynchronous implementation details of ReadPrefsAsync(). | 148 // Asynchronous implementation details of ReadPrefsAsync(). |
147 void OnPreferencesReadStart(); | 149 void OnPreferencesReadStart(); |
| 150 void OnPreferencesFileOpened(FileError err); |
148 void OnPreferencesFileRead(FileError err, mojo::Array<uint8_t> contents); | 151 void OnPreferencesFileRead(FileError err, mojo::Array<uint8_t> contents); |
149 | 152 |
150 const std::string path_; | 153 const std::string path_; |
151 mojo::Binding<filesystem::FileSystemClient> binding_; | 154 mojo::Binding<filesystem::FileSystemClient> binding_; |
152 filesystem::FileSystemPtr filesystem_; | 155 filesystem::FileSystemPtr filesystem_; |
153 | 156 |
154 // |directory_| is only bound after the first attempt to access the | 157 // |directory_| is only bound after the first attempt to access the |
155 // |filesystem. See OpenFilesystem(). | 158 // |filesystem. See OpenFilesystem(). |
156 DirectoryPtr directory_; | 159 DirectoryPtr directory_; |
157 | 160 |
| 161 FilePtr preferences_file_; |
| 162 FilePtr temporary_file_; |
| 163 |
158 scoped_ptr<base::DictionaryValue> prefs_; | 164 scoped_ptr<base::DictionaryValue> prefs_; |
159 | 165 |
160 bool read_only_; | 166 bool read_only_; |
161 | 167 |
162 scoped_ptr<PrefFilter> pref_filter_; | 168 scoped_ptr<PrefFilter> pref_filter_; |
163 base::ObserverList<PrefStore::Observer, true> observers_; | 169 base::ObserverList<PrefStore::Observer, true> observers_; |
164 | 170 |
165 scoped_ptr<ReadErrorDelegate> error_delegate_; | 171 scoped_ptr<ReadErrorDelegate> error_delegate_; |
166 | 172 |
167 bool initialized_; | 173 bool initialized_; |
168 bool filtering_in_progress_; | 174 bool filtering_in_progress_; |
169 bool pending_lossy_write_; | 175 bool pending_lossy_write_; |
170 PrefReadError read_error_; | 176 PrefReadError read_error_; |
171 | 177 |
172 DISALLOW_COPY_AND_ASSIGN(FilesystemJsonPrefStore); | 178 DISALLOW_COPY_AND_ASSIGN(FilesystemJsonPrefStore); |
173 }; | 179 }; |
174 | 180 |
175 } // namespace filesystem | 181 } // namespace filesystem |
176 | 182 |
177 #endif // COMPONENTS_FILESYSTEM_PUBLIC_CPP_PREFS_FILESYSTEM_JSON_PREF_STORE_H_ | 183 #endif // COMPONENTS_FILESYSTEM_PUBLIC_CPP_PREFS_FILESYSTEM_JSON_PREF_STORE_H_ |
OLD | NEW |