Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: base/prefs/persistent_pref_store.h

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/prefs/overlay_user_pref_store_unittest.cc ('k') | base/prefs/pref_change_registrar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 BASE_PREFS_PERSISTENT_PREF_STORE_H_
6 #define BASE_PREFS_PERSISTENT_PREF_STORE_H_
7
8 #include <string>
9
10 #include "base/prefs/base_prefs_export.h"
11 #include "base/prefs/writeable_pref_store.h"
12
13 // This interface is complementary to the PrefStore interface, declaring
14 // additional functionality that adds support for setting values and persisting
15 // the data to some backing store.
16 class BASE_PREFS_EXPORT PersistentPrefStore : public WriteablePrefStore {
17 public:
18 // Unique integer code for each type of error so we can report them
19 // distinctly in a histogram.
20 // NOTE: Don't change the explicit values of the enums as it will change the
21 // server's meaning of the histogram.
22 enum PrefReadError {
23 PREF_READ_ERROR_NONE = 0,
24 PREF_READ_ERROR_JSON_PARSE = 1,
25 PREF_READ_ERROR_JSON_TYPE = 2,
26 PREF_READ_ERROR_ACCESS_DENIED = 3,
27 PREF_READ_ERROR_FILE_OTHER = 4,
28 PREF_READ_ERROR_FILE_LOCKED = 5,
29 PREF_READ_ERROR_NO_FILE = 6,
30 PREF_READ_ERROR_JSON_REPEAT = 7,
31 // PREF_READ_ERROR_OTHER = 8, // Deprecated.
32 PREF_READ_ERROR_FILE_NOT_SPECIFIED = 9,
33 // Indicates that ReadPrefs() couldn't complete synchronously and is waiting
34 // for an asynchronous task to complete first.
35 PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE = 10,
36 PREF_READ_ERROR_LEVELDB_IO = 11,
37 PREF_READ_ERROR_LEVELDB_CORRUPTION_READ_ONLY = 12,
38 PREF_READ_ERROR_LEVELDB_CORRUPTION = 13,
39 PREF_READ_ERROR_MAX_ENUM
40 };
41
42 class ReadErrorDelegate {
43 public:
44 virtual ~ReadErrorDelegate() {}
45
46 virtual void OnError(PrefReadError error) = 0;
47 };
48
49 // Whether the store is in a pseudo-read-only mode where changes are not
50 // actually persisted to disk. This happens in some cases when there are
51 // read errors during startup.
52 virtual bool ReadOnly() const = 0;
53
54 // Gets the read error. Only valid if IsInitializationComplete() returns true.
55 virtual PrefReadError GetReadError() const = 0;
56
57 // Reads the preferences from disk. Notifies observers via
58 // "PrefStore::OnInitializationCompleted" when done.
59 virtual PrefReadError ReadPrefs() = 0;
60
61 // Reads the preferences from disk asynchronously. Notifies observers via
62 // "PrefStore::OnInitializationCompleted" when done. Also it fires
63 // |error_delegate| if it is not NULL and reading error has occurred.
64 // Owns |error_delegate|.
65 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) = 0;
66
67 // Lands any pending writes to disk.
68 virtual void CommitPendingWrite() = 0;
69
70 // Schedule a write if there is any lossy data pending. Unlike
71 // CommitPendingWrite() this does not immediately sync to disk, instead it
72 // triggers an eventual write if there is lossy data pending and if there
73 // isn't one scheduled already.
74 virtual void SchedulePendingLossyWrites() = 0;
75
76 protected:
77 ~PersistentPrefStore() override {}
78 };
79
80 #endif // BASE_PREFS_PERSISTENT_PREF_STORE_H_
OLDNEW
« no previous file with comments | « base/prefs/overlay_user_pref_store_unittest.cc ('k') | base/prefs/pref_change_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698