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

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

Issue 2078893002: Add callback list to PrefModelAssociator after sync data is loaded (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@migrate_domain_scoped_settings
Patch Set: Created 4 years, 5 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 (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_SYNCABLE_PREFS_PREF_MODEL_ASSOCIATOR_H_ 5 #ifndef COMPONENTS_SYNCABLE_PREFS_PREF_MODEL_ASSOCIATOR_H_
6 #define COMPONENTS_SYNCABLE_PREFS_PREF_MODEL_ASSOCIATOR_H_ 6 #define COMPONENTS_SYNCABLE_PREFS_PREF_MODEL_ASSOCIATOR_H_
7 7
8 #include <list>
8 #include <map> 9 #include <map>
9 #include <memory> 10 #include <memory>
10 #include <set> 11 #include <set>
11 #include <string> 12 #include <string>
12 13
14 #include "base/callback.h"
13 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
14 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
15 #include "base/macros.h" 17 #include "base/macros.h"
16 #include "base/observer_list.h" 18 #include "base/observer_list.h"
17 #include "base/threading/non_thread_safe.h" 19 #include "base/threading/non_thread_safe.h"
18 #include "components/syncable_prefs/synced_pref_observer.h" 20 #include "components/syncable_prefs/synced_pref_observer.h"
19 #include "sync/api/sync_data.h" 21 #include "sync/api/sync_data.h"
20 #include "sync/api/syncable_service.h" 22 #include "sync/api/syncable_service.h"
21 23
22 namespace base { 24 namespace base {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 void RemoveSyncedPrefObserver(const std::string& name, 115 void RemoveSyncedPrefObserver(const std::string& name,
114 SyncedPrefObserver* observer); 116 SyncedPrefObserver* observer);
115 117
116 // Returns the PrefModelAssociatorClient for this object. 118 // Returns the PrefModelAssociatorClient for this object.
117 const PrefModelAssociatorClient* client() const { return client_; } 119 const PrefModelAssociatorClient* client() const { return client_; }
118 120
119 // Set the PrefModelAssociatorClient to use for that object during tests. 121 // Set the PrefModelAssociatorClient to use for that object during tests.
120 void SetPrefModelAssociatorClientForTesting( 122 void SetPrefModelAssociatorClientForTesting(
121 const PrefModelAssociatorClient* client); 123 const PrefModelAssociatorClient* client);
122 124
125 // Register callback method which will get called at the end of
126 // PrefModelAssociator::MergeDataAndStartSyncing().
127 void RegisterMergeDataFinishedCallback(const base::Closure& callback);
128
123 protected: 129 protected:
124 friend class PrefServiceSyncableTest; 130 friend class PrefServiceSyncableTest;
125 131
126 typedef std::map<std::string, syncer::SyncData> SyncDataMap; 132 typedef std::map<std::string, syncer::SyncData> SyncDataMap;
127 133
128 // Create an association for a given preference. If |sync_pref| is valid, 134 // Create an association for a given preference. If |sync_pref| is valid,
129 // signifying that sync has data for this preference, we reconcile their data 135 // signifying that sync has data for this preference, we reconcile their data
130 // with ours and append a new UPDATE SyncChange to |sync_changes|. If 136 // with ours and append a new UPDATE SyncChange to |sync_changes|. If
131 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with 137 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with
132 // the current preference data. 138 // the current preference data.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // from sync. 192 // from sync.
187 typedef base::ObserverList<SyncedPrefObserver> SyncedPrefObserverList; 193 typedef base::ObserverList<SyncedPrefObserver> SyncedPrefObserverList;
188 typedef base::hash_map<std::string, SyncedPrefObserverList*> 194 typedef base::hash_map<std::string, SyncedPrefObserverList*>
189 SyncedPrefObserverMap; 195 SyncedPrefObserverMap;
190 196
191 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const; 197 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const;
192 198
193 SyncedPrefObserverMap synced_pref_observers_; 199 SyncedPrefObserverMap synced_pref_observers_;
194 const PrefModelAssociatorClient* client_; // Weak. 200 const PrefModelAssociatorClient* client_; // Weak.
195 201
202 std::list<base::Closure> callback_list_;
raymes 2016/06/29 03:50:01 std::vector is usually preferable
lshang 2016/06/30 05:03:36 Done.
203
196 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); 204 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator);
197 }; 205 };
198 206
199 } // namespace syncable_prefs 207 } // namespace syncable_prefs
200 208
201 #endif // COMPONENTS_SYNCABLE_PREFS_PREF_MODEL_ASSOCIATOR_H_ 209 #endif // COMPONENTS_SYNCABLE_PREFS_PREF_MODEL_ASSOCIATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698