Chromium Code Reviews| Index: sync/internal_api/attachments/attachment_uploader_impl.cc |
| diff --git a/sync/internal_api/attachments/attachment_uploader_impl.cc b/sync/internal_api/attachments/attachment_uploader_impl.cc |
| index 7333596564fb2c3a86d6f2b849cd5f365360ab15..71f73bf0336a7803c5b15c95648b60586669ba3f 100644 |
| --- a/sync/internal_api/attachments/attachment_uploader_impl.cc |
| +++ b/sync/internal_api/attachments/attachment_uploader_impl.cc |
| @@ -20,7 +20,6 @@ |
| #include "net/url_request/url_fetcher_delegate.h" |
| #include "sync/api/attachments/attachment.h" |
| #include "sync/protocol/sync.pb.h" |
| -#include "third_party/leveldatabase/src/util/crc32c.h" |
| namespace { |
| @@ -207,12 +206,9 @@ void AttachmentUploaderImpl::UploadState::OnGetTokenSuccess( |
| fetcher_->SetUploadData(kContentType, upload_content); |
| const std::string auth_header("Authorization: Bearer " + access_token_); |
| fetcher_->AddExtraRequestHeader(auth_header); |
| - // TODO(maniscalco): Consider computing the hash once and storing the value as |
| - // a new field in the Attachment object to avoid recomputing when an upload |
| - // fails and is retried (bug 417794). |
| + uint32_t crc = attachment_.GetCrc32c(); |
|
maniscalco
2014/11/11 00:44:54
Can be made const. Also, how about renaming to cr
pavely
2014/11/11 22:27:15
Done.
|
| fetcher_->AddExtraRequestHeader(base::StringPrintf( |
| - "X-Goog-Hash: crc32c=%s", |
| - ComputeCrc32cHash(memory->front_as<char>(), memory->size()).c_str())); |
| + "X-Goog-Hash: crc32c=%s", FormatCrc32cHash(crc).c_str())); |
| fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
| net::LOAD_DO_NOT_SEND_COOKIES | |
| net::LOAD_DISABLE_CACHE); |
| @@ -345,10 +341,8 @@ void AttachmentUploaderImpl::OnUploadStateStopped(const UniqueId& unique_id) { |
| } |
| } |
| -std::string AttachmentUploaderImpl::ComputeCrc32cHash(const char* data, |
| - size_t size) { |
| - const uint32_t crc32c_big_endian = |
| - base::HostToNet32(leveldb::crc32c::Value(data, size)); |
| +std::string AttachmentUploaderImpl::FormatCrc32cHash(uint32_t crc) { |
|
maniscalco
2014/11/11 00:44:54
crc -> crc32c?
pavely
2014/11/11 22:27:15
Done.
|
| + const uint32_t crc32c_big_endian = base::HostToNet32(crc); |
| const base::StringPiece raw(reinterpret_cast<const char*>(&crc32c_big_endian), |
| sizeof(crc32c_big_endian)); |
| std::string encoded; |