OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 #include "sync/test/engine/test_id_factory.h" | 62 #include "sync/test/engine/test_id_factory.h" |
63 #include "testing/gmock/include/gmock/gmock.h" | 63 #include "testing/gmock/include/gmock/gmock.h" |
64 | 64 |
65 using autofill::AutofillChange; | 65 using autofill::AutofillChange; |
66 using autofill::AutofillChangeList; | 66 using autofill::AutofillChangeList; |
67 using autofill::AutofillEntry; | 67 using autofill::AutofillEntry; |
68 using autofill::ServerFieldType; | 68 using autofill::ServerFieldType; |
69 using autofill::AutofillKey; | 69 using autofill::AutofillKey; |
70 using autofill::AutofillProfile; | 70 using autofill::AutofillProfile; |
71 using autofill::AutofillProfileChange; | 71 using autofill::AutofillProfileChange; |
| 72 using autofill::AutofillProfileSyncableService; |
72 using autofill::AutofillTable; | 73 using autofill::AutofillTable; |
73 using autofill::AutofillWebDataService; | 74 using autofill::AutofillWebDataService; |
74 using autofill::PersonalDataManager; | 75 using autofill::PersonalDataManager; |
75 using base::Time; | 76 using base::Time; |
76 using base::TimeDelta; | 77 using base::TimeDelta; |
77 using base::WaitableEvent; | 78 using base::WaitableEvent; |
78 using browser_sync::AutofillDataTypeController; | 79 using browser_sync::AutofillDataTypeController; |
79 using browser_sync::AutofillProfileDataTypeController; | 80 using browser_sync::AutofillProfileDataTypeController; |
80 using browser_sync::DataTypeController; | 81 using browser_sync::DataTypeController; |
81 using browser_sync::GenericChangeProcessor; | 82 using browser_sync::GenericChangeProcessor; |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 AutocompleteSyncableService::WriteAutofillEntry(entry, &specifics); | 636 AutocompleteSyncableService::WriteAutofillEntry(entry, &specifics); |
636 sync_pb::AutofillSpecifics* autofill_specifics = | 637 sync_pb::AutofillSpecifics* autofill_specifics = |
637 specifics.mutable_autofill(); | 638 specifics.mutable_autofill(); |
638 node.SetAutofillSpecifics(*autofill_specifics); | 639 node.SetAutofillSpecifics(*autofill_specifics); |
639 return true; | 640 return true; |
640 } | 641 } |
641 | 642 |
642 bool AddAutofillSyncNode(const AutofillProfile& profile) { | 643 bool AddAutofillSyncNode(const AutofillProfile& profile) { |
643 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 644 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
644 syncer::ReadNode autofill_root(&trans); | 645 syncer::ReadNode autofill_root(&trans); |
645 if (autofill_root.InitByTagLookup(kAutofillProfileTag) != | 646 if (autofill_root.InitByTagLookup(autofill::kAutofillProfileTag) != |
646 BaseNode::INIT_OK) { | 647 BaseNode::INIT_OK) { |
647 return false; | 648 return false; |
648 } | 649 } |
649 syncer::WriteNode node(&trans); | 650 syncer::WriteNode node(&trans); |
650 std::string tag = profile.guid(); | 651 std::string tag = profile.guid(); |
651 syncer::WriteNode::InitUniqueByCreationResult result = | 652 syncer::WriteNode::InitUniqueByCreationResult result = |
652 node.InitUniqueByCreation(syncer::AUTOFILL_PROFILE, | 653 node.InitUniqueByCreation(syncer::AUTOFILL_PROFILE, |
653 autofill_root, tag); | 654 autofill_root, tag); |
654 if (result != syncer::WriteNode::INIT_SUCCESS) | 655 if (result != syncer::WriteNode::INIT_SUCCESS) |
655 return false; | 656 return false; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 } | 700 } |
700 child_id = child_node.GetSuccessorId(); | 701 child_id = child_node.GetSuccessorId(); |
701 } | 702 } |
702 return true; | 703 return true; |
703 } | 704 } |
704 | 705 |
705 bool GetAutofillProfilesFromSyncDBUnderProfileNode( | 706 bool GetAutofillProfilesFromSyncDBUnderProfileNode( |
706 std::vector<AutofillProfile>* profiles) { | 707 std::vector<AutofillProfile>* profiles) { |
707 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 708 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
708 syncer::ReadNode autofill_root(&trans); | 709 syncer::ReadNode autofill_root(&trans); |
709 if (autofill_root.InitByTagLookup(kAutofillProfileTag) != | 710 if (autofill_root.InitByTagLookup(autofill::kAutofillProfileTag) != |
710 BaseNode::INIT_OK) { | 711 BaseNode::INIT_OK) { |
711 return false; | 712 return false; |
712 } | 713 } |
713 | 714 |
714 int64 child_id = autofill_root.GetFirstChildId(); | 715 int64 child_id = autofill_root.GetFirstChildId(); |
715 while (child_id != syncer::kInvalidId) { | 716 while (child_id != syncer::kInvalidId) { |
716 syncer::ReadNode child_node(&trans); | 717 syncer::ReadNode child_node(&trans); |
717 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) | 718 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) |
718 return false; | 719 return false; |
719 | 720 |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 std::vector<AutofillEntry> sync_entries; | 1412 std::vector<AutofillEntry> sync_entries; |
1412 std::vector<AutofillProfile> sync_profiles; | 1413 std::vector<AutofillProfile> sync_profiles; |
1413 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1414 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1414 EXPECT_EQ(3U, sync_entries.size()); | 1415 EXPECT_EQ(3U, sync_entries.size()); |
1415 EXPECT_EQ(0U, sync_profiles.size()); | 1416 EXPECT_EQ(0U, sync_profiles.size()); |
1416 for (size_t i = 0; i < sync_entries.size(); i++) { | 1417 for (size_t i = 0; i < sync_entries.size(); i++) { |
1417 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1418 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1418 << ", " << sync_entries[i].key().value(); | 1419 << ", " << sync_entries[i].key().value(); |
1419 } | 1420 } |
1420 } | 1421 } |
OLD | NEW |