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

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

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights 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 #include "chrome/browser/prefs/pref_model_associator.h" 5 #include "chrome/browser/prefs/pref_model_associator.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "sync/api/sync_change.h" 16 #include "sync/api/sync_change.h"
17 #include "sync/api/sync_error_factory.h" 17 #include "sync/api/sync_error_factory.h"
18 #include "sync/protocol/preference_specifics.pb.h" 18 #include "sync/protocol/preference_specifics.pb.h"
19 #include "sync/protocol/sync.pb.h" 19 #include "sync/protocol/sync.pb.h"
20 20
21 using syncable::PREFERENCES; 21 using syncer::PREFERENCES;
22 22
23 PrefModelAssociator::PrefModelAssociator() 23 PrefModelAssociator::PrefModelAssociator()
24 : models_associated_(false), 24 : models_associated_(false),
25 processing_syncer_changes_(false), 25 processing_syncer_changes_(false),
26 pref_service_(NULL) { 26 pref_service_(NULL) {
27 DCHECK(CalledOnValidThread()); 27 DCHECK(CalledOnValidThread());
28 } 28 }
29 29
30 PrefModelAssociator::~PrefModelAssociator() { 30 PrefModelAssociator::~PrefModelAssociator() {
31 DCHECK(CalledOnValidThread()); 31 DCHECK(CalledOnValidThread());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 return; 100 return;
101 } 101 }
102 102
103 // Make sure we add it to our list of synced preferences so we know what 103 // Make sure we add it to our list of synced preferences so we know what
104 // the server is aware of. 104 // the server is aware of.
105 synced_preferences_.insert(pref_name); 105 synced_preferences_.insert(pref_name);
106 return; 106 return;
107 } 107 }
108 108
109 syncer::SyncError PrefModelAssociator::MergeDataAndStartSyncing( 109 syncer::SyncError PrefModelAssociator::MergeDataAndStartSyncing(
110 syncable::ModelType type, 110 syncer::ModelType type,
111 const syncer::SyncDataList& initial_sync_data, 111 const syncer::SyncDataList& initial_sync_data,
112 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 112 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
113 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { 113 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) {
114 DCHECK_EQ(type, PREFERENCES); 114 DCHECK_EQ(type, PREFERENCES);
115 DCHECK(CalledOnValidThread()); 115 DCHECK(CalledOnValidThread());
116 DCHECK(pref_service_); 116 DCHECK(pref_service_);
117 DCHECK(!sync_processor_.get()); 117 DCHECK(!sync_processor_.get());
118 DCHECK(sync_processor.get()); 118 DCHECK(sync_processor.get());
119 DCHECK(sync_error_factory.get()); 119 DCHECK(sync_error_factory.get());
120 sync_processor_ = sync_processor.Pass(); 120 sync_processor_ = sync_processor.Pass();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 syncer::SyncError error = 156 syncer::SyncError error =
157 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); 157 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
158 if (error.IsSet()) { 158 if (error.IsSet()) {
159 return error; 159 return error;
160 } 160 }
161 161
162 models_associated_ = true; 162 models_associated_ = true;
163 return syncer::SyncError(); 163 return syncer::SyncError();
164 } 164 }
165 165
166 void PrefModelAssociator::StopSyncing(syncable::ModelType type) { 166 void PrefModelAssociator::StopSyncing(syncer::ModelType type) {
167 DCHECK_EQ(type, PREFERENCES); 167 DCHECK_EQ(type, PREFERENCES);
168 models_associated_ = false; 168 models_associated_ = false;
169 sync_processor_.reset(); 169 sync_processor_.reset();
170 sync_error_factory_.reset(); 170 sync_error_factory_.reset();
171 } 171 }
172 172
173 Value* PrefModelAssociator::MergePreference( 173 Value* PrefModelAssociator::MergePreference(
174 const PrefService::Preference& local_pref, 174 const PrefService::Preference& local_pref,
175 const Value& server_value) { 175 const Value& server_value) {
176 const std::string& name(local_pref.name()); 176 const std::string& name(local_pref.name());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 } 268 }
269 return result; 269 return result;
270 } 270 }
271 271
272 // Note: This will build a model of all preferences registered as syncable 272 // Note: This will build a model of all preferences registered as syncable
273 // with user controlled data. We do not track any information for preferences 273 // with user controlled data. We do not track any information for preferences
274 // not registered locally as syncable and do not inform the syncer of 274 // not registered locally as syncable and do not inform the syncer of
275 // non-user controlled preferences. 275 // non-user controlled preferences.
276 syncer::SyncDataList PrefModelAssociator::GetAllSyncData( 276 syncer::SyncDataList PrefModelAssociator::GetAllSyncData(
277 syncable::ModelType type) 277 syncer::ModelType type)
278 const { 278 const {
279 DCHECK_EQ(PREFERENCES, type); 279 DCHECK_EQ(PREFERENCES, type);
280 syncer::SyncDataList current_data; 280 syncer::SyncDataList current_data;
281 for (PreferenceSet::const_iterator iter = synced_preferences_.begin(); 281 for (PreferenceSet::const_iterator iter = synced_preferences_.begin();
282 iter != synced_preferences_.end(); 282 iter != synced_preferences_.end();
283 ++iter) { 283 ++iter) {
284 std::string name = *iter; 284 std::string name = *iter;
285 const PrefService::Preference* pref = 285 const PrefService::Preference* pref =
286 pref_service_->FindPreference(name.c_str()); 286 pref_service_->FindPreference(name.c_str());
287 DCHECK(pref); 287 DCHECK(pref);
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 } 432 }
433 433
434 syncer::SyncError error = 434 syncer::SyncError error =
435 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 435 sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
436 } 436 }
437 437
438 void PrefModelAssociator::SetPrefService(PrefService* pref_service) { 438 void PrefModelAssociator::SetPrefService(PrefService* pref_service) {
439 DCHECK(pref_service_ == NULL); 439 DCHECK(pref_service_ == NULL);
440 pref_service_ = pref_service; 440 pref_service_ = pref_service;
441 } 441 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_model_associator.h ('k') | chrome/browser/search_engines/template_url_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698