| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_JSON_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_JSON_PREF_STORE_H_ |
| 6 #define CHROME_BROWSER_JSON_PREF_STORE_H_ | 6 #define CHROME_BROWSER_JSON_PREF_STORE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/browser/important_file_writer.h" | 11 #include "chrome/browser/important_file_writer.h" |
| 12 #include "chrome/browser/pref_store.h" | 12 #include "chrome/browser/pref_store.h" |
| 13 | 13 |
| 14 class DictionaryValue; | 14 class DictionaryValue; |
| 15 class FilePath; | 15 class FilePath; |
| 16 | 16 |
| 17 class JsonPrefStore : public PrefStore, | 17 class JsonPrefStore : public PrefStore, |
| 18 public ImportantFileWriter::DataSerializer { | 18 public ImportantFileWriter::DataSerializer { |
| 19 public: | 19 public: |
| 20 explicit JsonPrefStore(const FilePath& pref_filename); | 20 explicit JsonPrefStore(const FilePath& pref_filename); |
| 21 virtual ~JsonPrefStore(); | 21 virtual ~JsonPrefStore(); |
| 22 | 22 |
| 23 // PrefStore methods: | 23 // PrefStore methods: |
| 24 virtual bool ReadOnly() { return read_only_; } | 24 virtual bool ReadOnly() { return read_only_; } |
| 25 | 25 |
| 26 virtual DictionaryValue* Prefs() { return prefs_.get(); } | 26 virtual DictionaryValue* prefs() { return prefs_.get(); } |
| 27 | 27 |
| 28 virtual PrefReadError ReadPrefs(); | 28 virtual PrefReadError ReadPrefs(); |
| 29 | 29 |
| 30 virtual bool WritePrefs(); | 30 virtual bool WritePrefs(); |
| 31 | 31 |
| 32 virtual void ScheduleWritePrefs(); | 32 virtual void ScheduleWritePrefs(); |
| 33 | 33 |
| 34 // ImportantFileWriter::DataSerializer methods: | 34 // ImportantFileWriter::DataSerializer methods: |
| 35 virtual bool SerializeData(std::string* data); | 35 virtual bool SerializeData(std::string* data); |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 FilePath path_; | 38 FilePath path_; |
| 39 | 39 |
| 40 scoped_ptr<DictionaryValue> prefs_; | 40 scoped_ptr<DictionaryValue> prefs_; |
| 41 | 41 |
| 42 bool read_only_; | 42 bool read_only_; |
| 43 | 43 |
| 44 // Helper for safely writing pref data. | 44 // Helper for safely writing pref data. |
| 45 ImportantFileWriter writer_; | 45 ImportantFileWriter writer_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 #endif // CHROME_BROWSER_JSON_PREF_STORE_H_ | 48 #endif // CHROME_BROWSER_JSON_PREF_STORE_H_ |
| OLD | NEW |