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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 save_file->save_item_id(), save_file->BytesSoFar(), | 193 save_file->save_item_id(), save_file->BytesSoFar(), |
194 reason == DOWNLOAD_INTERRUPT_REASON_NONE)); | 194 reason == DOWNLOAD_INTERRUPT_REASON_NONE)); |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 // The IO thread will call this when saving is completed or it got error when | 198 // The IO thread will call this when saving is completed or it got error when |
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) << __func__ << "() save_item_id = " << save_item_id |
204 << " save_item_id = " << save_item_id | |
205 << " save_package_id = " << save_package_id | 204 << " save_package_id = " << save_package_id |
206 << " is_success = " << is_success; | 205 << " is_success = " << is_success; |
207 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 206 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
208 | 207 |
209 int64_t bytes_so_far = 0; | 208 int64_t bytes_so_far = 0; |
210 SaveFile* save_file = LookupSaveFile(save_item_id); | 209 SaveFile* save_file = LookupSaveFile(save_item_id); |
211 if (save_file != nullptr) { | 210 if (save_file != nullptr) { |
212 DCHECK(save_file->InProgress()); | 211 DCHECK(save_file->InProgress()); |
213 DVLOG(20) << " " << __FUNCTION__ << "()" | 212 DVLOG(20) << __func__ << "() save_file = " << save_file->DebugString(); |
214 << " save_file = " << save_file->DebugString(); | |
215 bytes_so_far = save_file->BytesSoFar(); | 213 bytes_so_far = save_file->BytesSoFar(); |
216 save_file->Finish(); | 214 save_file->Finish(); |
217 save_file->Detach(); | 215 save_file->Detach(); |
218 } else { | 216 } else { |
219 // We got called before StartSave - this should only happen if | 217 // We got called before StartSave - this should only happen if |
220 // ResourceHandler failed before it got a chance to parse headers | 218 // ResourceHandler failed before it got a chance to parse headers |
221 // and metadata. | 219 // and metadata. |
222 DCHECK(!is_success); | 220 DCHECK(!is_success); |
223 } | 221 } |
224 | 222 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 SaveFile* save_file = it->second; | 417 SaveFile* save_file = it->second; |
420 DCHECK(!save_file->InProgress()); | 418 DCHECK(!save_file->InProgress()); |
421 base::DeleteFile(save_file->FullPath(), false); | 419 base::DeleteFile(save_file->FullPath(), false); |
422 delete save_file; | 420 delete save_file; |
423 save_file_map_.erase(it); | 421 save_file_map_.erase(it); |
424 } | 422 } |
425 } | 423 } |
426 } | 424 } |
427 | 425 |
428 } // namespace content | 426 } // namespace content |
OLD | NEW |