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_impl.h" | 5 #include "sync/internal_api/public/attachments/attachment_service_impl.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/thread_task_runner_handle.h" | 11 #include "base/thread_task_runner_handle.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "sync/api/attachments/attachment.h" | 13 #include "sync/api/attachments/attachment.h" |
| 14 #include "sync/api/attachments/fake_attachment_store.h" |
14 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" | 15 #include "sync/internal_api/public/attachments/fake_attachment_downloader.h" |
15 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" | 16 #include "sync/internal_api/public/attachments/fake_attachment_uploader.h" |
16 | 17 |
17 namespace syncer { | 18 namespace syncer { |
18 | 19 |
19 // GetOrDownloadAttachments starts multiple parallel DownloadAttachment calls. | 20 // GetOrDownloadAttachments starts multiple parallel DownloadAttachment calls. |
20 // GetOrDownloadState tracks completion of these calls and posts callback for | 21 // GetOrDownloadState tracks completion of these calls and posts callback for |
21 // consumer once all attachments are either retrieved or reported unavailable. | 22 // consumer once all attachments are either retrieved or reported unavailable. |
22 class AttachmentServiceImpl::GetOrDownloadState | 23 class AttachmentServiceImpl::GetOrDownloadState |
23 : public base::RefCounted<GetOrDownloadState>, | 24 : public base::RefCounted<GetOrDownloadState>, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); | 138 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); |
138 } | 139 } |
139 | 140 |
140 AttachmentServiceImpl::~AttachmentServiceImpl() { | 141 AttachmentServiceImpl::~AttachmentServiceImpl() { |
141 DCHECK(CalledOnValidThread()); | 142 DCHECK(CalledOnValidThread()); |
142 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); | 143 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); |
143 } | 144 } |
144 | 145 |
145 // Static. | 146 // Static. |
146 scoped_ptr<syncer::AttachmentService> AttachmentServiceImpl::CreateForTest() { | 147 scoped_ptr<syncer::AttachmentService> AttachmentServiceImpl::CreateForTest() { |
147 scoped_refptr<syncer::AttachmentStore> attachment_store = | 148 scoped_refptr<syncer::AttachmentStore> attachment_store( |
148 AttachmentStore::CreateInMemoryStore(); | 149 new syncer::FakeAttachmentStore(base::ThreadTaskRunnerHandle::Get())); |
149 scoped_ptr<AttachmentUploader> attachment_uploader( | 150 scoped_ptr<AttachmentUploader> attachment_uploader( |
150 new FakeAttachmentUploader); | 151 new FakeAttachmentUploader); |
151 scoped_ptr<AttachmentDownloader> attachment_downloader( | 152 scoped_ptr<AttachmentDownloader> attachment_downloader( |
152 new FakeAttachmentDownloader()); | 153 new FakeAttachmentDownloader()); |
153 scoped_ptr<syncer::AttachmentService> attachment_service( | 154 scoped_ptr<syncer::AttachmentService> attachment_service( |
154 new syncer::AttachmentServiceImpl(attachment_store, | 155 new syncer::AttachmentServiceImpl(attachment_store, |
155 attachment_uploader.Pass(), | 156 attachment_uploader.Pass(), |
156 attachment_downloader.Pass(), | 157 attachment_downloader.Pass(), |
157 NULL, | 158 NULL, |
158 base::TimeDelta(), | 159 base::TimeDelta(), |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 base::Bind(&AttachmentServiceImpl::UploadDone, | 321 base::Bind(&AttachmentServiceImpl::UploadDone, |
321 weak_ptr_factory_.GetWeakPtr())); | 322 weak_ptr_factory_.GetWeakPtr())); |
322 } | 323 } |
323 } | 324 } |
324 | 325 |
325 void AttachmentServiceImpl::SetTimerForTest(scoped_ptr<base::Timer> timer) { | 326 void AttachmentServiceImpl::SetTimerForTest(scoped_ptr<base::Timer> timer) { |
326 upload_task_queue_->SetTimerForTest(timer.Pass()); | 327 upload_task_queue_->SetTimerForTest(timer.Pass()); |
327 } | 328 } |
328 | 329 |
329 } // namespace syncer | 330 } // namespace syncer |
OLD | NEW |