diff options
author | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-21 15:01:35 +0000 |
---|---|---|
committer | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-21 15:01:35 +0000 |
commit | ea587b01337fd38626923e48258a2b39a631543a (patch) | |
tree | 944b56193e7870f97877836e490556b0983f5b0a /chrome/common/json_pref_store.h | |
parent | 893934384f65e8676d226396c34625880a46436a (diff) | |
download | chromium_src-ea587b01337fd38626923e48258a2b39a631543a.zip chromium_src-ea587b01337fd38626923e48258a2b39a631543a.tar.gz chromium_src-ea587b01337fd38626923e48258a2b39a631543a.tar.bz2 |
Removed dependency on ChromeThread from JsonPrefStore and moved JsonPrefStore and PrefStore to chrome/common. This is because JsonPrefStore is needed in the service process
BUG=None.
TEST=Updated unit-tests
Review URL: http://codereview.chromium.org/2066015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47915 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/json_pref_store.h')
-rw-r--r-- | chrome/common/json_pref_store.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/common/json_pref_store.h b/chrome/common/json_pref_store.h new file mode 100644 index 0000000..70f5dee --- /dev/null +++ b/chrome/common/json_pref_store.h @@ -0,0 +1,56 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_JSON_PREF_STORE_H_ +#define CHROME_COMMON_JSON_PREF_STORE_H_ + +#include <string> + +#include "base/scoped_ptr.h" +#include "chrome/common/pref_store.h" +#include "chrome/common/important_file_writer.h" + +namespace base { +class MessageLoopProxy; +} + +class DictionaryValue; +class FilePath; + +class JsonPrefStore : public PrefStore, + public ImportantFileWriter::DataSerializer { + public: + // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which + // file I/O can be done. + JsonPrefStore(const FilePath& pref_filename, + base::MessageLoopProxy* file_message_loop_proxy); + virtual ~JsonPrefStore(); + + // PrefStore methods: + virtual bool ReadOnly() { return read_only_; } + + virtual DictionaryValue* prefs() { return prefs_.get(); } + + virtual PrefReadError ReadPrefs(); + + virtual bool WritePrefs(); + + virtual void ScheduleWritePrefs(); + + // ImportantFileWriter::DataSerializer methods: + virtual bool SerializeData(std::string* data); + + private: + FilePath path_; + + scoped_ptr<DictionaryValue> prefs_; + + bool read_only_; + + // Helper for safely writing pref data. + ImportantFileWriter writer_; +}; + +#endif // CHROME_COMMON_JSON_PREF_STORE_H_ + |