Move creation and ownership of DownloadManager from the embedder to content. This matches all the other objects that content depends on.
In a followup change, I'll make content support NULL DownloadManagerDelegates to match the rest of the delegate interfaces.
BUG=98716
Review URL: https://chromiumcodereview.appspot.com/10535026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@140761 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index 3296daa..45e2c982 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -140,13 +140,6 @@
namespace content {
-// static
-DownloadManager* DownloadManager::Create(
- content::DownloadManagerDelegate* delegate,
- net::NetLog* net_log) {
- return new DownloadManagerImpl(delegate, net_log);
-}
-
bool DownloadManager::EnsureNoPendingDownloadsForTesting() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
bool result = true;
@@ -159,14 +152,12 @@
} // namespace content
-DownloadManagerImpl::DownloadManagerImpl(
- content::DownloadManagerDelegate* delegate,
- net::NetLog* net_log)
- : shutdown_needed_(false),
- browser_context_(NULL),
- file_manager_(NULL),
- delegate_(delegate),
- net_log_(net_log) {
+DownloadManagerImpl::DownloadManagerImpl(net::NetLog* net_log)
+ : shutdown_needed_(false),
+ browser_context_(NULL),
+ file_manager_(NULL),
+ delegate_(NULL),
+ net_log_(net_log) {
}
DownloadManagerImpl::~DownloadManagerImpl() {
@@ -185,6 +176,11 @@
return delegate_->ShouldOpenFileBasedOnExtension(path);
}
+void DownloadManagerImpl::SetDelegate(
+ content::DownloadManagerDelegate* delegate) {
+ delegate_ = delegate;
+}
+
void DownloadManagerImpl::Shutdown() {
VLOG(20) << __FUNCTION__ << "()"
<< " shutdown_needed_ = " << shutdown_needed_;
@@ -249,7 +245,8 @@
DCHECK(save_page_downloads_.empty());
file_manager_ = NULL;
- delegate_->Shutdown();
+ if (delegate_)
+ delegate_->Shutdown();
}
void DownloadManagerImpl::GetTemporaryDownloads(