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

Side by Side Diff: chrome/browser/drive/drive_api_util.cc

Issue 905723004: Files.app: Rename a variable in drive_api_util.cc for more sanity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/drive/drive_api_util.h" 5 #include "chrome/browser/drive/drive_api_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 185 }
186 186
187 void FileStreamMd5Digester::ReadNextChunk() { 187 void FileStreamMd5Digester::ReadNextChunk() {
188 const int result = reader_->Read( 188 const int result = reader_->Read(
189 buffer_.get(), kMd5DigestBufferSize, 189 buffer_.get(), kMd5DigestBufferSize,
190 base::Bind(&FileStreamMd5Digester::OnChunkRead, base::Unretained(this))); 190 base::Bind(&FileStreamMd5Digester::OnChunkRead, base::Unretained(this)));
191 if (result != net::ERR_IO_PENDING) 191 if (result != net::ERR_IO_PENDING)
192 OnChunkRead(result); 192 OnChunkRead(result);
193 } 193 }
194 194
195 void FileStreamMd5Digester::OnChunkRead(int result) { 195 void FileStreamMd5Digester::OnChunkRead(int bytesRead) {
mtomasz 2015/02/25 02:36:30 nit: bytes_read.
196 if (result < 0) { 196 if (bytesRead < 0) {
197 // Error - just return empty string. 197 // Error - just return empty string.
198 callback_.Run(""); 198 callback_.Run("");
199 return; 199 return;
200 } else if (result == 0) { 200 } else if (bytesRead == 0) {
201 // EOF. 201 // EOF.
202 base::MD5Digest digest; 202 base::MD5Digest digest;
203 base::MD5Final(&digest, &md5_context_); 203 base::MD5Final(&digest, &md5_context_);
204 std::string result = MD5DigestToBase16(digest); 204 std::string result = MD5DigestToBase16(digest);
205 callback_.Run(result); 205 callback_.Run(result);
206 return; 206 return;
207 } 207 }
208 208
209 // Read data and digest it. 209 // Read data and digest it.
210 base::MD5Update(&md5_context_, base::StringPiece(buffer_->data(), result)); 210 base::MD5Update(&md5_context_, base::StringPiece(buffer_->data(), bytesRead));
211 211
212 // Kick off the next read. 212 // Kick off the next read.
213 ReadNextChunk(); 213 ReadNextChunk();
214 } 214 }
215 215
216 std::string GetHostedDocumentExtension(const std::string& mime_type) { 216 std::string GetHostedDocumentExtension(const std::string& mime_type) {
217 for (size_t i = 0; i < arraysize(kHostedDocumentKinds); ++i) { 217 for (size_t i = 0; i < arraysize(kHostedDocumentKinds); ++i) {
218 if (mime_type == kHostedDocumentKinds[i].mime_type) 218 if (mime_type == kHostedDocumentKinds[i].mime_type)
219 return kHostedDocumentKinds[i].extension; 219 return kHostedDocumentKinds[i].extension;
220 } 220 }
(...skipping 12 matching lines...) Expand all
233 const std::string extension = base::FilePath(path.Extension()).AsUTF8Unsafe(); 233 const std::string extension = base::FilePath(path.Extension()).AsUTF8Unsafe();
234 for (size_t i = 0; i < arraysize(kHostedDocumentKinds); ++i) { 234 for (size_t i = 0; i < arraysize(kHostedDocumentKinds); ++i) {
235 if (extension == kHostedDocumentKinds[i].extension) 235 if (extension == kHostedDocumentKinds[i].extension)
236 return true; 236 return true;
237 } 237 }
238 return extension == kUnknownHostedDocumentExtension; 238 return extension == kUnknownHostedDocumentExtension;
239 } 239 }
240 240
241 } // namespace util 241 } // namespace util
242 } // namespace drive 242 } // namespace drive
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698