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

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

Issue 1088593005: drive: Do not rely on argument-dependent lookup when calling MD5DigestToBase16(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // End of file. 161 // End of file.
162 break; 162 break;
163 } 163 }
164 164
165 offset += result; 165 offset += result;
166 base::MD5Update(&context, base::StringPiece(buffer.get(), result)); 166 base::MD5Update(&context, base::StringPiece(buffer.get(), result));
167 } 167 }
168 168
169 base::MD5Digest digest; 169 base::MD5Digest digest;
170 base::MD5Final(&digest, &context); 170 base::MD5Final(&digest, &context);
171 return MD5DigestToBase16(digest); 171 return base::MD5DigestToBase16(digest);
172 } 172 }
173 173
174 FileStreamMd5Digester::FileStreamMd5Digester() 174 FileStreamMd5Digester::FileStreamMd5Digester()
175 : buffer_(new net::IOBuffer(kMd5DigestBufferSize)) { 175 : buffer_(new net::IOBuffer(kMd5DigestBufferSize)) {
176 } 176 }
177 177
178 FileStreamMd5Digester::~FileStreamMd5Digester() { 178 FileStreamMd5Digester::~FileStreamMd5Digester() {
179 } 179 }
180 180
181 void FileStreamMd5Digester::GetMd5Digest( 181 void FileStreamMd5Digester::GetMd5Digest(
(...skipping 18 matching lines...) Expand all
200 void FileStreamMd5Digester::OnChunkRead(const ResultCallback& callback, 200 void FileStreamMd5Digester::OnChunkRead(const ResultCallback& callback,
201 int bytes_read) { 201 int bytes_read) {
202 if (bytes_read < 0) { 202 if (bytes_read < 0) {
203 // Error - just return empty string. 203 // Error - just return empty string.
204 callback.Run(""); 204 callback.Run("");
205 return; 205 return;
206 } else if (bytes_read == 0) { 206 } else if (bytes_read == 0) {
207 // EOF. 207 // EOF.
208 base::MD5Digest digest; 208 base::MD5Digest digest;
209 base::MD5Final(&digest, &md5_context_); 209 base::MD5Final(&digest, &md5_context_);
210 std::string result = MD5DigestToBase16(digest); 210 std::string result = base::MD5DigestToBase16(digest);
211 callback.Run(result); 211 callback.Run(result);
212 return; 212 return;
213 } 213 }
214 214
215 // Read data and digest it. 215 // Read data and digest it.
216 base::MD5Update(&md5_context_, 216 base::MD5Update(&md5_context_,
217 base::StringPiece(buffer_->data(), bytes_read)); 217 base::StringPiece(buffer_->data(), bytes_read));
218 218
219 // Kick off the next read. 219 // Kick off the next read.
220 ReadNextChunk(callback); 220 ReadNextChunk(callback);
(...skipping 19 matching lines...) Expand all
240 const std::string extension = base::FilePath(path.Extension()).AsUTF8Unsafe(); 240 const std::string extension = base::FilePath(path.Extension()).AsUTF8Unsafe();
241 for (size_t i = 0; i < arraysize(kHostedDocumentKinds); ++i) { 241 for (size_t i = 0; i < arraysize(kHostedDocumentKinds); ++i) {
242 if (extension == kHostedDocumentKinds[i].extension) 242 if (extension == kHostedDocumentKinds[i].extension)
243 return true; 243 return true;
244 } 244 }
245 return extension == kUnknownHostedDocumentExtension; 245 return extension == kUnknownHostedDocumentExtension;
246 } 246 }
247 247
248 } // namespace util 248 } // namespace util
249 } // namespace drive 249 } // 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