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/api/attachments/attachment_service_impl.h" | 5 #include "sync/api/attachments/attachment_service_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/thread_task_runner_handle.h" |
9 #include "sync/api/attachments/attachment.h" | 10 #include "sync/api/attachments/attachment.h" |
10 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" | 11 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" |
11 #include "sync/internal_api/public/attachments/fake_attachment_store.h" | 12 #include "sync/internal_api/public/attachments/fake_attachment_store.h" |
12 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" | 13 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" |
13 | 14 |
14 namespace syncer { | 15 namespace syncer { |
15 | 16 |
16 // GetOrDownloadAttachments starts multiple parallel DownloadAttachment calls. | 17 // GetOrDownloadAttachments starts multiple parallel DownloadAttachment calls. |
17 // GetOrDownloadState tracks completion of these calls and posts callback for | 18 // GetOrDownloadState tracks completion of these calls and posts callback for |
18 // consumer once all attachments are either retrieved or reported unavailable. | 19 // consumer once all attachments are either retrieved or reported unavailable. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 DCHECK(attachment_store_); | 121 DCHECK(attachment_store_); |
121 } | 122 } |
122 | 123 |
123 AttachmentServiceImpl::~AttachmentServiceImpl() { | 124 AttachmentServiceImpl::~AttachmentServiceImpl() { |
124 DCHECK(CalledOnValidThread()); | 125 DCHECK(CalledOnValidThread()); |
125 } | 126 } |
126 | 127 |
127 // Static. | 128 // Static. |
128 scoped_ptr<syncer::AttachmentService> AttachmentServiceImpl::CreateForTest() { | 129 scoped_ptr<syncer::AttachmentService> AttachmentServiceImpl::CreateForTest() { |
129 scoped_ptr<syncer::AttachmentStore> attachment_store( | 130 scoped_ptr<syncer::AttachmentStore> attachment_store( |
130 new syncer::FakeAttachmentStore(base::MessageLoopProxy::current())); | 131 new syncer::FakeAttachmentStore(base::ThreadTaskRunnerHandle::Get())); |
131 scoped_ptr<AttachmentUploader> attachment_uploader( | 132 scoped_ptr<AttachmentUploader> attachment_uploader( |
132 new FakeAttachmentUploader); | 133 new FakeAttachmentUploader); |
133 scoped_ptr<AttachmentDownloader> attachment_downloader( | 134 scoped_ptr<AttachmentDownloader> attachment_downloader( |
134 new FakeAttachmentDownloader()); | 135 new FakeAttachmentDownloader()); |
135 scoped_ptr<syncer::AttachmentService> attachment_service( | 136 scoped_ptr<syncer::AttachmentService> attachment_service( |
136 new syncer::AttachmentServiceImpl(attachment_store.Pass(), | 137 new syncer::AttachmentServiceImpl(attachment_store.Pass(), |
137 attachment_uploader.Pass(), | 138 attachment_uploader.Pass(), |
138 attachment_downloader.Pass(), | 139 attachment_downloader.Pass(), |
139 NULL)); | 140 NULL)); |
140 return attachment_service.Pass(); | 141 return attachment_service.Pass(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 const AttachmentDownloader::DownloadResult& result, | 255 const AttachmentDownloader::DownloadResult& result, |
255 scoped_ptr<Attachment> attachment) { | 256 scoped_ptr<Attachment> attachment) { |
256 if (result == AttachmentDownloader::DOWNLOAD_SUCCESS) { | 257 if (result == AttachmentDownloader::DOWNLOAD_SUCCESS) { |
257 state->AddAttachment(*attachment.get()); | 258 state->AddAttachment(*attachment.get()); |
258 } else { | 259 } else { |
259 state->AddUnavailableAttachmentId(attachment_id); | 260 state->AddUnavailableAttachmentId(attachment_id); |
260 } | 261 } |
261 } | 262 } |
262 | 263 |
263 } // namespace syncer | 264 } // namespace syncer |
OLD | NEW |