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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 VLOG(20) << __FUNCTION__ << "()" | 328 VLOG(20) << __FUNCTION__ << "()" |
329 << " shutdown_needed_ = " << shutdown_needed_; | 329 << " shutdown_needed_ = " << shutdown_needed_; |
330 if (!shutdown_needed_) | 330 if (!shutdown_needed_) |
331 return; | 331 return; |
332 shutdown_needed_ = false; | 332 shutdown_needed_ = false; |
333 | 333 |
334 FOR_EACH_OBSERVER(Observer, observers_, ManagerGoingDown(this)); | 334 FOR_EACH_OBSERVER(Observer, observers_, ManagerGoingDown(this)); |
335 // TODO(benjhayden): Consider clearing observers_. | 335 // TODO(benjhayden): Consider clearing observers_. |
336 | 336 |
337 // Go through all downloads in downloads_. Dangerous ones we need to | 337 // Go through all downloads in downloads_. Dangerous ones we need to |
338 // remove on disk, and in progress ones we need to cancel. | 338 // remove on disk, and in progress ones we need to cancel. |
Randy Smith (Not in Mondays)
2013/05/28 17:29:40
This comment seems obsolete.
asanka
2013/05/28 22:01:39
Done.
| |
339 for (DownloadMap::iterator it = downloads_.begin(); it != downloads_.end();) { | 339 for (DownloadMap::iterator it = downloads_.begin(); it != downloads_.end();) { |
340 DownloadItemImpl* download = it->second; | 340 DownloadItemImpl* download = it->second; |
341 | 341 |
342 // Save iterator from potential erases in this set done by called code. | 342 // Save iterator from potential erases in this set done by called code. |
343 // Iterators after an erasure point are still valid for lists and | 343 // Iterators after an erasure point are still valid for lists and |
344 // associative containers such as sets. | 344 // associative containers such as sets. |
345 it++; | 345 it++; |
Randy Smith (Not in Mondays)
2013/05/28 17:29:40
We're no longer removing downloads here, so would
asanka
2013/05/28 22:01:39
Done.
| |
346 | 346 |
347 if (download->IsDangerous() && download->IsPartialDownload()) { | 347 if (download->GetState() == DownloadItem::IN_PROGRESS) |
348 // The user hasn't accepted it, so we need to remove it | |
349 // from the disk. This may or may not result in it being | |
350 // removed from the DownloadManager queues and deleted | |
351 // (specifically, DownloadManager::DownloadRemoved only | |
352 // removes and deletes it if it's known to the history service) | |
353 // so the only thing we know after calling this function is that | |
354 // the download was deleted if-and-only-if it was removed | |
355 // from all queues. | |
356 download->Delete(DownloadItem::DELETE_DUE_TO_BROWSER_SHUTDOWN); | |
Randy Smith (Not in Mondays)
2013/05/28 17:29:40
There's a semantic difference we're putting in whi
asanka
2013/05/28 22:01:39
Yeah. I updated the CL description to mention this
| |
357 } else if (download->IsPartialDownload()) { | |
358 download->Cancel(false); | 348 download->Cancel(false); |
359 } | |
360 } | 349 } |
361 | 350 |
362 // At this point, all dangerous downloads have had their files removed | 351 // At this point, all dangerous downloads have had their files removed |
363 // and all in progress downloads have been cancelled. We can now delete | 352 // and all in progress downloads have been cancelled. We can now delete |
364 // anything left. | 353 // anything left. |
365 | 354 |
366 STLDeleteValues(&downloads_); | 355 STLDeleteValues(&downloads_); |
367 downloads_.clear(); | 356 downloads_.clear(); |
368 | 357 |
369 // We'll have nothing more to report to the observers after this point. | 358 // We'll have nothing more to report to the observers after this point. |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 if (delegate_) | 654 if (delegate_) |
666 delegate_->OpenDownload(download); | 655 delegate_->OpenDownload(download); |
667 } | 656 } |
668 | 657 |
669 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { | 658 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { |
670 if (delegate_) | 659 if (delegate_) |
671 delegate_->ShowDownloadInShell(download); | 660 delegate_->ShowDownloadInShell(download); |
672 } | 661 } |
673 | 662 |
674 } // namespace content | 663 } // namespace content |
OLD | NEW |