| OLD | NEW | 
|---|
| 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 "content/browser/download/base_file.h" | 5 #include "content/browser/download/base_file.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" | 
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 225 | 225 | 
| 226 bool BaseFile::GetHash(std::string* hash) { | 226 bool BaseFile::GetHash(std::string* hash) { | 
| 227   DCHECK(!detached_); | 227   DCHECK(!detached_); | 
| 228   hash->assign(reinterpret_cast<const char*>(sha256_hash_), | 228   hash->assign(reinterpret_cast<const char*>(sha256_hash_), | 
| 229                sizeof(sha256_hash_)); | 229                sizeof(sha256_hash_)); | 
| 230   return (calculate_hash_ && !in_progress()); | 230   return (calculate_hash_ && !in_progress()); | 
| 231 } | 231 } | 
| 232 | 232 | 
| 233 std::string BaseFile::GetHashState() { | 233 std::string BaseFile::GetHashState() { | 
| 234   if (!calculate_hash_) | 234   if (!calculate_hash_) | 
| 235     return ""; | 235     return std::string(); | 
| 236 | 236 | 
| 237   Pickle hash_state; | 237   Pickle hash_state; | 
| 238   if (!secure_hash_->Serialize(&hash_state)) | 238   if (!secure_hash_->Serialize(&hash_state)) | 
| 239     return ""; | 239     return std::string(); | 
| 240 | 240 | 
| 241   return std::string(reinterpret_cast<const char*>(hash_state.data()), | 241   return std::string(reinterpret_cast<const char*>(hash_state.data()), | 
| 242                      hash_state.size()); | 242                      hash_state.size()); | 
| 243 } | 243 } | 
| 244 | 244 | 
| 245 // static | 245 // static | 
| 246 bool BaseFile::IsEmptyHash(const std::string& hash) { | 246 bool BaseFile::IsEmptyHash(const std::string& hash) { | 
| 247   return (hash.size() == kSha256HashLen && | 247   return (hash.size() == kSha256HashLen && | 
| 248           0 == memcmp(hash.data(), kEmptySha256Hash, sizeof(kSha256HashLen))); | 248           0 == memcmp(hash.data(), kEmptySha256Hash, sizeof(kSha256HashLen))); | 
| 249 } | 249 } | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 369     const char* operation, | 369     const char* operation, | 
| 370     int os_error, | 370     int os_error, | 
| 371     DownloadInterruptReason reason) { | 371     DownloadInterruptReason reason) { | 
| 372   bound_net_log_.AddEvent( | 372   bound_net_log_.AddEvent( | 
| 373       net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, | 373       net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, | 
| 374       base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); | 374       base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); | 
| 375   return reason; | 375   return reason; | 
| 376 } | 376 } | 
| 377 | 377 | 
| 378 }  // namespace content | 378 }  // namespace content | 
| OLD | NEW | 
|---|