Index: sync/api/attachments/fake_attachment_service.cc |
diff --git a/sync/api/attachments/fake_attachment_service.cc b/sync/api/attachments/fake_attachment_service.cc |
index f86f380f01d658e91a8354f3ffe6c504fbad4db0..0b206bf926f5192578caf5fb67edd24280b77128 100644 |
--- a/sync/api/attachments/fake_attachment_service.cc |
+++ b/sync/api/attachments/fake_attachment_service.cc |
@@ -39,6 +39,10 @@ scoped_ptr<syncer::AttachmentService> FakeAttachmentService::CreateForTest() { |
return attachment_service.Pass(); |
} |
+void FakeAttachmentService::SetDelegate(Delegate* delegate) { |
+ delegate_ = delegate; |
+} |
+ |
void FakeAttachmentService::GetOrDownloadAttachments( |
const AttachmentIdList& attachment_ids, |
const GetOrDownloadCallback& callback) { |
@@ -66,8 +70,14 @@ void FakeAttachmentService::StoreAttachments(const AttachmentList& attachments, |
base::Bind(&FakeAttachmentService::WriteDone, |
weak_ptr_factory_.GetWeakPtr(), |
callback)); |
- // TODO(maniscalco): Ensure the linked attachments are schedule for upload to |
- // the server (bug 356351). |
+ for (AttachmentList::const_iterator iter = attachments.begin(); |
+ iter != attachments.end(); |
+ ++iter) { |
+ attachment_uploader_->UploadAttachment( |
+ *iter, |
+ base::Bind(&FakeAttachmentService::UploadDone, |
+ weak_ptr_factory_.GetWeakPtr())); |
+ } |
} |
void FakeAttachmentService::OnSyncDataDelete(const SyncData& sync_data) { |
@@ -124,4 +134,13 @@ void FakeAttachmentService::WriteDone(const StoreCallback& callback, |
base::Bind(callback, store_result)); |
} |
+void FakeAttachmentService::UploadDone( |
+ const AttachmentUploader::UploadResult& result, |
+ const AttachmentId& attachment_id) { |
+ DCHECK(delegate_); |
maniscalco
2014/05/09 18:12:11
I thought having a delegate_ was optional, no?
pavely
2014/05/13 23:06:44
No, having delegate is not optional, I would rathe
|
+ if (result != AttachmentUploader::UPLOAD_SUCCESS) |
maniscalco
2014/05/09 18:12:11
Please add a TODO for dealing with error results.
pavely
2014/05/13 23:06:44
Done.
|
+ return; |
+ delegate_->OnAttachmentUploaded(attachment_id); |
+} |
+ |
} // namespace syncer |