| OLD | NEW |
| 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/webdata/autofill_profile_syncable_service.h" | 5 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 AutofillProfileSyncableService::~AutofillProfileSyncableService() { | 51 AutofillProfileSyncableService::~AutofillProfileSyncableService() { |
| 52 DCHECK(CalledOnValidThread()); | 52 DCHECK(CalledOnValidThread()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 AutofillProfileSyncableService::AutofillProfileSyncableService() | 55 AutofillProfileSyncableService::AutofillProfileSyncableService() |
| 56 : web_data_service_(NULL) { | 56 : web_data_service_(NULL) { |
| 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 syncer::SyncError AutofillProfileSyncableService::MergeDataAndStartSyncing( | 60 syncer::SyncError AutofillProfileSyncableService::MergeDataAndStartSyncing( |
| 61 syncable::ModelType type, | 61 syncer::ModelType type, |
| 62 const syncer::SyncDataList& initial_sync_data, | 62 const syncer::SyncDataList& initial_sync_data, |
| 63 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 63 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 64 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { | 64 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { |
| 65 DCHECK(CalledOnValidThread()); | 65 DCHECK(CalledOnValidThread()); |
| 66 DCHECK(!sync_processor_.get()); | 66 DCHECK(!sync_processor_.get()); |
| 67 DCHECK(sync_processor.get()); | 67 DCHECK(sync_processor.get()); |
| 68 DCHECK(sync_error_factory.get()); | 68 DCHECK(sync_error_factory.get()); |
| 69 DVLOG(1) << "Associating Autofill: MergeDataAndStartSyncing"; | 69 DVLOG(1) << "Associating Autofill: MergeDataAndStartSyncing"; |
| 70 | 70 |
| 71 sync_error_factory_ = sync_error_factory.Pass(); | 71 sync_error_factory_ = sync_error_factory.Pass(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 syncer::SyncError error; | 154 syncer::SyncError error; |
| 155 if (!new_changes.empty()) | 155 if (!new_changes.empty()) |
| 156 error = sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); | 156 error = sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes); |
| 157 | 157 |
| 158 WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_); | 158 WebDataService::NotifyOfMultipleAutofillChanges(web_data_service_); |
| 159 | 159 |
| 160 return error; | 160 return error; |
| 161 } | 161 } |
| 162 | 162 |
| 163 void AutofillProfileSyncableService::StopSyncing(syncable::ModelType type) { | 163 void AutofillProfileSyncableService::StopSyncing(syncer::ModelType type) { |
| 164 DCHECK(CalledOnValidThread()); | 164 DCHECK(CalledOnValidThread()); |
| 165 DCHECK_EQ(type, syncable::AUTOFILL_PROFILE); | 165 DCHECK_EQ(type, syncer::AUTOFILL_PROFILE); |
| 166 | 166 |
| 167 sync_processor_.reset(); | 167 sync_processor_.reset(); |
| 168 sync_error_factory_.reset(); | 168 sync_error_factory_.reset(); |
| 169 profiles_.reset(); | 169 profiles_.reset(); |
| 170 profiles_map_.clear(); | 170 profiles_map_.clear(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 syncer::SyncDataList AutofillProfileSyncableService::GetAllSyncData( | 173 syncer::SyncDataList AutofillProfileSyncableService::GetAllSyncData( |
| 174 syncable::ModelType type) const { | 174 syncer::ModelType type) const { |
| 175 DCHECK(CalledOnValidThread()); | 175 DCHECK(CalledOnValidThread()); |
| 176 DCHECK(sync_processor_.get()); | 176 DCHECK(sync_processor_.get()); |
| 177 DCHECK_EQ(type, syncable::AUTOFILL_PROFILE); | 177 DCHECK_EQ(type, syncer::AUTOFILL_PROFILE); |
| 178 | 178 |
| 179 syncer::SyncDataList current_data; | 179 syncer::SyncDataList current_data; |
| 180 | 180 |
| 181 for (GUIDToProfileMap::const_iterator i = profiles_map_.begin(); | 181 for (GUIDToProfileMap::const_iterator i = profiles_map_.begin(); |
| 182 i != profiles_map_.end(); ++i) { | 182 i != profiles_map_.end(); ++i) { |
| 183 current_data.push_back(CreateData(*(i->second))); | 183 current_data.push_back(CreateData(*(i->second))); |
| 184 } | 184 } |
| 185 return current_data; | 185 return current_data; |
| 186 } | 186 } |
| 187 | 187 |
| 188 syncer::SyncError AutofillProfileSyncableService::ProcessSyncChanges( | 188 syncer::SyncError AutofillProfileSyncableService::ProcessSyncChanges( |
| 189 const tracked_objects::Location& from_here, | 189 const tracked_objects::Location& from_here, |
| 190 const syncer::SyncChangeList& change_list) { | 190 const syncer::SyncChangeList& change_list) { |
| 191 DCHECK(CalledOnValidThread()); | 191 DCHECK(CalledOnValidThread()); |
| 192 if (!sync_processor_.get()) { | 192 if (!sync_processor_.get()) { |
| 193 syncer::SyncError error(FROM_HERE, "Models not yet associated.", | 193 syncer::SyncError error(FROM_HERE, "Models not yet associated.", |
| 194 syncable::AUTOFILL_PROFILE); | 194 syncer::AUTOFILL_PROFILE); |
| 195 return error; | 195 return error; |
| 196 } | 196 } |
| 197 | 197 |
| 198 DataBundle bundle; | 198 DataBundle bundle; |
| 199 | 199 |
| 200 for (syncer::SyncChangeList::const_iterator i = change_list.begin(); | 200 for (syncer::SyncChangeList::const_iterator i = change_list.begin(); |
| 201 i != change_list.end(); ++i) { | 201 i != change_list.end(); ++i) { |
| 202 DCHECK(i->IsValid()); | 202 DCHECK(i->IsValid()); |
| 203 switch (i->change_type()) { | 203 switch (i->change_type()) { |
| 204 case syncer::SyncChange::ACTION_ADD: | 204 case syncer::SyncChange::ACTION_ADD: |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 } | 369 } |
| 370 | 370 |
| 371 AutofillProfileSyncableService::GUIDToProfileMap::iterator | 371 AutofillProfileSyncableService::GUIDToProfileMap::iterator |
| 372 AutofillProfileSyncableService::CreateOrUpdateProfile( | 372 AutofillProfileSyncableService::CreateOrUpdateProfile( |
| 373 const syncer::SyncData& data, | 373 const syncer::SyncData& data, |
| 374 GUIDToProfileMap* profile_map, | 374 GUIDToProfileMap* profile_map, |
| 375 DataBundle* bundle) { | 375 DataBundle* bundle) { |
| 376 DCHECK(profile_map); | 376 DCHECK(profile_map); |
| 377 DCHECK(bundle); | 377 DCHECK(bundle); |
| 378 | 378 |
| 379 DCHECK_EQ(syncable::AUTOFILL_PROFILE, data.GetDataType()); | 379 DCHECK_EQ(syncer::AUTOFILL_PROFILE, data.GetDataType()); |
| 380 | 380 |
| 381 const sync_pb::EntitySpecifics& specifics = data.GetSpecifics(); | 381 const sync_pb::EntitySpecifics& specifics = data.GetSpecifics(); |
| 382 const sync_pb::AutofillProfileSpecifics& autofill_specifics( | 382 const sync_pb::AutofillProfileSpecifics& autofill_specifics( |
| 383 specifics.autofill_profile()); | 383 specifics.autofill_profile()); |
| 384 | 384 |
| 385 GUIDToProfileMap::iterator it = profile_map->find( | 385 GUIDToProfileMap::iterator it = profile_map->find( |
| 386 autofill_specifics.guid()); | 386 autofill_specifics.guid()); |
| 387 if (it != profile_map->end()) { | 387 if (it != profile_map->end()) { |
| 388 // Some profile that already present is synced. | 388 // Some profile that already present is synced. |
| 389 if (OverwriteProfileWithServerData(autofill_specifics, it->second)) | 389 if (OverwriteProfileWithServerData(autofill_specifics, it->second)) |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 } | 525 } |
| 526 | 526 |
| 527 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { | 527 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { |
| 528 return web_data_service_->GetDatabase()->GetAutofillTable(); | 528 return web_data_service_->GetDatabase()->GetAutofillTable(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 AutofillProfileSyncableService::DataBundle::DataBundle() {} | 531 AutofillProfileSyncableService::DataBundle::DataBundle() {} |
| 532 | 532 |
| 533 AutofillProfileSyncableService::DataBundle::~DataBundle() { | 533 AutofillProfileSyncableService::DataBundle::~DataBundle() { |
| 534 } | 534 } |
| OLD | NEW |