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

Unified Diff: sync/internal_api/attachments/attachment_downloader_impl.cc

Issue 982883002: [Sync] Add size and crc32c to AttachmentId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master. Created 5 years, 9 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/internal_api/attachments/attachment_downloader_impl.cc
diff --git a/sync/internal_api/attachments/attachment_downloader_impl.cc b/sync/internal_api/attachments/attachment_downloader_impl.cc
index 56a2c346d7cdb2492afb92fbeec23ef834285a77..f2e6a007aa0f1dc5dd921f4c37713b49081095d8 100644
--- a/sync/internal_api/attachments/attachment_downloader_impl.cc
+++ b/sync/internal_api/attachments/attachment_downloader_impl.cc
@@ -132,7 +132,7 @@ void AttachmentDownloaderImpl::OnGetTokenFailure(
DownloadState* download_state = *iter;
scoped_refptr<base::RefCountedString> null_attachment_data;
ReportResult(*download_state, DOWNLOAD_TRANSIENT_ERROR,
- null_attachment_data, 0);
+ null_attachment_data);
DCHECK(state_map_.find(download_state->attachment_url) != state_map_.end());
state_map_.erase(download_state->attachment_url);
}
@@ -175,7 +175,13 @@ void AttachmentDownloaderImpl::OnURLFetchComplete(
// locally calculated one will be stored and used for further checks.
result = DOWNLOAD_TRANSIENT_ERROR;
} else {
- result = DOWNLOAD_SUCCESS;
+ // If the id's crc32c doesn't match that of the downloaded attachment,
+ // then we're stuck and retrying is unlikely to help.
+ if (attachment_crc32c != download_state.attachment_id.GetCrc32c()) {
+ result = DOWNLOAD_UNSPECIFIED_ERROR;
+ } else {
+ result = DOWNLOAD_SUCCESS;
+ }
}
UMA_HISTOGRAM_BOOLEAN("Sync.Attachments.DownloadChecksumResult",
result == DOWNLOAD_SUCCESS);
@@ -193,7 +199,7 @@ void AttachmentDownloaderImpl::OnURLFetchComplete(
} else if (response_code == net::URLFetcher::RESPONSE_CODE_INVALID) {
result = DOWNLOAD_TRANSIENT_ERROR;
}
- ReportResult(download_state, result, attachment_data, attachment_crc32c);
+ ReportResult(download_state, result, attachment_data);
state_map_.erase(iter);
}
@@ -221,8 +227,7 @@ void AttachmentDownloaderImpl::RequestAccessToken(
void AttachmentDownloaderImpl::ReportResult(
const DownloadState& download_state,
const DownloadResult& result,
- const scoped_refptr<base::RefCountedString>& attachment_data,
- uint32_t attachment_crc32c) {
+ const scoped_refptr<base::RefCountedString>& attachment_data) {
std::vector<DownloadCallback>::const_iterator iter;
for (iter = download_state.user_callbacks.begin();
iter != download_state.user_callbacks.end();
@@ -230,7 +235,7 @@ void AttachmentDownloaderImpl::ReportResult(
scoped_ptr<Attachment> attachment;
if (result == DOWNLOAD_SUCCESS) {
attachment.reset(new Attachment(Attachment::CreateFromParts(
- download_state.attachment_id, attachment_data, attachment_crc32c)));
+ download_state.attachment_id, attachment_data)));
}
base::MessageLoop::current()->PostTask(
« no previous file with comments | « sync/engine/directory_update_handler_unittest.cc ('k') | sync/internal_api/attachments/attachment_downloader_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698