OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/internal_api/public/attachments/attachment_service_proxy.h" | 5 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 | 107 |
108 // a GetOrDownloadCallback | 108 // a GetOrDownloadCallback |
109 void IncrementGetOrDownload(const AttachmentService::GetOrDownloadResult&, | 109 void IncrementGetOrDownload(const AttachmentService::GetOrDownloadResult&, |
110 std::unique_ptr<AttachmentMap>) { | 110 std::unique_ptr<AttachmentMap>) { |
111 CalledOnValidThread(); | 111 CalledOnValidThread(); |
112 ++count_callback_get_or_download; | 112 ++count_callback_get_or_download; |
113 } | 113 } |
114 | 114 |
115 void WaitForStubThread() { | 115 void WaitForStubThread() { |
116 base::WaitableEvent done(false, false); | 116 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 117 base::WaitableEvent::InitialState::NOT_SIGNALED); |
117 stub_thread->message_loop()->PostTask( | 118 stub_thread->message_loop()->PostTask( |
118 FROM_HERE, | 119 FROM_HERE, |
119 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | 120 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
120 done.Wait(); | 121 done.Wait(); |
121 } | 122 } |
122 | 123 |
123 base::MessageLoop loop; | 124 base::MessageLoop loop; |
124 std::unique_ptr<base::Thread> stub_thread; | 125 std::unique_ptr<base::Thread> stub_thread; |
125 std::unique_ptr<StubAttachmentService> stub; | 126 std::unique_ptr<StubAttachmentService> stub; |
126 std::unique_ptr<AttachmentServiceProxy> proxy; | 127 std::unique_ptr<AttachmentServiceProxy> proxy; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // Now that the wrapped object has been destroyed, call again and see that we | 171 // Now that the wrapped object has been destroyed, call again and see that we |
171 // don't crash and the count remains the same. | 172 // don't crash and the count remains the same. |
172 proxy->GetOrDownloadAttachments(AttachmentIdList(), callback_get_or_download); | 173 proxy->GetOrDownloadAttachments(AttachmentIdList(), callback_get_or_download); |
173 WaitForStubThread(); | 174 WaitForStubThread(); |
174 WaitForStubThread(); | 175 WaitForStubThread(); |
175 base::RunLoop().RunUntilIdle(); | 176 base::RunLoop().RunUntilIdle(); |
176 EXPECT_EQ(1, count_callback_get_or_download); | 177 EXPECT_EQ(1, count_callback_get_or_download); |
177 } | 178 } |
178 | 179 |
179 } // namespace syncer | 180 } // namespace syncer |
OLD | NEW |