| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 578 |
| 579 WriteTransaction::NotifyTransactionComplete(types); | 579 WriteTransaction::NotifyTransactionComplete(types); |
| 580 } | 580 } |
| 581 | 581 |
| 582 private: | 582 private: |
| 583 scoped_ptr<WaitableEvent>* wait_for_syncapi_; | 583 scoped_ptr<WaitableEvent>* wait_for_syncapi_; |
| 584 }; | 584 }; |
| 585 | 585 |
| 586 // Our fake server updater. Needs the RefCountedThreadSafe inheritance so we can | 586 // Our fake server updater. Needs the RefCountedThreadSafe inheritance so we can |
| 587 // post tasks with it. | 587 // post tasks with it. |
| 588 class FakeServerUpdater: public base::RefCountedThreadSafe<FakeServerUpdater> { | 588 class FakeServerUpdater : public base::RefCountedThreadSafe<FakeServerUpdater> { |
| 589 public: | 589 public: |
| 590 FakeServerUpdater(TestProfileSyncService* service, | 590 FakeServerUpdater(TestProfileSyncService* service, |
| 591 scoped_ptr<WaitableEvent>* wait_for_start, | 591 scoped_ptr<WaitableEvent>* wait_for_start, |
| 592 scoped_ptr<WaitableEvent>* wait_for_syncapi) | 592 scoped_ptr<WaitableEvent>* wait_for_syncapi) |
| 593 : entry_(ProfileSyncServiceAutofillTest::MakeAutofillEntry("0", "0", 0)), | 593 : entry_(ProfileSyncServiceAutofillTest::MakeAutofillEntry("0", "0", 0)), |
| 594 service_(service), | 594 service_(service), |
| 595 wait_for_start_(wait_for_start), | 595 wait_for_start_(wait_for_start), |
| 596 wait_for_syncapi_(wait_for_syncapi), | 596 wait_for_syncapi_(wait_for_syncapi), |
| 597 is_finished_(false, false) { } | 597 is_finished_(false, false) { } |
| 598 | 598 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 VLOG(1) << "FakeServerUpdater finishing."; | 645 VLOG(1) << "FakeServerUpdater finishing."; |
| 646 is_finished_.Signal(); | 646 is_finished_.Signal(); |
| 647 } | 647 } |
| 648 | 648 |
| 649 void CreateNewEntry(const AutofillEntry& entry) { | 649 void CreateNewEntry(const AutofillEntry& entry) { |
| 650 entry_ = entry; | 650 entry_ = entry; |
| 651 scoped_ptr<Callback0::Type> c(NewCallback((FakeServerUpdater*)this, | 651 scoped_ptr<Callback0::Type> c(NewCallback((FakeServerUpdater*)this, |
| 652 &FakeServerUpdater::Update)); | 652 &FakeServerUpdater::Update)); |
| 653 ASSERT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 653 ASSERT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 654 if (!BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 654 if (!BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 655 NewRunnableMethod(this, &FakeServerUpdater::Update))) { | 655 base::Bind(&FakeServerUpdater::Update, this))) { |
| 656 NOTREACHED() << "Failed to post task to the db thread."; | 656 NOTREACHED() << "Failed to post task to the db thread."; |
| 657 return; | 657 return; |
| 658 } | 658 } |
| 659 } | 659 } |
| 660 | 660 |
| 661 void CreateNewEntryAndWait(const AutofillEntry& entry) { | 661 void CreateNewEntryAndWait(const AutofillEntry& entry) { |
| 662 entry_ = entry; | 662 entry_ = entry; |
| 663 scoped_ptr<Callback0::Type> c(NewCallback((FakeServerUpdater*)this, | 663 scoped_ptr<Callback0::Type> c(NewCallback((FakeServerUpdater*)this, |
| 664 &FakeServerUpdater::Update)); | 664 &FakeServerUpdater::Update)); |
| 665 ASSERT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 665 ASSERT_FALSE(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 666 is_finished_.Reset(); | 666 is_finished_.Reset(); |
| 667 if (!BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 667 if (!BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 668 NewRunnableMethod(this, &FakeServerUpdater::Update))) { | 668 base::Bind(&FakeServerUpdater::Update, this))) { |
| 669 NOTREACHED() << "Failed to post task to the db thread."; | 669 NOTREACHED() << "Failed to post task to the db thread."; |
| 670 return; | 670 return; |
| 671 } | 671 } |
| 672 is_finished_.Wait(); | 672 is_finished_.Wait(); |
| 673 } | 673 } |
| 674 | 674 |
| 675 private: | 675 private: |
| 676 friend class base::RefCountedThreadSafe<FakeServerUpdater>; | 676 friend class base::RefCountedThreadSafe<FakeServerUpdater>; |
| 677 ~FakeServerUpdater() { } | 677 ~FakeServerUpdater() { } |
| 678 | 678 |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 std::vector<AutofillEntry> sync_entries; | 1148 std::vector<AutofillEntry> sync_entries; |
| 1149 std::vector<AutofillProfile> sync_profiles; | 1149 std::vector<AutofillProfile> sync_profiles; |
| 1150 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1150 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1151 EXPECT_EQ(3U, sync_entries.size()); | 1151 EXPECT_EQ(3U, sync_entries.size()); |
| 1152 EXPECT_EQ(0U, sync_profiles.size()); | 1152 EXPECT_EQ(0U, sync_profiles.size()); |
| 1153 for (size_t i = 0; i < sync_entries.size(); i++) { | 1153 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1154 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1154 VLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
| 1155 << ", " << sync_entries[i].key().value(); | 1155 << ", " << sync_entries[i].key().value(); |
| 1156 } | 1156 } |
| 1157 } | 1157 } |
| OLD | NEW |