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/location.h" | 7 #include "base/location.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autofill/autofill_profile.h" | 10 #include "chrome/browser/autofill/autofill_profile.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 AutofillProfileSyncableService::AutofillProfileSyncableService() | 54 AutofillProfileSyncableService::AutofillProfileSyncableService() |
55 : web_data_service_(NULL) { | 55 : web_data_service_(NULL) { |
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
57 } | 57 } |
58 | 58 |
59 SyncError AutofillProfileSyncableService::MergeDataAndStartSyncing( | 59 SyncError AutofillProfileSyncableService::MergeDataAndStartSyncing( |
60 syncable::ModelType type, | 60 syncable::ModelType type, |
61 const SyncDataList& initial_sync_data, | 61 const SyncDataList& initial_sync_data, |
62 SyncChangeProcessor* sync_processor) { | 62 scoped_ptr<SyncChangeProcessor> sync_processor) { |
63 DCHECK(CalledOnValidThread()); | 63 DCHECK(CalledOnValidThread()); |
64 DCHECK(!sync_processor_.get()); | 64 DCHECK(!sync_processor_.get()); |
| 65 DCHECK(sync_processor.get()); |
65 DVLOG(1) << "Associating Autofill: MergeDataAndStartSyncing"; | 66 DVLOG(1) << "Associating Autofill: MergeDataAndStartSyncing"; |
66 | 67 |
67 if (!LoadAutofillData(&profiles_.get())) { | 68 if (!LoadAutofillData(&profiles_.get())) { |
68 return SyncError( | 69 return SyncError( |
69 FROM_HERE, "Could not get the autofill data from WebDatabase.", | 70 FROM_HERE, "Could not get the autofill data from WebDatabase.", |
70 model_type()); | 71 model_type()); |
71 } | 72 } |
72 | 73 |
73 if (DLOG_IS_ON(INFO)) { | 74 if (DLOG_IS_ON(INFO)) { |
74 DVLOG(2) << "[AUTOFILL MIGRATION]" | 75 DVLOG(2) << "[AUTOFILL MIGRATION]" |
75 << "Printing profiles from web db"; | 76 << "Printing profiles from web db"; |
76 | 77 |
77 for (ScopedVector<AutofillProfile>::const_iterator ix = | 78 for (ScopedVector<AutofillProfile>::const_iterator ix = |
78 profiles_.begin(); ix != profiles_.end(); ++ix) { | 79 profiles_.begin(); ix != profiles_.end(); ++ix) { |
79 AutofillProfile* p = *ix; | 80 AutofillProfile* p = *ix; |
80 DVLOG(2) << "[AUTOFILL MIGRATION] " | 81 DVLOG(2) << "[AUTOFILL MIGRATION] " |
81 << p->GetInfo(NAME_FIRST) | 82 << p->GetInfo(NAME_FIRST) |
82 << p->GetInfo(NAME_LAST) | 83 << p->GetInfo(NAME_LAST) |
83 << p->guid(); | 84 << p->guid(); |
84 } | 85 } |
85 } | 86 } |
86 | 87 |
87 sync_processor_.reset(sync_processor); | 88 sync_processor_ = sync_processor.Pass(); |
88 | 89 |
89 GUIDToProfileMap remaining_profiles; | 90 GUIDToProfileMap remaining_profiles; |
90 CreateGUIDToProfileMap(profiles_.get(), &remaining_profiles); | 91 CreateGUIDToProfileMap(profiles_.get(), &remaining_profiles); |
91 | 92 |
92 DataBundle bundle; | 93 DataBundle bundle; |
93 // Go through and check for all the profiles that sync already knows about. | 94 // Go through and check for all the profiles that sync already knows about. |
94 for (SyncDataList::const_iterator sync_iter = initial_sync_data.begin(); | 95 for (SyncDataList::const_iterator sync_iter = initial_sync_data.begin(); |
95 sync_iter != initial_sync_data.end(); | 96 sync_iter != initial_sync_data.end(); |
96 ++sync_iter) { | 97 ++sync_iter) { |
97 GUIDToProfileMap::iterator it = | 98 GUIDToProfileMap::iterator it = |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 } | 504 } |
504 | 505 |
505 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { | 506 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { |
506 return web_data_service_->GetDatabase()->GetAutofillTable(); | 507 return web_data_service_->GetDatabase()->GetAutofillTable(); |
507 } | 508 } |
508 | 509 |
509 AutofillProfileSyncableService::DataBundle::DataBundle() {} | 510 AutofillProfileSyncableService::DataBundle::DataBundle() {} |
510 | 511 |
511 AutofillProfileSyncableService::DataBundle::~DataBundle() { | 512 AutofillProfileSyncableService::DataBundle::~DataBundle() { |
512 } | 513 } |
OLD | NEW |