OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sync/glue/autofill_model_associator.h" | 5 #include "chrome/browser/sync/glue/autofill_model_associator.h" |
6 | 6 |
7 #include <functional> | 7 #include <functional> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/task.h" | 10 #include "base/task.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 228 |
229 bool AutofillModelAssociator::TraverseAndAssociateAllSyncNodes( | 229 bool AutofillModelAssociator::TraverseAndAssociateAllSyncNodes( |
230 sync_api::WriteTransaction* write_trans, | 230 sync_api::WriteTransaction* write_trans, |
231 const sync_api::ReadNode& autofill_root, | 231 const sync_api::ReadNode& autofill_root, |
232 DataBundle* bundle, | 232 DataBundle* bundle, |
233 const std::vector<AutoFillProfile*>& all_profiles_from_db) { | 233 const std::vector<AutoFillProfile*>& all_profiles_from_db) { |
234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
235 | 235 |
236 bool autofill_profile_not_migrated = HasNotMigratedYet(write_trans); | 236 bool autofill_profile_not_migrated = HasNotMigratedYet(write_trans); |
237 | 237 |
238 if (VLOG_IS_ON(1) && autofill_profile_not_migrated) { | 238 if (VLOG_IS_ON(2) && autofill_profile_not_migrated) { |
239 VLOG(1) << "[AUTOFILL MIGRATION]" | 239 VLOG(2) << "[AUTOFILL MIGRATION]" |
240 << "Printing profiles from web db"; | 240 << "Printing profiles from web db"; |
241 | 241 |
242 for (std::vector<AutoFillProfile*>::const_iterator ix = | 242 for (std::vector<AutoFillProfile*>::const_iterator ix = |
243 all_profiles_from_db.begin(); ix != all_profiles_from_db.end(); ++ix) { | 243 all_profiles_from_db.begin(); ix != all_profiles_from_db.end(); ++ix) { |
244 AutoFillProfile* p = *ix; | 244 AutoFillProfile* p = *ix; |
245 VLOG(1) << "[AUTOFILL MIGRATION] " | 245 VLOG(2) << "[AUTOFILL MIGRATION] " |
246 << p->GetFieldText(AutoFillType(NAME_FIRST)) | 246 << p->GetFieldText(AutoFillType(NAME_FIRST)) |
247 << p->GetFieldText(AutoFillType(NAME_LAST)); | 247 << p->GetFieldText(AutoFillType(NAME_LAST)); |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 if (autofill_profile_not_migrated) { | 251 if (autofill_profile_not_migrated) { |
252 VLOG(1) << "[AUTOFILL MIGRATION]" | 252 VLOG(1) << "[AUTOFILL MIGRATION]" |
253 << "Iterating over sync db"; | 253 << "Iterating over sync db"; |
254 } | 254 } |
255 | 255 |
256 int64 sync_child_id = autofill_root.GetFirstChildId(); | 256 int64 sync_child_id = autofill_root.GetFirstChildId(); |
257 while (sync_child_id != sync_api::kInvalidId) { | 257 while (sync_child_id != sync_api::kInvalidId) { |
258 sync_api::ReadNode sync_child(write_trans); | 258 sync_api::ReadNode sync_child(write_trans); |
259 if (!sync_child.InitByIdLookup(sync_child_id)) { | 259 if (!sync_child.InitByIdLookup(sync_child_id)) { |
260 LOG(ERROR) << "Failed to fetch child node."; | 260 LOG(ERROR) << "Failed to fetch child node."; |
261 return false; | 261 return false; |
262 } | 262 } |
263 const sync_pb::AutofillSpecifics& autofill( | 263 const sync_pb::AutofillSpecifics& autofill( |
264 sync_child.GetAutofillSpecifics()); | 264 sync_child.GetAutofillSpecifics()); |
265 | 265 |
266 if (autofill.has_value()) { | 266 if (autofill.has_value()) { |
267 AddNativeEntryIfNeeded(autofill, bundle, sync_child); | 267 AddNativeEntryIfNeeded(autofill, bundle, sync_child); |
268 } else if (autofill.has_profile()) { | 268 } else if (autofill.has_profile()) { |
269 // Ignore autofill profiles if we are not upgrading. | 269 // Ignore autofill profiles if we are not upgrading. |
270 if (autofill_profile_not_migrated) { | 270 if (autofill_profile_not_migrated) { |
271 VLOG(1) << "[AUTOFILL MIGRATION] Looking for " | 271 VLOG(2) << "[AUTOFILL MIGRATION] Looking for " |
272 << autofill.profile().name_first() | 272 << autofill.profile().name_first() |
273 << autofill.profile().name_last(); | 273 << autofill.profile().name_last(); |
274 AddNativeProfileIfNeeded( | 274 AddNativeProfileIfNeeded( |
275 autofill.profile(), | 275 autofill.profile(), |
276 bundle, | 276 bundle, |
277 sync_child, | 277 sync_child, |
278 all_profiles_from_db); | 278 all_profiles_from_db); |
279 } | 279 } |
280 } else { | 280 } else { |
281 NOTREACHED() << "AutofillSpecifics has no autofill data!"; | 281 NOTREACHED() << "AutofillSpecifics has no autofill data!"; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 sync_service_->SetAutofillMigrationState(syncable::MIGRATED); | 565 sync_service_->SetAutofillMigrationState(syncable::MIGRATED); |
566 | 566 |
567 VLOG(1) << "[AUTOFILL MIGRATION]" | 567 VLOG(1) << "[AUTOFILL MIGRATION]" |
568 << "Current autofill migration state is migrated."; | 568 << "Current autofill migration state is migrated."; |
569 } | 569 } |
570 | 570 |
571 return false; | 571 return false; |
572 } | 572 } |
573 | 573 |
574 } // namespace browser_sync | 574 } // namespace browser_sync |
OLD | NEW |