Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: chrome/browser/download/download_manager.cc

Issue 3348010: Revert 58196 - GTTF: Clean up DownloadFileManager... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_manager.h" 5 #include "chrome/browser/download/download_manager.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 DownloadManager::~DownloadManager() { 67 DownloadManager::~DownloadManager() {
68 FOR_EACH_OBSERVER(Observer, observers_, ManagerGoingDown()); 68 FOR_EACH_OBSERVER(Observer, observers_, ManagerGoingDown());
69 69
70 if (shutdown_needed_) 70 if (shutdown_needed_)
71 Shutdown(); 71 Shutdown();
72 } 72 }
73 73
74 void DownloadManager::Shutdown() { 74 void DownloadManager::Shutdown() {
75 DCHECK(shutdown_needed_) << "Shutdown called when not needed."; 75 DCHECK(shutdown_needed_) << "Shutdown called when not needed.";
76 76
77 if (file_manager_) { 77 // Stop receiving download updates
78 ChromeThread::PostTask(ChromeThread::FILE, FROM_HERE, 78 if (file_manager_)
79 NewRunnableMethod(file_manager_, 79 file_manager_->RemoveDownloadManager(this);
80 &DownloadFileManager::OnDownloadManagerShutdown,
81 this));
82 }
83 80
84 // 'in_progress_' may contain DownloadItems that have not finished the start 81 // 'in_progress_' may contain DownloadItems that have not finished the start
85 // complete (from the history service) and thus aren't in downloads_. 82 // complete (from the history service) and thus aren't in downloads_.
86 DownloadMap::iterator it = in_progress_.begin(); 83 DownloadMap::iterator it = in_progress_.begin();
87 std::set<DownloadItem*> to_remove; 84 std::set<DownloadItem*> to_remove;
88 for (; it != in_progress_.end(); ++it) { 85 for (; it != in_progress_.end(); ++it) {
89 DownloadItem* download = it->second; 86 DownloadItem* download = it->second;
90 if (download->safety_state() == DownloadItem::DANGEROUS) { 87 if (download->safety_state() == DownloadItem::DANGEROUS) {
91 // Forget about any download that the user did not approve. 88 // Forget about any download that the user did not approve.
92 // Note that we cannot call download->Remove() this would invalidate our 89 // Note that we cannot call download->Remove() this would invalidate our
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 int render_process_id, 655 int render_process_id,
659 int request_id) { 656 int request_id) {
660 // Cancel the network request. RDH is guaranteed to outlive the IO thread. 657 // Cancel the network request. RDH is guaranteed to outlive the IO thread.
661 ChromeThread::PostTask( 658 ChromeThread::PostTask(
662 ChromeThread::IO, FROM_HERE, 659 ChromeThread::IO, FROM_HERE,
663 NewRunnableFunction(&download_util::CancelDownloadRequest, 660 NewRunnableFunction(&download_util::CancelDownloadRequest,
664 g_browser_process->resource_dispatcher_host(), 661 g_browser_process->resource_dispatcher_host(),
665 render_process_id, 662 render_process_id,
666 request_id)); 663 request_id));
667 664
665 // Tell the file manager to cancel the download.
666 file_manager_->RemoveDownload(download_id, this); // On the UI thread
668 ChromeThread::PostTask( 667 ChromeThread::PostTask(
669 ChromeThread::FILE, FROM_HERE, 668 ChromeThread::FILE, FROM_HERE,
670 NewRunnableMethod( 669 NewRunnableMethod(
671 file_manager_, &DownloadFileManager::CancelDownload, download_id)); 670 file_manager_, &DownloadFileManager::CancelDownload, download_id));
672 } 671 }
673 672
674 void DownloadManager::PauseDownload(int32 download_id, bool pause) { 673 void DownloadManager::PauseDownload(int32 download_id, bool pause) {
675 DownloadMap::iterator it = in_progress_.find(download_id); 674 DownloadMap::iterator it = in_progress_.find(download_id);
676 if (it == in_progress_.end()) 675 if (it == in_progress_.end())
677 return; 676 return;
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 observed_download_manager_->RemoveObserver(this); 1062 observed_download_manager_->RemoveObserver(this);
1064 } 1063 }
1065 1064
1066 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() { 1065 void DownloadManager::OtherDownloadManagerObserver::ModelChanged() {
1067 observing_download_manager_->NotifyModelChanged(); 1066 observing_download_manager_->NotifyModelChanged();
1068 } 1067 }
1069 1068
1070 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() { 1069 void DownloadManager::OtherDownloadManagerObserver::ManagerGoingDown() {
1071 observed_download_manager_ = NULL; 1070 observed_download_manager_ = NULL;
1072 } 1071 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_file_manager.cc ('k') | chrome/browser/download/download_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698