blob: 70f5dee1e4751c9d4c2d04dce989519b37cb7715 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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_
|