blob: d5acd89943da17f7686dcd0131a3db95e11fa0ed [file] [log] [blame]
[email protected]277404c22010-04-22 13:09:451// 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
[email protected]ea587b02010-05-21 15:01:355#ifndef CHROME_COMMON_PREF_STORE_H_
6#define CHROME_COMMON_PREF_STORE_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]277404c22010-04-22 13:09:458
9class DictionaryValue;
10
11// This is an abstract interface for reading and writing from/to a persistent
12// preference store, used by |PrefService|. An implementation using a JSON file
13// can be found in |JsonPrefStore|, while an implementation without any backing
14// store (currently used for testing) can be found in |DummyPrefStore|.
15class PrefStore {
16 public:
17 // Unique integer code for each type of error so we can report them
18 // distinctly in a histogram.
19 // NOTE: Don't change the order here as it will change the server's meaning
20 // of the histogram.
21 enum PrefReadError {
22 PREF_READ_ERROR_NONE = 0,
23 PREF_READ_ERROR_JSON_PARSE,
24 PREF_READ_ERROR_JSON_TYPE,
25 PREF_READ_ERROR_ACCESS_DENIED,
26 PREF_READ_ERROR_FILE_OTHER,
27 PREF_READ_ERROR_FILE_LOCKED,
28 PREF_READ_ERROR_NO_FILE,
29 PREF_READ_ERROR_JSON_REPEAT,
[email protected]c0858b02010-05-12 15:03:3230 PREF_READ_ERROR_OTHER
[email protected]277404c22010-04-22 13:09:4531 };
32
33 virtual ~PrefStore() { }
34
35 // Whether the store is in a pseudo-read-only mode where changes are not
36 // actually persisted to disk. This happens in some cases when there are
37 // read errors during startup.
38 virtual bool ReadOnly() { return true; }
39
[email protected]c0858b02010-05-12 15:03:3240 virtual DictionaryValue* prefs() = 0;
[email protected]277404c22010-04-22 13:09:4541
42 virtual PrefReadError ReadPrefs() = 0;
43
44 virtual bool WritePrefs() { return true; }
45
46 virtual void ScheduleWritePrefs() { }
47};
48
[email protected]ea587b02010-05-21 15:01:3549#endif // CHROME_COMMON_PREF_STORE_H_
50