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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
5 #include <set> | 8 #include <set> |
6 #include <string> | 9 #include <string> |
7 #include <utility> | 10 #include <utility> |
8 #include <vector> | 11 #include <vector> |
9 | 12 |
10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
11 | 14 |
12 #include "base/bind.h" | 15 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
14 #include "base/callback.h" | 17 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
16 #include "base/location.h" | 19 #include "base/location.h" |
| 20 #include "base/macros.h" |
17 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
19 #include "base/run_loop.h" | 23 #include "base/run_loop.h" |
20 #include "base/strings/string16.h" | 24 #include "base/strings/string16.h" |
21 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
22 #include "base/synchronization/waitable_event.h" | 26 #include "base/synchronization/waitable_event.h" |
23 #include "base/time/time.h" | 27 #include "base/time/time.h" |
24 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 28 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
25 #include "chrome/browser/signin/account_tracker_service_factory.h" | 29 #include "chrome/browser/signin/account_tracker_service_factory.h" |
26 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 30 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 } | 577 } |
574 | 578 |
575 bool GetAutofillEntriesFromSyncDB(std::vector<AutofillEntry>* entries, | 579 bool GetAutofillEntriesFromSyncDB(std::vector<AutofillEntry>* entries, |
576 std::vector<AutofillProfile>* profiles) { | 580 std::vector<AutofillProfile>* profiles) { |
577 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 581 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
578 syncer::ReadNode autofill_root(&trans); | 582 syncer::ReadNode autofill_root(&trans); |
579 if (autofill_root.InitTypeRoot(syncer::AUTOFILL) != BaseNode::INIT_OK) { | 583 if (autofill_root.InitTypeRoot(syncer::AUTOFILL) != BaseNode::INIT_OK) { |
580 return false; | 584 return false; |
581 } | 585 } |
582 | 586 |
583 int64 child_id = autofill_root.GetFirstChildId(); | 587 int64_t child_id = autofill_root.GetFirstChildId(); |
584 while (child_id != syncer::kInvalidId) { | 588 while (child_id != syncer::kInvalidId) { |
585 syncer::ReadNode child_node(&trans); | 589 syncer::ReadNode child_node(&trans); |
586 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) | 590 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) |
587 return false; | 591 return false; |
588 | 592 |
589 const sync_pb::AutofillSpecifics& autofill( | 593 const sync_pb::AutofillSpecifics& autofill( |
590 child_node.GetEntitySpecifics().autofill()); | 594 child_node.GetEntitySpecifics().autofill()); |
591 if (autofill.has_value()) { | 595 if (autofill.has_value()) { |
592 AutofillKey key(base::UTF8ToUTF16(autofill.name()), | 596 AutofillKey key(base::UTF8ToUTF16(autofill.name()), |
593 base::UTF8ToUTF16(autofill.value())); | 597 base::UTF8ToUTF16(autofill.value())); |
(...skipping 18 matching lines...) Expand all Loading... |
612 } | 616 } |
613 | 617 |
614 bool GetAutofillProfilesFromSyncDBUnderProfileNode( | 618 bool GetAutofillProfilesFromSyncDBUnderProfileNode( |
615 std::vector<AutofillProfile>* profiles) { | 619 std::vector<AutofillProfile>* profiles) { |
616 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 620 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
617 syncer::ReadNode autofill_root(&trans); | 621 syncer::ReadNode autofill_root(&trans); |
618 if (autofill_root.InitTypeRoot(AUTOFILL_PROFILE) != BaseNode::INIT_OK) { | 622 if (autofill_root.InitTypeRoot(AUTOFILL_PROFILE) != BaseNode::INIT_OK) { |
619 return false; | 623 return false; |
620 } | 624 } |
621 | 625 |
622 int64 child_id = autofill_root.GetFirstChildId(); | 626 int64_t child_id = autofill_root.GetFirstChildId(); |
623 while (child_id != syncer::kInvalidId) { | 627 while (child_id != syncer::kInvalidId) { |
624 syncer::ReadNode child_node(&trans); | 628 syncer::ReadNode child_node(&trans); |
625 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) | 629 if (child_node.InitByIdLookup(child_id) != BaseNode::INIT_OK) |
626 return false; | 630 return false; |
627 | 631 |
628 const sync_pb::AutofillProfileSpecifics& autofill( | 632 const sync_pb::AutofillProfileSpecifics& autofill( |
629 child_node.GetEntitySpecifics().autofill_profile()); | 633 child_node.GetEntitySpecifics().autofill_profile()); |
630 AutofillProfile p; | 634 AutofillProfile p; |
631 p.set_guid(autofill.guid()); | 635 p.set_guid(autofill.guid()); |
632 AutofillProfileSyncableService::OverwriteProfileWithServerData( | 636 AutofillProfileSyncableService::OverwriteProfileWithServerData( |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 std::vector<AutofillEntry> sync_entries; | 1307 std::vector<AutofillEntry> sync_entries; |
1304 std::vector<AutofillProfile> sync_profiles; | 1308 std::vector<AutofillProfile> sync_profiles; |
1305 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1309 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1306 EXPECT_EQ(3U, sync_entries.size()); | 1310 EXPECT_EQ(3U, sync_entries.size()); |
1307 EXPECT_EQ(0U, sync_profiles.size()); | 1311 EXPECT_EQ(0U, sync_profiles.size()); |
1308 for (size_t i = 0; i < sync_entries.size(); i++) { | 1312 for (size_t i = 0; i < sync_entries.size(); i++) { |
1309 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1313 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1310 << ", " << sync_entries[i].key().value(); | 1314 << ", " << sync_entries[i].key().value(); |
1311 } | 1315 } |
1312 } | 1316 } |
OLD | NEW |