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

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: fix tests Created 7 years, 8 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/pref_names.cc ('k') | components/user_prefs/pref_registry_syncable.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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. Syncable priority preferences are preferences that are
35 // never encrypted and are synced before other datatypes. Because they're
36 // never encrypted, on first sync, they can be synced down before the user
37 // is prompted for a passphrase.
37 enum PrefSyncStatus { 38 enum PrefSyncStatus {
38 UNSYNCABLE_PREF, 39 UNSYNCABLE_PREF,
39 SYNCABLE_PREF 40 SYNCABLE_PREF,
41 SYNCABLE_PRIORITY_PREF,
40 }; 42 };
41 43
44 typedef
45 base::Callback<void(const char* path, const PrefSyncStatus sync_status)>
46 SyncableRegistrationCallback;
47
42 PrefRegistrySyncable(); 48 PrefRegistrySyncable();
43 49
50 typedef std::map<std::string, PrefSyncStatus> PrefToStatus;
51
44 // Retrieve the set of syncable preferences currently registered. 52 // Retrieve the set of syncable preferences currently registered.
45 const std::set<std::string>& syncable_preferences() const; 53 const PrefToStatus& syncable_preferences() const;
46 54
47 // Exactly one callback can be set for the event of a syncable 55 // Exactly one callback can be set for the event of a syncable
48 // preference being registered. It will be fired after the 56 // preference being registered. It will be fired after the
49 // registration has occurred. 57 // registration has occurred.
50 // 58 //
51 // Calling this method after a callback has already been set will 59 // Calling this method after a callback has already been set will
52 // make the object forget the previous callback and use the new one 60 // make the object forget the previous callback and use the new one
53 // instead. 61 // instead.
54 void SetSyncableRegistrationCallback(const SyncableRegistrationCallback& cb); 62 void SetSyncableRegistrationCallback(const SyncableRegistrationCallback& cb);
55 63
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 private: 112 private:
105 virtual ~PrefRegistrySyncable(); 113 virtual ~PrefRegistrySyncable();
106 114
107 void RegisterSyncablePreference(const char* path, 115 void RegisterSyncablePreference(const char* path,
108 base::Value* default_value, 116 base::Value* default_value,
109 PrefSyncStatus sync_status); 117 PrefSyncStatus sync_status);
110 118
111 SyncableRegistrationCallback callback_; 119 SyncableRegistrationCallback callback_;
112 120
113 // Contains the names of all registered preferences that are syncable. 121 // Contains the names of all registered preferences that are syncable.
114 std::set<std::string> syncable_preferences_; 122 PrefToStatus syncable_preferences_;
115 123
116 DISALLOW_COPY_AND_ASSIGN(PrefRegistrySyncable); 124 DISALLOW_COPY_AND_ASSIGN(PrefRegistrySyncable);
117 }; 125 };
118 126
119 #endif // COMPONENTS_USER_PREFS_PREF_REGISTRY_SYNCABLE_H_ 127 #endif // COMPONENTS_USER_PREFS_PREF_REGISTRY_SYNCABLE_H_
OLDNEW
« no previous file with comments | « chrome/common/pref_names.cc ('k') | components/user_prefs/pref_registry_syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698