| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/download/download_file_manager.h" | 5 #include "chrome/browser/download/download_file_manager.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // Without a download manager, we can't cancel the request normally, so we | 370 // Without a download manager, we can't cancel the request normally, so we |
| 371 // need to do it here. The normal path will also update the download | 371 // need to do it here. The normal path will also update the download |
| 372 // history before cancelling the request. | 372 // history before cancelling the request. |
| 373 download_file->CancelDownloadRequest(); | 373 download_file->CancelDownloadRequest(); |
| 374 return; | 374 return; |
| 375 } | 375 } |
| 376 | 376 |
| 377 BrowserThread::PostTask( | 377 BrowserThread::PostTask( |
| 378 BrowserThread::UI, FROM_HERE, | 378 BrowserThread::UI, FROM_HERE, |
| 379 NewRunnableMethod(download_manager, | 379 NewRunnableMethod(download_manager, |
| 380 &DownloadManager::DownloadCancelled, id)); | 380 &DownloadManager::CancelDownload, id)); |
| 381 } | 381 } |
| 382 | 382 |
| 383 void DownloadFileManager::EraseDownload(int id) { | 383 void DownloadFileManager::EraseDownload(int id) { |
| 384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 384 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 385 | 385 |
| 386 if (!ContainsKey(downloads_, id)) | 386 if (!ContainsKey(downloads_, id)) |
| 387 return; | 387 return; |
| 388 | 388 |
| 389 DownloadFile* download_file = downloads_[id]; | 389 DownloadFile* download_file = downloads_[id]; |
| 390 | 390 |
| 391 VLOG(20) << " " << __FUNCTION__ << "()" | 391 VLOG(20) << " " << __FUNCTION__ << "()" |
| 392 << " id = " << id | 392 << " id = " << id |
| 393 << " download_file = " << download_file->DebugString(); | 393 << " download_file = " << download_file->DebugString(); |
| 394 | 394 |
| 395 downloads_.erase(id); | 395 downloads_.erase(id); |
| 396 | 396 |
| 397 delete download_file; | 397 delete download_file; |
| 398 | 398 |
| 399 if (downloads_.empty()) | 399 if (downloads_.empty()) |
| 400 StopUpdateTimer(); | 400 StopUpdateTimer(); |
| 401 } | 401 } |
| OLD | NEW |