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

Side by Side Diff: components/syncable_prefs/synced_pref_change_registrar.h

Issue 1305213009: Componentize PrefSyncableService and support classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pref_service_syncable
Patch Set: Add missing dependency on //sync:test_support_sync_api for unit tests with gn Created 5 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_ 5 #ifndef COMPONENTS_SYNCABLE_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_
6 #define CHROME_BROWSER_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_ 6 #define COMPONENTS_SYNCABLE_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "chrome/browser/prefs/pref_service_syncable.h" 12 #include "components/syncable_prefs/pref_service_syncable.h"
13 #include "chrome/browser/prefs/synced_pref_observer.h" 13 #include "components/syncable_prefs/synced_pref_observer.h"
14 14
15 // Manages the registration of one or more SyncedPrefObservers on a 15 // Manages the registration of one or more SyncedPrefObservers on a
16 // PrefServiceSyncable. This is modeled after base::PrefChangeRegistrar, and 16 // PrefServiceSyncable. This is modeled after base::PrefChangeRegistrar, and
17 // it should be used whenever it's necessary to determine whether a pref change 17 // it should be used whenever it's necessary to determine whether a pref change
18 // has come from sync or from some other mechanism (managed, UI, external, etc.) 18 // has come from sync or from some other mechanism (managed, UI, external, etc.)
19 class SyncedPrefChangeRegistrar : public SyncedPrefObserver { 19 class SyncedPrefChangeRegistrar : public SyncedPrefObserver {
20 public: 20 public:
21 // Registered callbacks may optionally take a path argument. 21 // Registered callbacks may optionally take a path argument.
22 // The boolean argument indicates whether (true) or not (false) 22 // The boolean argument indicates whether (true) or not (false)
23 // the change was a result of syncing. 23 // the change was a result of syncing.
(...skipping 22 matching lines...) Expand all
46 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override; 46 void OnSyncedPrefChanged(const std::string& path, bool from_sync) override;
47 47
48 typedef std::map<std::string, NamedChangeCallback> ObserverMap; 48 typedef std::map<std::string, NamedChangeCallback> ObserverMap;
49 49
50 PrefServiceSyncable* pref_service_; 50 PrefServiceSyncable* pref_service_;
51 ObserverMap observers_; 51 ObserverMap observers_;
52 52
53 DISALLOW_COPY_AND_ASSIGN(SyncedPrefChangeRegistrar); 53 DISALLOW_COPY_AND_ASSIGN(SyncedPrefChangeRegistrar);
54 }; 54 };
55 55
56 #endif // CHROME_BROWSER_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_ 56 #endif // COMPONENTS_SYNCABLE_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_
OLDNEW
« no previous file with comments | « components/syncable_prefs/pref_service_syncable_unittest.cc ('k') | components/syncable_prefs/synced_pref_change_registrar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698