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

Side by Side Diff: components/user_prefs/pref_registry_syncable.h

Issue 12033093: sync: Implementation of Priority Preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_USER_PREFS_PREF_REGISTRY_SYNCABLE_H_ 5 #ifndef COMPONENTS_USER_PREFS_PREF_REGISTRY_SYNCABLE_H_
6 #define COMPONENTS_USER_PREFS_PREF_REGISTRY_SYNCABLE_H_ 6 #define COMPONENTS_USER_PREFS_PREF_REGISTRY_SYNCABLE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 12 matching lines...) Expand all
23 // 23 //
24 // Classes or components that want to register such preferences should 24 // Classes or components that want to register such preferences should
25 // define a static function named RegisterUserPrefs that takes a 25 // define a static function named RegisterUserPrefs that takes a
26 // PrefRegistrySyncable*, and the top-level application using the 26 // PrefRegistrySyncable*, and the top-level application using the
27 // class or embedding the component should call this function at an 27 // class or embedding the component should call this function at an
28 // appropriate time before the PrefService for these preferences is 28 // appropriate time before the PrefService for these preferences is
29 // constructed. See e.g. chrome/browser/prefs/browser_prefs.cc which 29 // constructed. See e.g. chrome/browser/prefs/browser_prefs.cc which
30 // does this for Chrome. 30 // does this for Chrome.
31 class USER_PREFS_EXPORT PrefRegistrySyncable : public PrefRegistry { 31 class USER_PREFS_EXPORT PrefRegistrySyncable : public PrefRegistry {
32 public: 32 public:
33 typedef base::Callback<void(const char* path)> SyncableRegistrationCallback;
34
35 // Enum used when registering preferences to determine if it should 33 // Enum used when registering preferences to determine if it should
36 // be synced or not. 34 // be synced or not.
37 enum PrefSyncStatus { 35 enum PrefSyncStatus {
38 UNSYNCABLE_PREF, 36 UNSYNCABLE_PREF,
39 SYNCABLE_PREF 37 SYNCABLE_PREF,
38 SYNCABLE_PRIORITY_PREF,
tim (not reviewing) 2013/03/21 16:36:00 We should explain these here.
albertb 2013/03/21 17:10:33 Done.
40 }; 39 };
41 40
41 typedef
42 base::Callback<void(const char* path, const PrefSyncStatus sync_status)>
43 SyncableRegistrationCallback;
44
42 PrefRegistrySyncable(); 45 PrefRegistrySyncable();
43 46
47 typedef std::map<std::string, PrefSyncStatus> PrefToStatus;
48
44 // Retrieve the set of syncable preferences currently registered. 49 // Retrieve the set of syncable preferences currently registered.
45 const std::set<std::string>& syncable_preferences() const; 50 const PrefToStatus& syncable_preferences() const;
46 51
47 // Exactly one callback can be set for the event of a syncable 52 // Exactly one callback can be set for the event of a syncable
48 // preference being registered. It will be fired after the 53 // preference being registered. It will be fired after the
49 // registration has occurred. 54 // registration has occurred.
50 // 55 //
51 // Calling this method after a callback has already been set will 56 // Calling this method after a callback has already been set will
52 // make the object forget the previous callback and use the new one 57 // make the object forget the previous callback and use the new one
53 // instead. 58 // instead.
54 void SetSyncableRegistrationCallback(const SyncableRegistrationCallback& cb); 59 void SetSyncableRegistrationCallback(const SyncableRegistrationCallback& cb);
55 60
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 private: 109 private:
105 virtual ~PrefRegistrySyncable(); 110 virtual ~PrefRegistrySyncable();
106 111
107 void RegisterSyncablePreference(const char* path, 112 void RegisterSyncablePreference(const char* path,
108 base::Value* default_value, 113 base::Value* default_value,
109 PrefSyncStatus sync_status); 114 PrefSyncStatus sync_status);
110 115
111 SyncableRegistrationCallback callback_; 116 SyncableRegistrationCallback callback_;
112 117
113 // Contains the names of all registered preferences that are syncable. 118 // Contains the names of all registered preferences that are syncable.
114 std::set<std::string> syncable_preferences_; 119 PrefToStatus syncable_preferences_;
115 120
116 DISALLOW_COPY_AND_ASSIGN(PrefRegistrySyncable); 121 DISALLOW_COPY_AND_ASSIGN(PrefRegistrySyncable);
117 }; 122 };
118 123
119 #endif // COMPONENTS_USER_PREFS_PREF_REGISTRY_SYNCABLE_H_ 124 #endif // COMPONENTS_USER_PREFS_PREF_REGISTRY_SYNCABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698