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

Unified Diff: chrome/browser/drive/drive_api_util.cc

Issue 955313003: Files.app: Fix a bug in content hash computation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2311
Patch Set: Created 5 years, 10 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 | « chrome/browser/drive/drive_api_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/drive/drive_api_util.cc
diff --git a/chrome/browser/drive/drive_api_util.cc b/chrome/browser/drive/drive_api_util.cc
index 8d153877411a4b0b66f09fbd95d3b4b026d49bcb..5bacfd79aa5c5cfa9d1769d9bd7d6ab8dc3ae816 100644
--- a/chrome/browser/drive/drive_api_util.cc
+++ b/chrome/browser/drive/drive_api_util.cc
@@ -177,40 +177,42 @@ void FileStreamMd5Digester::GetMd5Digest(
scoped_ptr<storage::FileStreamReader> stream_reader,
const ResultCallback& callback) {
reader_ = stream_reader.Pass();
- callback_ = callback;
base::MD5Init(&md5_context_);
// Start the read/hash.
- ReadNextChunk();
+ ReadNextChunk(callback);
}
-void FileStreamMd5Digester::ReadNextChunk() {
- const int result = reader_->Read(
- buffer_.get(), kMd5DigestBufferSize,
- base::Bind(&FileStreamMd5Digester::OnChunkRead, base::Unretained(this)));
+void FileStreamMd5Digester::ReadNextChunk(const ResultCallback& callback) {
+ const int result =
+ reader_->Read(buffer_.get(), kMd5DigestBufferSize,
+ base::Bind(&FileStreamMd5Digester::OnChunkRead,
+ base::Unretained(this), callback));
if (result != net::ERR_IO_PENDING)
- OnChunkRead(result);
+ OnChunkRead(callback, result);
}
-void FileStreamMd5Digester::OnChunkRead(int bytesRead) {
- if (bytesRead < 0) {
+void FileStreamMd5Digester::OnChunkRead(const ResultCallback& callback,
+ int bytes_read) {
+ if (bytes_read < 0) {
// Error - just return empty string.
- callback_.Run("");
+ callback.Run("");
return;
- } else if (bytesRead == 0) {
+ } else if (bytes_read == 0) {
// EOF.
base::MD5Digest digest;
base::MD5Final(&digest, &md5_context_);
std::string result = MD5DigestToBase16(digest);
- callback_.Run(result);
+ callback.Run(result);
return;
}
// Read data and digest it.
- base::MD5Update(&md5_context_, base::StringPiece(buffer_->data(), bytesRead));
+ base::MD5Update(&md5_context_,
+ base::StringPiece(buffer_->data(), bytes_read));
// Kick off the next read.
- ReadNextChunk();
+ ReadNextChunk(callback);
}
std::string GetHostedDocumentExtension(const std::string& mime_type) {
« no previous file with comments | « chrome/browser/drive/drive_api_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698