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

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: Fix Android build 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
« no previous file with comments | « sync/api/attachments/attachment_service_impl.h ('k') | sync/internal_api/public/write_transaction.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a77d05243122376b56d6598b468abd86bc47aa1b 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,15 @@ void AttachmentServiceImpl::WriteDone(const StoreCallback& callback,
base::Bind(callback, store_result));
}
+void AttachmentServiceImpl::UploadDone(
+ const AttachmentUploader::UploadResult& result,
+ const AttachmentId& attachment_id) {
+ // TODO(pavely): crbug/372622: Deal with UploadAttachment failures.
+ if (result != AttachmentUploader::UPLOAD_SUCCESS)
+ return;
+ if (delegate_) {
+ delegate_->OnAttachmentUploaded(attachment_id);
+ }
+}
+
} // namespace syncer
« no previous file with comments | « sync/api/attachments/attachment_service_impl.h ('k') | sync/internal_api/public/write_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698