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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 net_log_.BeginEvent(net::NetLogEventType::DOWNLOAD_FILE_WRITTEN); | 103 net_log_.BeginEvent(net::NetLogEventType::DOWNLOAD_FILE_WRITTEN); |
104 int write_result = file_.Write(offset, data, data_len); | 104 int write_result = file_.Write(offset, data, data_len); |
105 DCHECK_NE(0, write_result); | 105 DCHECK_NE(0, write_result); |
106 | 106 |
107 // Report errors on file writes. | 107 // Report errors on file writes. |
108 if (write_result < 0) | 108 if (write_result < 0) |
109 return LogSystemError("Write", logging::GetLastSystemErrorCode()); | 109 return LogSystemError("Write", logging::GetLastSystemErrorCode()); |
110 | 110 |
111 DCHECK_EQ(static_cast<size_t>(write_result), data_len); | 111 DCHECK_EQ(static_cast<size_t>(write_result), data_len); |
| 112 |
| 113 if (bytes_so_far_ != offset) { |
| 114 // A hole is created in the file. |
| 115 is_sparse_file_ = true; |
| 116 secure_hash_.reset(); |
| 117 } |
| 118 |
112 bytes_so_far_ += data_len; | 119 bytes_so_far_ += data_len; |
113 net_log_.EndEvent(net::NetLogEventType::DOWNLOAD_FILE_WRITTEN, | 120 net_log_.EndEvent(net::NetLogEventType::DOWNLOAD_FILE_WRITTEN, |
114 net::NetLog::Int64Callback("bytes", data_len)); | 121 net::NetLog::Int64Callback("bytes", data_len)); |
115 | 122 |
116 if (secure_hash_) | 123 if (secure_hash_) |
117 secure_hash_->Update(data, data_len); | 124 secure_hash_->Update(data, data_len); |
118 | 125 |
119 return DOWNLOAD_INTERRUPT_REASON_NONE; | 126 return DOWNLOAD_INTERRUPT_REASON_NONE; |
120 } | 127 } |
121 | 128 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 #else // !OS_WIN && !OS_MACOSX && !OS_LINUX | 473 #else // !OS_WIN && !OS_MACOSX && !OS_LINUX |
467 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation( | 474 DownloadInterruptReason BaseFile::AnnotateWithSourceInformation( |
468 const std::string& client_guid, | 475 const std::string& client_guid, |
469 const GURL& source_url, | 476 const GURL& source_url, |
470 const GURL& referrer_url) { | 477 const GURL& referrer_url) { |
471 return DOWNLOAD_INTERRUPT_REASON_NONE; | 478 return DOWNLOAD_INTERRUPT_REASON_NONE; |
472 } | 479 } |
473 #endif | 480 #endif |
474 | 481 |
475 } // namespace content | 482 } // namespace content |
OLD | NEW |