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

Side by Side Diff: chrome/browser/prefs/pref_model_associator.h

Issue 10698014: [Sync] Rename csync namespace to syncer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 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 | 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 CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_
6 #define CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ 6 #define CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 namespace base { 24 namespace base {
25 class Value; 25 class Value;
26 } 26 }
27 27
28 // Contains all preference sync related logic. 28 // Contains all preference sync related logic.
29 // TODO(sync): Merge this into PrefService once we separate the profile 29 // TODO(sync): Merge this into PrefService once we separate the profile
30 // PrefService from the local state PrefService. 30 // PrefService from the local state PrefService.
31 class PrefModelAssociator 31 class PrefModelAssociator
32 : public csync::SyncableService, 32 : public syncer::SyncableService,
33 public base::NonThreadSafe { 33 public base::NonThreadSafe {
34 public: 34 public:
35 PrefModelAssociator(); 35 PrefModelAssociator();
36 virtual ~PrefModelAssociator(); 36 virtual ~PrefModelAssociator();
37 37
38 // csync::SyncableService implementation. 38 // syncer::SyncableService implementation.
39 virtual csync::SyncDataList GetAllSyncData( 39 virtual syncer::SyncDataList GetAllSyncData(
40 syncable::ModelType type) const OVERRIDE; 40 syncable::ModelType type) const OVERRIDE;
41 virtual csync::SyncError ProcessSyncChanges( 41 virtual syncer::SyncError ProcessSyncChanges(
42 const tracked_objects::Location& from_here, 42 const tracked_objects::Location& from_here,
43 const csync::SyncChangeList& change_list) OVERRIDE; 43 const syncer::SyncChangeList& change_list) OVERRIDE;
44 virtual csync::SyncError MergeDataAndStartSyncing( 44 virtual syncer::SyncError MergeDataAndStartSyncing(
45 syncable::ModelType type, 45 syncable::ModelType type,
46 const csync::SyncDataList& initial_sync_data, 46 const syncer::SyncDataList& initial_sync_data,
47 scoped_ptr<csync::SyncChangeProcessor> sync_processor, 47 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
48 scoped_ptr<csync::SyncErrorFactory> sync_error_factory) OVERRIDE; 48 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) OVERRIDE;
49 virtual void StopSyncing(syncable::ModelType type) OVERRIDE; 49 virtual void StopSyncing(syncable::ModelType type) OVERRIDE;
50 50
51 // Returns the list of preference names that are registered as syncable, and 51 // Returns the list of preference names that are registered as syncable, and
52 // hence should be monitored for changes. 52 // hence should be monitored for changes.
53 std::set<std::string> registered_preferences() const; 53 std::set<std::string> registered_preferences() const;
54 54
55 // Register a preference with the specified name for syncing. We do not care 55 // Register a preference with the specified name for syncing. We do not care
56 // about the type at registration time, but when changes arrive from the 56 // about the type at registration time, but when changes arrive from the
57 // syncer, we check if they can be applied and if not drop them. 57 // syncer, we check if they can be applied and if not drop them.
58 // Note: This should only be called at profile startup time (before sync 58 // Note: This should only be called at profile startup time (before sync
(...skipping 19 matching lines...) Expand all
78 // actually be merged, all others will return a copy of the server value. See 78 // actually be merged, all others will return a copy of the server value. See
79 // the method's implementation for details. 79 // the method's implementation for details.
80 static base::Value* MergePreference( 80 static base::Value* MergePreference(
81 const PrefService::Preference& local_pref, 81 const PrefService::Preference& local_pref,
82 const base::Value& server_value); 82 const base::Value& server_value);
83 83
84 // Fills |sync_data| with a sync representation of the preference data 84 // Fills |sync_data| with a sync representation of the preference data
85 // provided. 85 // provided.
86 static bool CreatePrefSyncData(const std::string& name, 86 static bool CreatePrefSyncData(const std::string& name,
87 const base::Value& value, 87 const base::Value& value,
88 csync::SyncData* sync_data); 88 syncer::SyncData* sync_data);
89 89
90 // Extract preference value and name from sync specifics. 90 // Extract preference value and name from sync specifics.
91 base::Value* ReadPreferenceSpecifics( 91 base::Value* ReadPreferenceSpecifics(
92 const sync_pb::PreferenceSpecifics& specifics, 92 const sync_pb::PreferenceSpecifics& specifics,
93 std::string* name); 93 std::string* name);
94 94
95 protected: 95 protected:
96 friend class ProfileSyncServicePreferenceTest; 96 friend class ProfileSyncServicePreferenceTest;
97 97
98 typedef std::map<std::string, csync::SyncData> SyncDataMap; 98 typedef std::map<std::string, syncer::SyncData> SyncDataMap;
99 99
100 // Create an association for a given preference. If |sync_pref| is valid, 100 // Create an association for a given preference. If |sync_pref| is valid,
101 // signifying that sync has data for this preference, we reconcile their data 101 // signifying that sync has data for this preference, we reconcile their data
102 // with ours and append a new UPDATE SyncChange to |sync_changes|. If 102 // with ours and append a new UPDATE SyncChange to |sync_changes|. If
103 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with 103 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with
104 // the current preference data. 104 // the current preference data.
105 // Note: We do not modify the sync data for preferences that are either 105 // Note: We do not modify the sync data for preferences that are either
106 // controlled by policy (are not user modifiable) or have their default value 106 // controlled by policy (are not user modifiable) or have their default value
107 // (are not user controlled). 107 // (are not user controlled).
108 void InitPrefAndAssociate(const csync::SyncData& sync_pref, 108 void InitPrefAndAssociate(const syncer::SyncData& sync_pref,
109 const std::string& pref_name, 109 const std::string& pref_name,
110 csync::SyncChangeList* sync_changes); 110 syncer::SyncChangeList* sync_changes);
111 111
112 static base::Value* MergeListValues( 112 static base::Value* MergeListValues(
113 const base::Value& from_value, const base::Value& to_value); 113 const base::Value& from_value, const base::Value& to_value);
114 static base::Value* MergeDictionaryValues(const base::Value& from_value, 114 static base::Value* MergeDictionaryValues(const base::Value& from_value,
115 const base::Value& to_value); 115 const base::Value& to_value);
116 116
117 // Do we have an active association between the preferences and sync models? 117 // Do we have an active association between the preferences and sync models?
118 // Set when start syncing, reset in StopSyncing. While this is not set, we 118 // Set when start syncing, reset in StopSyncing. While this is not set, we
119 // ignore any local preference changes (when we start syncing we will look 119 // ignore any local preference changes (when we start syncing we will look
120 // up the most recent values anyways). 120 // up the most recent values anyways).
(...skipping 14 matching lines...) Expand all
135 // policy controlled). 135 // policy controlled).
136 // Note: this set never decreases, only grows to eventually match 136 // Note: this set never decreases, only grows to eventually match
137 // registered_preferences_ as more preferences are synced. It determines 137 // registered_preferences_ as more preferences are synced. It determines
138 // whether a preference change should update an existing sync node or create 138 // whether a preference change should update an existing sync node or create
139 // a new sync node. 139 // a new sync node.
140 PreferenceSet synced_preferences_; 140 PreferenceSet synced_preferences_;
141 141
142 // The PrefService we are syncing to. 142 // The PrefService we are syncing to.
143 PrefService* pref_service_; 143 PrefService* pref_service_;
144 144
145 // Sync's csync::SyncChange handler. We push all our changes through this. 145 // Sync's syncer::SyncChange handler. We push all our changes through this.
146 scoped_ptr<csync::SyncChangeProcessor> sync_processor_; 146 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
147 147
148 // Sync's error handler. We use this to create sync errors. 148 // Sync's error handler. We use this to create sync errors.
149 scoped_ptr<csync::SyncErrorFactory> sync_error_factory_; 149 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory_;
150 150
151 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); 151 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator);
152 }; 152 };
153 153
154 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ 154 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/test_extension_service.cc ('k') | chrome/browser/prefs/pref_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698