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

Side by Side Diff: chrome/common/pref_store.h

Issue 11243002: Move the bits of Prefs where production code has only trivially easy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments, fix gypi problem Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/persistent_pref_store.h ('k') | chrome/common/pref_store.cc » ('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 CHROME_COMMON_PREF_STORE_H_
6 #define CHROME_COMMON_PREF_STORE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12
13 namespace base {
14 class Value;
15 }
16
17 // This is an abstract interface for reading and writing from/to a persistent
18 // preference store, used by PrefService. An implementation using a JSON file
19 // can be found in JsonPrefStore, while an implementation without any backing
20 // store for testing can be found in TestingPrefStore. Furthermore, there is
21 // CommandLinePrefStore, which bridges command line options to preferences and
22 // ConfigurationPolicyPrefStore, which is used for hooking up configuration
23 // policy with the preference subsystem.
24 class PrefStore : public base::RefCounted<PrefStore> {
25 public:
26 // Observer interface for monitoring PrefStore.
27 class Observer {
28 public:
29 // Called when the value for the given |key| in the store changes.
30 virtual void OnPrefValueChanged(const std::string& key) = 0;
31 // Notification about the PrefStore being fully initialized.
32 virtual void OnInitializationCompleted(bool succeeded) = 0;
33
34 protected:
35 virtual ~Observer() {}
36 };
37
38 // Return values for GetValue().
39 enum ReadResult {
40 // Value found and returned.
41 READ_OK,
42 // No value present, but skip other pref stores and use default.
43 READ_USE_DEFAULT,
44 // No value present.
45 READ_NO_VALUE,
46 };
47
48 PrefStore() {}
49
50 // Add and remove observers.
51 virtual void AddObserver(Observer* observer) {}
52 virtual void RemoveObserver(Observer* observer) {}
53 virtual size_t NumberOfObservers() const;
54
55 // Whether the store has completed all asynchronous initialization.
56 virtual bool IsInitializationComplete() const;
57
58 // Get the value for a given preference |key| and stores it in |*result|.
59 // |*result| is only modified if the return value is READ_OK and if |result|
60 // is not NULL. Ownership of the |*result| value remains with the PrefStore.
61 virtual ReadResult GetValue(const std::string& key,
62 const base::Value** result) const = 0;
63
64 protected:
65 friend class base::RefCounted<PrefStore>;
66 virtual ~PrefStore() {}
67
68 private:
69 DISALLOW_COPY_AND_ASSIGN(PrefStore);
70 };
71
72 #endif // CHROME_COMMON_PREF_STORE_H_
OLDNEW
« no previous file with comments | « chrome/common/persistent_pref_store.h ('k') | chrome/common/pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698