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/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 void BaseFile::Cancel() { | 178 void BaseFile::Cancel() { |
179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
180 DCHECK(!detached_); | 180 DCHECK(!detached_); |
181 | 181 |
182 bound_net_log_.AddEvent(net::NetLog::TYPE_CANCELLED); | 182 bound_net_log_.AddEvent(net::NetLog::TYPE_CANCELLED); |
183 | 183 |
184 Close(); | 184 Close(); |
185 | 185 |
186 if (!full_path_.empty()) { | 186 if (!full_path_.empty()) { |
187 bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_DELETED); | 187 bound_net_log_.AddEvent(net::NetLog::TYPE_DOWNLOAD_FILE_DELETED); |
188 | |
189 base::DeleteFile(full_path_, false); | 188 base::DeleteFile(full_path_, false); |
190 } | 189 } |
| 190 |
| 191 Detach(); |
191 } | 192 } |
192 | 193 |
193 void BaseFile::Finish() { | 194 void BaseFile::Finish() { |
194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
195 | 196 |
196 if (calculate_hash_) | 197 if (calculate_hash_) |
197 secure_hash_->Finish(sha256_hash_, crypto::kSHA256Length); | 198 secure_hash_->Finish(sha256_hash_, crypto::kSHA256Length); |
198 | 199 |
199 Close(); | 200 Close(); |
200 } | 201 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 const char* operation, | 337 const char* operation, |
337 int os_error, | 338 int os_error, |
338 DownloadInterruptReason reason) { | 339 DownloadInterruptReason reason) { |
339 bound_net_log_.AddEvent( | 340 bound_net_log_.AddEvent( |
340 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, | 341 net::NetLog::TYPE_DOWNLOAD_FILE_ERROR, |
341 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); | 342 base::Bind(&FileInterruptedNetLogCallback, operation, os_error, reason)); |
342 return reason; | 343 return reason; |
343 } | 344 } |
344 | 345 |
345 } // namespace content | 346 } // namespace content |
OLD | NEW |