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/fake_attachment_service.h" | 5 #include "sync/api/attachments/fake_attachment_service.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 "sync/api/attachments/attachment.h" | 9 #include "sync/api/attachments/attachment.h" |
10 #include "sync/api/attachments/fake_attachment_store.h" | 10 #include "sync/api/attachments/fake_attachment_store.h" |
| 11 #include "sync/api/attachments/fake_attachment_uploader.h" |
11 | 12 |
12 namespace syncer { | 13 namespace syncer { |
13 | 14 |
14 FakeAttachmentService::FakeAttachmentService( | 15 FakeAttachmentService::FakeAttachmentService( |
15 scoped_ptr<AttachmentStore> attachment_store) | 16 scoped_ptr<AttachmentStore> attachment_store, |
16 : attachment_store_(attachment_store.Pass()), weak_ptr_factory_(this) { | 17 scoped_ptr<AttachmentUploader> attachment_uploader) |
| 18 : attachment_store_(attachment_store.Pass()), |
| 19 attachment_uploader_(attachment_uploader.Pass()), |
| 20 weak_ptr_factory_(this) { |
17 DCHECK(CalledOnValidThread()); | 21 DCHECK(CalledOnValidThread()); |
18 DCHECK(attachment_store_); | 22 DCHECK(attachment_store_); |
| 23 DCHECK(attachment_uploader_); |
19 } | 24 } |
20 | 25 |
21 FakeAttachmentService::~FakeAttachmentService() { | 26 FakeAttachmentService::~FakeAttachmentService() { |
22 DCHECK(CalledOnValidThread()); | 27 DCHECK(CalledOnValidThread()); |
23 } | 28 } |
24 | 29 |
25 // Static. | 30 // Static. |
26 scoped_ptr<syncer::AttachmentService> FakeAttachmentService::CreateForTest() { | 31 scoped_ptr<syncer::AttachmentService> FakeAttachmentService::CreateForTest() { |
27 scoped_ptr<syncer::AttachmentStore> attachment_store( | 32 scoped_ptr<syncer::AttachmentStore> attachment_store( |
28 new syncer::FakeAttachmentStore(base::MessageLoopProxy::current())); | 33 new syncer::FakeAttachmentStore(base::MessageLoopProxy::current())); |
| 34 scoped_ptr<AttachmentUploader> attachment_uploader( |
| 35 new FakeAttachmentUploader); |
29 scoped_ptr<syncer::AttachmentService> attachment_service( | 36 scoped_ptr<syncer::AttachmentService> attachment_service( |
30 new syncer::FakeAttachmentService(attachment_store.Pass())); | 37 new syncer::FakeAttachmentService(attachment_store.Pass(), |
| 38 attachment_uploader.Pass())); |
31 return attachment_service.Pass(); | 39 return attachment_service.Pass(); |
32 } | 40 } |
33 | 41 |
34 void FakeAttachmentService::GetOrDownloadAttachments( | 42 void FakeAttachmentService::GetOrDownloadAttachments( |
35 const AttachmentIdList& attachment_ids, | 43 const AttachmentIdList& attachment_ids, |
36 const GetOrDownloadCallback& callback) { | 44 const GetOrDownloadCallback& callback) { |
37 DCHECK(CalledOnValidThread()); | 45 DCHECK(CalledOnValidThread()); |
38 attachment_store_->Read(attachment_ids, | 46 attachment_store_->Read(attachment_ids, |
39 base::Bind(&FakeAttachmentService::ReadDone, | 47 base::Bind(&FakeAttachmentService::ReadDone, |
40 weak_ptr_factory_.GetWeakPtr(), | 48 weak_ptr_factory_.GetWeakPtr(), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 AttachmentService::STORE_UNSPECIFIED_ERROR; | 118 AttachmentService::STORE_UNSPECIFIED_ERROR; |
111 if (result == AttachmentStore::SUCCESS) { | 119 if (result == AttachmentStore::SUCCESS) { |
112 store_result = AttachmentService::STORE_SUCCESS; | 120 store_result = AttachmentService::STORE_SUCCESS; |
113 } | 121 } |
114 // TODO(maniscalco): Deal with case where an error occurred (bug 361251). | 122 // TODO(maniscalco): Deal with case where an error occurred (bug 361251). |
115 base::MessageLoop::current()->PostTask(FROM_HERE, | 123 base::MessageLoop::current()->PostTask(FROM_HERE, |
116 base::Bind(callback, store_result)); | 124 base::Bind(callback, store_result)); |
117 } | 125 } |
118 | 126 |
119 } // namespace syncer | 127 } // namespace syncer |
OLD | NEW |