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

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

Issue 2459823002: [Sync] Rename syncable_prefs to sync_preferences. (Closed)
Patch Set: Created 4 years, 1 month 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_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_H_
6 #define COMPONENTS_SYNCABLE_PREFS_PREF_MODEL_ASSOCIATOR_H_ 6 #define COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "base/threading/non_thread_safe.h" 19 #include "base/threading/non_thread_safe.h"
20 #include "components/sync/model/sync_data.h" 20 #include "components/sync/model/sync_data.h"
21 #include "components/sync/model/syncable_service.h" 21 #include "components/sync/model/syncable_service.h"
22 #include "components/syncable_prefs/synced_pref_observer.h" 22 #include "components/sync_preferences/synced_pref_observer.h"
23 23
24 namespace base { 24 namespace base {
25 class Value; 25 class Value;
26 } 26 }
27 27
28 namespace sync_pb { 28 namespace sync_pb {
29 class PreferenceSpecifics; 29 class PreferenceSpecifics;
30 } 30 }
31 31
32 namespace syncable_prefs { 32 namespace sync_preferences {
33 33
34 class PrefModelAssociatorClient; 34 class PrefModelAssociatorClient;
35 class PrefRegistrySyncable; 35 class PrefRegistrySyncable;
36 class PrefServiceSyncable; 36 class PrefServiceSyncable;
37 37
38 // Contains all preference sync related logic. 38 // Contains all preference sync related logic.
39 // TODO(sync): Merge this into PrefService once we separate the profile 39 // TODO(sync): Merge this into PrefService once we separate the profile
40 // PrefService from the local state PrefService. 40 // PrefService from the local state PrefService.
41 class PrefModelAssociator 41 class PrefModelAssociator : public syncer::SyncableService,
42 : public syncer::SyncableService, 42 public base::NonThreadSafe {
43 public base::NonThreadSafe {
44 public: 43 public:
45 // Constructs a PrefModelAssociator initializing the |client_| and |type_| 44 // Constructs a PrefModelAssociator initializing the |client_| and |type_|
46 // instance variable. The |client| is not owned by this object and the caller 45 // instance variable. The |client| is not owned by this object and the caller
47 // must ensure that it oulives the PrefModelAssociator. 46 // must ensure that it oulives the PrefModelAssociator.
48 PrefModelAssociator(const PrefModelAssociatorClient* client, 47 PrefModelAssociator(const PrefModelAssociatorClient* client,
49 syncer::ModelType type); 48 syncer::ModelType type);
50 ~PrefModelAssociator() override; 49 ~PrefModelAssociator() override;
51 50
52 // See description above field for details. 51 // See description above field for details.
53 bool models_associated() const { return models_associated_; } 52 bool models_associated() const { return models_associated_; }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // with ours and append a new UPDATE SyncChange to |sync_changes|. If 135 // with ours and append a new UPDATE SyncChange to |sync_changes|. If
137 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with 136 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with
138 // the current preference data. 137 // the current preference data.
139 // Note: We do not modify the sync data for preferences that are either 138 // Note: We do not modify the sync data for preferences that are either
140 // controlled by policy (are not user modifiable) or have their default value 139 // controlled by policy (are not user modifiable) or have their default value
141 // (are not user controlled). 140 // (are not user controlled).
142 void InitPrefAndAssociate(const syncer::SyncData& sync_pref, 141 void InitPrefAndAssociate(const syncer::SyncData& sync_pref,
143 const std::string& pref_name, 142 const std::string& pref_name,
144 syncer::SyncChangeList* sync_changes); 143 syncer::SyncChangeList* sync_changes);
145 144
146 static base::Value* MergeListValues( 145 static base::Value* MergeListValues(const base::Value& from_value,
147 const base::Value& from_value, const base::Value& to_value); 146 const base::Value& to_value);
148 static base::Value* MergeDictionaryValues(const base::Value& from_value, 147 static base::Value* MergeDictionaryValues(const base::Value& from_value,
149 const base::Value& to_value); 148 const base::Value& to_value);
150 149
151 // Do we have an active association between the preferences and sync models? 150 // Do we have an active association between the preferences and sync models?
152 // Set when start syncing, reset in StopSyncing. While this is not set, we 151 // Set when start syncing, reset in StopSyncing. While this is not set, we
153 // ignore any local preference changes (when we start syncing we will look 152 // ignore any local preference changes (when we start syncing we will look
154 // up the most recent values anyways). 153 // up the most recent values anyways).
155 bool models_associated_; 154 bool models_associated_;
156 155
157 // Whether we're currently processing changes from the syncer. While this is 156 // Whether we're currently processing changes from the syncer. While this is
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const; 196 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const;
198 197
199 SyncedPrefObserverMap synced_pref_observers_; 198 SyncedPrefObserverMap synced_pref_observers_;
200 const PrefModelAssociatorClient* client_; // Weak. 199 const PrefModelAssociatorClient* client_; // Weak.
201 200
202 std::vector<base::Closure> callback_list_; 201 std::vector<base::Closure> callback_list_;
203 202
204 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); 203 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator);
205 }; 204 };
206 205
207 } // namespace syncable_prefs 206 } // namespace sync_preferences
208 207
209 #endif // COMPONENTS_SYNCABLE_PREFS_PREF_MODEL_ASSOCIATOR_H_ 208 #endif // COMPONENTS_SYNC_PREFERENCES_PREF_MODEL_ASSOCIATOR_H_
OLDNEW
« no previous file with comments | « components/sync_preferences/OWNERS ('k') | components/sync_preferences/pref_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698