Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1127)

Unified Diff: sync/api/attachments/fake_attachment_service.cc

Issue 272043002: Invoke AttachmentUploader and update AttachmentIds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698