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

Unified Diff: components/sync_driver/generic_change_processor.cc

Issue 538403004: Revert of Replace AttachmentStore's StoreAttachments with UploadAttachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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: components/sync_driver/generic_change_processor.cc
diff --git a/components/sync_driver/generic_change_processor.cc b/components/sync_driver/generic_change_processor.cc
index ddf6b676eb45a697d3d8b0a12482197bb82ab9ef..c44ce72a1bd23d1fa5a8e377c50903bc9ef83a6a 100644
--- a/components/sync_driver/generic_change_processor.cc
+++ b/components/sync_driver/generic_change_processor.cc
@@ -85,11 +85,6 @@
attachment_service_proxy);
}
-const syncer::AttachmentId& AttachmentToAttachmentId(
- const syncer::Attachment& attachment) {
- return attachment.GetId();
-}
-
} // namespace
GenericChangeProcessor::GenericChangeProcessor(
@@ -107,8 +102,7 @@
attachment_service_weak_ptr_factory_(attachment_service_.get()),
attachment_service_proxy_(
base::MessageLoopProxy::current(),
- attachment_service_weak_ptr_factory_.GetWeakPtr()),
- weak_ptr_factory_(this) {
+ attachment_service_weak_ptr_factory_.GetWeakPtr()) {
DCHECK(CalledOnValidThread());
DCHECK(attachment_service_);
}
@@ -393,6 +387,25 @@
return syncer::SyncError();
}
+// A callback invoked on completion of AttachmentService::StoreAttachment.
+void IgnoreStoreResult(const syncer::AttachmentService::StoreResult&) {
+ // TODO(maniscalco): Here is where we're going to update the in-directory
+ // entry to indicate that the attachments have been successfully stored on
+ // disk. Why do we care? Because we might crash after persisting the
+ // directory to disk, but before we have persisted its attachments, leaving us
+ // with danging attachment ids. Having a flag that indicates we've stored the
+ // entry will allow us to detect and filter entries with dangling attachment
+ // ids (bug 368353).
+}
+
+void StoreAttachments(syncer::AttachmentService* attachment_service,
+ const syncer::AttachmentList& attachments) {
+ DCHECK(attachment_service);
+ syncer::AttachmentService::StoreCallback ignore_store_result =
+ base::Bind(&IgnoreStoreResult);
+ attachment_service->StoreAttachments(attachments, ignore_store_result);
+}
+
} // namespace
syncer::SyncError GenericChangeProcessor::ProcessSyncChanges(
@@ -452,7 +465,7 @@
}
if (!new_attachments.empty()) {
- StoreAndUploadAttachments(new_attachments);
+ StoreAttachments(attachment_service_.get(), new_attachments);
}
return syncer::SyncError();
@@ -698,40 +711,4 @@
return share_handle_;
}
-void GenericChangeProcessor::StoreAndUploadAttachments(
- const syncer::AttachmentList& attachments) {
- DCHECK(CalledOnValidThread());
- attachment_service_->GetStore()->Write(
- attachments,
- base::Bind(&GenericChangeProcessor::WriteAttachmentsDone,
- weak_ptr_factory_.GetWeakPtr(),
- attachments));
-}
-
-void GenericChangeProcessor::WriteAttachmentsDone(
- const syncer::AttachmentList& attachments,
- const syncer::AttachmentStore::Result& result) {
- DCHECK(CalledOnValidThread());
- if (result != syncer::AttachmentStore::SUCCESS) {
- // TODO(maniscalco): Deal with case where an error occurred (bug 361251).
- return;
- }
-
- // TODO(maniscalco): Here is where we're going to update the in-directory
- // entry to indicate that the attachments have been successfully stored on
- // disk. Why do we care? Because we might crash after persisting the
- // directory to disk, but before we have persisted its attachments, leaving us
- // with danging attachment ids. Having a flag that indicates we've stored the
- // entry will allow us to detect and filter entries with dangling attachment
- // ids (bug 368353).
-
- // Begin uploading the attachments now that they are safe on disk.
- syncer::AttachmentIdSet attachment_ids;
- std::transform(attachments.begin(),
- attachments.end(),
- std::inserter(attachment_ids, attachment_ids.end()),
- AttachmentToAttachmentId);
- attachment_service_->UploadAttachments(attachment_ids);
-}
-
} // namespace sync_driver
« no previous file with comments | « components/sync_driver/generic_change_processor.h ('k') | components/sync_driver/generic_change_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698