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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 if (!web_database_->GetAutoFillProfiles(profiles)) | 130 if (!web_database_->GetAutoFillProfiles(profiles)) |
131 return false; | 131 return false; |
132 | 132 |
133 return true; | 133 return true; |
134 } | 134 } |
135 | 135 |
136 bool AutofillModelAssociator::AssociateModels() { | 136 bool AutofillModelAssociator::AssociateModels() { |
137 VLOG(1) << "Associating Autofill Models"; | 137 VLOG(1) << "Associating Autofill Models"; |
138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
139 { | 139 { |
140 AutoLock lock(abort_association_pending_lock_); | 140 base::AutoLock lock(abort_association_pending_lock_); |
141 abort_association_pending_ = false; | 141 abort_association_pending_ = false; |
142 } | 142 } |
143 | 143 |
144 // TODO(zork): Attempt to load the model association from storage. | 144 // TODO(zork): Attempt to load the model association from storage. |
145 std::vector<AutofillEntry> entries; | 145 std::vector<AutofillEntry> entries; |
146 ScopedVector<AutoFillProfile> profiles; | 146 ScopedVector<AutoFillProfile> profiles; |
147 | 147 |
148 if (!LoadAutofillData(&entries, &profiles.get())) { | 148 if (!LoadAutofillData(&entries, &profiles.get())) { |
149 LOG(ERROR) << "Could not get the autofill data from WebDatabase."; | 149 LOG(ERROR) << "Could not get the autofill data from WebDatabase."; |
150 return false; | 150 return false; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 } | 395 } |
396 | 396 |
397 // The sync model has user created nodes if the autofill folder has any | 397 // The sync model has user created nodes if the autofill folder has any |
398 // children. | 398 // children. |
399 *has_nodes = sync_api::kInvalidId != autofill_node.GetFirstChildId(); | 399 *has_nodes = sync_api::kInvalidId != autofill_node.GetFirstChildId(); |
400 return true; | 400 return true; |
401 } | 401 } |
402 | 402 |
403 void AutofillModelAssociator::AbortAssociation() { | 403 void AutofillModelAssociator::AbortAssociation() { |
404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
405 AutoLock lock(abort_association_pending_lock_); | 405 base::AutoLock lock(abort_association_pending_lock_); |
406 abort_association_pending_ = true; | 406 abort_association_pending_ = true; |
407 } | 407 } |
408 | 408 |
409 const std::string* | 409 const std::string* |
410 AutofillModelAssociator::GetChromeNodeFromSyncId(int64 sync_id) { | 410 AutofillModelAssociator::GetChromeNodeFromSyncId(int64 sync_id) { |
411 SyncIdToAutofillMap::const_iterator iter = id_map_inverse_.find(sync_id); | 411 SyncIdToAutofillMap::const_iterator iter = id_map_inverse_.find(sync_id); |
412 return iter == id_map_inverse_.end() ? NULL : &(iter->second); | 412 return iter == id_map_inverse_.end() ? NULL : &(iter->second); |
413 } | 413 } |
414 | 414 |
415 bool AutofillModelAssociator::InitSyncNodeFromChromeId( | 415 bool AutofillModelAssociator::InitSyncNodeFromChromeId( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 sync_api::ReadTransaction trans( | 448 sync_api::ReadTransaction trans( |
449 sync_service_->backend()->GetUserShareHandle()); | 449 sync_service_->backend()->GetUserShareHandle()); |
450 sync_api::ReadNode sync_node(&trans); | 450 sync_api::ReadNode sync_node(&trans); |
451 if (!sync_node.InitByTagLookup(tag.c_str())) | 451 if (!sync_node.InitByTagLookup(tag.c_str())) |
452 return false; | 452 return false; |
453 *sync_id = sync_node.GetId(); | 453 *sync_id = sync_node.GetId(); |
454 return true; | 454 return true; |
455 } | 455 } |
456 | 456 |
457 bool AutofillModelAssociator::IsAbortPending() { | 457 bool AutofillModelAssociator::IsAbortPending() { |
458 AutoLock lock(abort_association_pending_lock_); | 458 base::AutoLock lock(abort_association_pending_lock_); |
459 return abort_association_pending_; | 459 return abort_association_pending_; |
460 } | 460 } |
461 | 461 |
462 // static | 462 // static |
463 std::string AutofillModelAssociator::KeyToTag(const string16& name, | 463 std::string AutofillModelAssociator::KeyToTag(const string16& name, |
464 const string16& value) { | 464 const string16& value) { |
465 std::string ns(kAutofillEntryNamespaceTag); | 465 std::string ns(kAutofillEntryNamespaceTag); |
466 return ns + EscapePath(UTF16ToUTF8(name)) + "|" + | 466 return ns + EscapePath(UTF16ToUTF8(name)) + "|" + |
467 EscapePath(UTF16ToUTF8(value)); | 467 EscapePath(UTF16ToUTF8(value)); |
468 } | 468 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 | 570 |
571 VLOG(1) << "[AUTOFILL MIGRATION]" | 571 VLOG(1) << "[AUTOFILL MIGRATION]" |
572 << "Current autofill migration state is migrated."; | 572 << "Current autofill migration state is migrated."; |
573 } | 573 } |
574 | 574 |
575 return false; | 575 return false; |
576 } | 576 } |
577 | 577 |
578 } // namespace browser_sync | 578 } // namespace browser_sync |
579 | 579 |
OLD | NEW |