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

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

Issue 272043002: Invoke AttachmentUploader and update AttachmentIds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize through SyncApiComponentFactory 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/attachment_service_impl.cc
diff --git a/sync/api/attachments/attachment_service_impl.cc b/sync/api/attachments/attachment_service_impl.cc
index 75578873dbe3aeab58a3dffee4f674ac390fb2f1..7a3d90ca5daa68fcf248e6bed9094f2038c44b86 100644
--- a/sync/api/attachments/attachment_service_impl.cc
+++ b/sync/api/attachments/attachment_service_impl.cc
@@ -14,9 +14,11 @@ namespace syncer {
AttachmentServiceImpl::AttachmentServiceImpl(
scoped_ptr<AttachmentStore> attachment_store,
- scoped_ptr<AttachmentUploader> attachment_uploader)
+ scoped_ptr<AttachmentUploader> attachment_uploader,
+ Delegate* delegate)
: attachment_store_(attachment_store.Pass()),
attachment_uploader_(attachment_uploader.Pass()),
+ delegate_(delegate),
weak_ptr_factory_(this) {
DCHECK(CalledOnValidThread());
DCHECK(attachment_store_);
@@ -34,8 +36,8 @@ scoped_ptr<syncer::AttachmentService> AttachmentServiceImpl::CreateForTest() {
scoped_ptr<AttachmentUploader> attachment_uploader(
new FakeAttachmentUploader);
scoped_ptr<syncer::AttachmentService> attachment_service(
- new syncer::AttachmentServiceImpl(attachment_store.Pass(),
- attachment_uploader.Pass()));
+ new syncer::AttachmentServiceImpl(
+ attachment_store.Pass(), attachment_uploader.Pass(), NULL));
return attachment_service.Pass();
}
@@ -66,8 +68,14 @@ void AttachmentServiceImpl::StoreAttachments(const AttachmentList& attachments,
base::Bind(&AttachmentServiceImpl::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(&AttachmentServiceImpl::UploadDone,
+ weak_ptr_factory_.GetWeakPtr()));
+ }
}
void AttachmentServiceImpl::OnSyncDataDelete(const SyncData& sync_data) {
@@ -124,4 +132,14 @@ void AttachmentServiceImpl::WriteDone(const StoreCallback& callback,
base::Bind(callback, store_result));
}
+void AttachmentServiceImpl::UploadDone(
+ const AttachmentUploader::UploadResult& result,
+ const AttachmentId& attachment_id) {
+ DCHECK(delegate_);
maniscalco 2014/05/15 20:09:28 Based on our last talk, I was thinking delegate_ w
pavely 2014/05/16 00:19:10 I made this change but lost it between revisions 5
+ // TODO(pavely): crbug/372622: Deal with UploadAttachment failures.
+ if (result != AttachmentUploader::UPLOAD_SUCCESS)
+ return;
+ delegate_->OnAttachmentUploaded(attachment_id);
+}
+
} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698