blob: d7cf8adc7ca3f36ba483e43b96158025daf8eafd [file] [log] [blame]
[email protected]ac4df1d2010-04-21 08:49:531// 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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_PREF_STORE_H_
6#define CHROME_BROWSER_PREF_STORE_H_
7
8class DictionaryValue;
9
10// This is an abstract interface for reading and writing from/to a persistent
11// preference store, used by |PrefService|. An implementation using a JSON file
12// can be found in |JsonPrefStore|, while an implementation without any backing
13// store (currently used for testing) can be found in |DummyPrefStore|.
14class PrefStore {
15 public:
16 // Unique integer code for each type of error so we can report them
17 // distinctly in a histogram.
18 // NOTE: Don't change the order here as it will change the server's meaning
19 // of the histogram.
20 enum PrefReadError {
21 PREF_READ_ERROR_NONE = 0,
22 PREF_READ_ERROR_JSON_PARSE,
23 PREF_READ_ERROR_JSON_TYPE,
24 PREF_READ_ERROR_ACCESS_DENIED,
25 PREF_READ_ERROR_FILE_OTHER,
26 PREF_READ_ERROR_FILE_LOCKED,
27 PREF_READ_ERROR_NO_FILE,
28 };
29
30 virtual ~PrefStore() { }
31
32 // Whether the store is in a pseudo-read-only mode where changes are not
33 // actually persisted to disk. This happens in some cases when there are
34 // read errors during startup.
35 virtual bool ReadOnly() { return true; }
36
37 virtual DictionaryValue* Prefs() = 0;
38
39 virtual PrefReadError ReadPrefs() = 0;
40
41 virtual bool WritePrefs() { return true; }
42
43 virtual void ScheduleWritePrefs() { }
44};
45
46#endif // CHROME_BROWSER_PREF_STORE_H_