OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 AutofillWebDataServiceConsumer() : handle_(0) {} | 52 AutofillWebDataServiceConsumer() : handle_(0) {} |
53 virtual ~AutofillWebDataServiceConsumer() {} | 53 virtual ~AutofillWebDataServiceConsumer() {} |
54 | 54 |
55 virtual void OnWebDataServiceRequestDone(WebDataServiceBase::Handle handle, | 55 virtual void OnWebDataServiceRequestDone(WebDataServiceBase::Handle handle, |
56 const WDTypedResult* result) { | 56 const WDTypedResult* result) { |
57 handle_ = handle; | 57 handle_ = handle; |
58 const WDResult<T>* wrapped_result = | 58 const WDResult<T>* wrapped_result = |
59 static_cast<const WDResult<T>*>(result); | 59 static_cast<const WDResult<T>*>(result); |
60 result_ = wrapped_result->GetValue(); | 60 result_ = wrapped_result->GetValue(); |
61 | 61 |
62 base::MessageLoop::current()->Quit(); | 62 base::MessageLoop::current()->QuitWhenIdle(); |
63 } | 63 } |
64 | 64 |
65 WebDataServiceBase::Handle handle() { return handle_; } | 65 WebDataServiceBase::Handle handle() { return handle_; } |
66 T& result() { return result_; } | 66 T& result() { return result_; } |
67 | 67 |
68 private: | 68 private: |
69 WebDataServiceBase::Handle handle_; | 69 WebDataServiceBase::Handle handle_; |
70 T result_; | 70 T result_; |
71 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataServiceConsumer); | 71 DISALLOW_COPY_AND_ASSIGN(AutofillWebDataServiceConsumer); |
72 }; | 72 }; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 | 114 |
115 void TearDown() override { | 115 void TearDown() override { |
116 wds_->ShutdownOnUIThread(); | 116 wds_->ShutdownOnUIThread(); |
117 wdbs_->ShutdownDatabase(); | 117 wdbs_->ShutdownDatabase(); |
118 wds_ = NULL; | 118 wds_ = NULL; |
119 wdbs_ = NULL; | 119 wdbs_ = NULL; |
120 WaitForDatabaseThread(); | 120 WaitForDatabaseThread(); |
121 | 121 |
122 base::ThreadTaskRunnerHandle::Get()->PostTask( | 122 base::ThreadTaskRunnerHandle::Get()->PostTask( |
123 FROM_HERE, base::MessageLoop::QuitClosure()); | 123 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
124 base::MessageLoop::current()->Run(); | 124 base::MessageLoop::current()->Run(); |
125 db_thread_.Stop(); | 125 db_thread_.Stop(); |
126 } | 126 } |
127 | 127 |
128 void WaitForDatabaseThread() { | 128 void WaitForDatabaseThread() { |
129 base::WaitableEvent done(false, false); | 129 base::WaitableEvent done(false, false); |
130 db_thread_.task_runner()->PostTask( | 130 db_thread_.task_runner()->PostTask( |
131 FROM_HERE, | 131 FROM_HERE, |
132 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | 132 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
133 done.Wait(); | 133 done.Wait(); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 532 |
533 // Check that the credit card was removed. | 533 // Check that the credit card was removed. |
534 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2; | 534 AutofillWebDataServiceConsumer<std::vector<CreditCard*> > card_consumer2; |
535 handle2 = wds_->GetCreditCards(&card_consumer2); | 535 handle2 = wds_->GetCreditCards(&card_consumer2); |
536 base::MessageLoop::current()->Run(); | 536 base::MessageLoop::current()->Run(); |
537 EXPECT_EQ(handle2, card_consumer2.handle()); | 537 EXPECT_EQ(handle2, card_consumer2.handle()); |
538 ASSERT_EQ(0U, card_consumer2.result().size()); | 538 ASSERT_EQ(0U, card_consumer2.result().size()); |
539 } | 539 } |
540 | 540 |
541 } // namespace autofill | 541 } // namespace autofill |
OLD | NEW |