| 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> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/files/file.h" | 10 #include "base/files/file.h" |
| 9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 10 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 11 #include "base/logging.h" | 13 #include "base/logging.h" |
| 12 #include "base/pickle.h" | 14 #include "base/pickle.h" |
| 13 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 14 #include "base/threading/thread_restrictions.h" | 16 #include "base/threading/thread_restrictions.h" |
| 15 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 16 #include "content/browser/download/download_interrupt_reasons_impl.h" | 18 #include "content/browser/download/download_interrupt_reasons_impl.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 30 const GURL& source_url, | 32 const GURL& source_url, |
| 31 const GURL& referrer_url, | 33 const GURL& referrer_url, |
| 32 int64_t received_bytes, | 34 int64_t received_bytes, |
| 33 bool calculate_hash, | 35 bool calculate_hash, |
| 34 const std::string& hash_state_bytes, | 36 const std::string& hash_state_bytes, |
| 35 base::File file, | 37 base::File file, |
| 36 const net::BoundNetLog& bound_net_log) | 38 const net::BoundNetLog& bound_net_log) |
| 37 : full_path_(full_path), | 39 : full_path_(full_path), |
| 38 source_url_(source_url), | 40 source_url_(source_url), |
| 39 referrer_url_(referrer_url), | 41 referrer_url_(referrer_url), |
| 40 file_(file.Pass()), | 42 file_(std::move(file)), |
| 41 bytes_so_far_(received_bytes), | 43 bytes_so_far_(received_bytes), |
| 42 start_tick_(base::TimeTicks::Now()), | 44 start_tick_(base::TimeTicks::Now()), |
| 43 calculate_hash_(calculate_hash), | 45 calculate_hash_(calculate_hash), |
| 44 detached_(false), | 46 detached_(false), |
| 45 bound_net_log_(bound_net_log) { | 47 bound_net_log_(bound_net_log) { |
| 46 memcpy(sha256_hash_, kEmptySha256Hash, crypto::kSHA256Length); | 48 memcpy(sha256_hash_, kEmptySha256Hash, crypto::kSHA256Length); |
| 47 if (calculate_hash_) { | 49 if (calculate_hash_) { |
| 48 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256)); | 50 secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256)); |
| 49 if ((bytes_so_far_ > 0) && // Not starting at the beginning. | 51 if ((bytes_so_far_ > 0) && // Not starting at the beginning. |
| 50 (!IsEmptyHash(hash_state_bytes))) { | 52 (!IsEmptyHash(hash_state_bytes))) { |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 const char* operation, | 343 const char* operation, |
| 342 int os_error, | 344 int os_error, |
| 343 DownloadInterruptReason reason) { | 345 DownloadInterruptReason reason) { |
| 344 bound_net_log_.AddEvent( | 346 bound_net_log_.AddEvent( |
| 345 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, | 347 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, |
| 346 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); | 348 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); |
| 347 return reason; | 349 return reason; |
| 348 } | 350 } |
| 349 | 351 |
| 350 } // namespace content | 352 } // namespace content |
| OLD | NEW |