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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 " full_path_ = \"%" PRFilePath | 201 " full_path_ = \"%" PRFilePath |
202 "\"" | 202 "\"" |
203 " bytes_so_far_ = %" PRId64 " detached_ = %c }", | 203 " bytes_so_far_ = %" PRId64 " detached_ = %c }", |
204 full_path_.value().c_str(), | 204 full_path_.value().c_str(), |
205 bytes_so_far_, | 205 bytes_so_far_, |
206 detached_ ? 'T' : 'F'); | 206 detached_ ? 'T' : 'F'); |
207 } | 207 } |
208 | 208 |
209 DownloadInterruptReason BaseFile::CalculatePartialHash( | 209 DownloadInterruptReason BaseFile::CalculatePartialHash( |
210 const std::string& hash_to_expect) { | 210 const std::string& hash_to_expect) { |
211 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 211 secure_hash_ = crypto::SecureHash::Create(crypto::SecureHash::SHA256); |
212 | 212 |
213 if (bytes_so_far_ == 0) | 213 if (bytes_so_far_ == 0) |
214 return DOWNLOAD_INTERRUPT_REASON_NONE; | 214 return DOWNLOAD_INTERRUPT_REASON_NONE; |
215 | 215 |
216 if (file_.Seek(base::File::FROM_BEGIN, 0) != 0) | 216 if (file_.Seek(base::File::FROM_BEGIN, 0) != 0) |
217 return LogSystemError("Seek partial file", | 217 return LogSystemError("Seek partial file", |
218 logging::GetLastSystemErrorCode()); | 218 logging::GetLastSystemErrorCode()); |
219 | 219 |
220 const size_t kMinBufferSize = secure_hash_->GetHashLength(); | 220 const size_t kMinBufferSize = secure_hash_->GetHashLength(); |
221 const size_t kMaxBufferSize = 1024 * 512; | 221 const size_t kMaxBufferSize = 1024 * 512; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 DVLOG(1) << __FUNCTION__ << "() operation:" << operation | 372 DVLOG(1) << __FUNCTION__ << "() operation:" << operation |
373 << " os_error:" << os_error | 373 << " os_error:" << os_error |
374 << " reason:" << DownloadInterruptReasonToString(reason); | 374 << " reason:" << DownloadInterruptReasonToString(reason); |
375 bound_net_log_.AddEvent( | 375 bound_net_log_.AddEvent( |
376 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, | 376 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, |
377 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); | 377 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); |
378 return reason; | 378 return reason; |
379 } | 379 } |
380 | 380 |
381 } // namespace content | 381 } // namespace content |
OLD | NEW |