| 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "content/browser/download/save_file_manager.h" | 7 #include "content/browser/download/save_file_manager.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // fetching data. We forward the message to OnSaveFinished in UI thread. | 199 // fetching data. We forward the message to OnSaveFinished in UI thread. |
| 200 void SaveFileManager::SaveFinished(SaveItemId save_item_id, | 200 void SaveFileManager::SaveFinished(SaveItemId save_item_id, |
| 201 SavePackageId save_package_id, | 201 SavePackageId save_package_id, |
| 202 bool is_success) { | 202 bool is_success) { |
| 203 DVLOG(20) << " " << __FUNCTION__ << "()" | 203 DVLOG(20) << " " << __FUNCTION__ << "()" |
| 204 << " save_item_id = " << save_item_id | 204 << " save_item_id = " << save_item_id |
| 205 << " save_package_id = " << save_package_id | 205 << " save_package_id = " << save_package_id |
| 206 << " is_success = " << is_success; | 206 << " is_success = " << is_success; |
| 207 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 207 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
| 208 | 208 |
| 209 int64_t bytes_so_far; | 209 int64_t bytes_so_far = 0; |
| 210 SaveFile* save_file = LookupSaveFile(save_item_id); | 210 SaveFile* save_file = LookupSaveFile(save_item_id); |
| 211 if (save_file != nullptr) { | 211 if (save_file != nullptr) { |
| 212 DCHECK(save_file->InProgress()); | 212 DCHECK(save_file->InProgress()); |
| 213 DVLOG(20) << " " << __FUNCTION__ << "()" | 213 DVLOG(20) << " " << __FUNCTION__ << "()" |
| 214 << " save_file = " << save_file->DebugString(); | 214 << " save_file = " << save_file->DebugString(); |
| 215 bytes_so_far = save_file->BytesSoFar(); | 215 bytes_so_far = save_file->BytesSoFar(); |
| 216 save_file->Finish(); | 216 save_file->Finish(); |
| 217 save_file->Detach(); | 217 save_file->Detach(); |
| 218 } else { | 218 } else { |
| 219 // We got called before StartSave - this should only happen if | 219 // We got called before StartSave - this should only happen if |
| 220 // ResourceHandler failed before it got a chance to parse headers | 220 // ResourceHandler failed before it got a chance to parse headers |
| 221 // and metadata. | 221 // and metadata. |
| 222 DCHECK(!is_success); | 222 DCHECK(!is_success); |
| 223 | |
| 224 bytes_so_far = 0; | |
| 225 } | 223 } |
| 226 | 224 |
| 227 BrowserThread::PostTask( | 225 BrowserThread::PostTask( |
| 228 BrowserThread::UI, FROM_HERE, | 226 BrowserThread::UI, FROM_HERE, |
| 229 base::Bind(&SaveFileManager::OnSaveFinished, this, save_item_id, | 227 base::Bind(&SaveFileManager::OnSaveFinished, this, save_item_id, |
| 230 bytes_so_far, is_success)); | 228 bytes_so_far, is_success)); |
| 231 } | 229 } |
| 232 | 230 |
| 233 // Notifications sent from the file thread and run on the UI thread. | 231 // Notifications sent from the file thread and run on the UI thread. |
| 234 | 232 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 SaveFile* save_file = it->second; | 419 SaveFile* save_file = it->second; |
| 422 DCHECK(!save_file->InProgress()); | 420 DCHECK(!save_file->InProgress()); |
| 423 base::DeleteFile(save_file->FullPath(), false); | 421 base::DeleteFile(save_file->FullPath(), false); |
| 424 delete save_file; | 422 delete save_file; |
| 425 save_file_map_.erase(it); | 423 save_file_map_.erase(it); |
| 426 } | 424 } |
| 427 } | 425 } |
| 428 } | 426 } |
| 429 | 427 |
| 430 } // namespace content | 428 } // namespace content |
| OLD | NEW |