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/download_manager_impl.h" | 5 #include "content/browser/download/download_manager_impl.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 DownloadId id(info->download_id); | 382 DownloadId id(info->download_id); |
383 const bool new_download = !id.IsValid(); | 383 const bool new_download = !id.IsValid(); |
384 DownloadItemImpl* download = NULL; | 384 DownloadItemImpl* download = NULL; |
385 | 385 |
386 if (new_download) { | 386 if (new_download) { |
387 id = GetNextId(); | 387 id = GetNextId(); |
388 download = CreateActiveItem(id, *info); | 388 download = CreateActiveItem(id, *info); |
389 } else { | 389 } else { |
390 DownloadMap::iterator item_iterator = downloads_.find(id.local()); | 390 DownloadMap::iterator item_iterator = downloads_.find(id.local()); |
391 // Trying to resume an interrupted download. | 391 // Trying to resume an interrupted download. |
392 if (item_iterator == downloads_.end()) { | 392 if (item_iterator == downloads_.end() || |
393 item_iterator->second->IsCancelled()) { | |
Randy Smith (Not in Mondays)
2013/05/21 21:40:37
(This is mostly just rambling--the final conclusio
asanka
2013/05/22 22:55:52
Noted :)
| |
393 // If the download is no longer known to the DownloadManager, then it was | 394 // If the download is no longer known to the DownloadManager, then it was |
394 // removed after it was resumed. Ignore. | 395 // removed after it was resumed. Ignore. If the download is cancelled |
396 // while resuming, then also ignore the request. | |
395 info->request_handle.CancelRequest(); | 397 info->request_handle.CancelRequest(); |
396 return NULL; | 398 return NULL; |
397 } | 399 } |
398 download = item_iterator->second; | 400 download = item_iterator->second; |
399 DCHECK(download->IsInterrupted()); | 401 DCHECK(download->IsInterrupted()); |
Randy Smith (Not in Mondays)
2013/05/21 21:40:37
Won't this DCHECK fail in the cancelled case?
asanka
2013/05/22 22:55:52
If the download is cancelled, the previous 'if' bl
| |
400 } | 402 } |
401 | 403 |
402 base::FilePath default_download_directory; | 404 base::FilePath default_download_directory; |
403 if (delegate_) { | 405 if (delegate_) { |
404 base::FilePath website_save_directory; // Unused | 406 base::FilePath website_save_directory; // Unused |
405 bool skip_dir_check = false; // Unused | 407 bool skip_dir_check = false; // Unused |
406 delegate_->GetSaveDir(GetBrowserContext(), &website_save_directory, | 408 delegate_->GetSaveDir(GetBrowserContext(), &website_save_directory, |
407 &default_download_directory, &skip_dir_check); | 409 &default_download_directory, &skip_dir_check); |
408 } | 410 } |
409 | 411 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
663 if (delegate_) | 665 if (delegate_) |
664 delegate_->OpenDownload(download); | 666 delegate_->OpenDownload(download); |
665 } | 667 } |
666 | 668 |
667 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 669 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
668 if (delegate_) | 670 if (delegate_) |
669 delegate_->ShowDownloadInShell(download); | 671 delegate_->ShowDownloadInShell(download); |
670 } | 672 } |
671 | 673 |
672 } // namespace content | 674 } // namespace content |
OLD | NEW |