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

Side by Side Diff: content/browser/download/download_manager_impl.cc

Issue 15701007: BrowserContext should simply own DownloadManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased version of patch for win_rel Created 7 years, 7 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
OLDNEW
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 DownloadManagerImpl::DownloadManagerImpl( 233 DownloadManagerImpl::DownloadManagerImpl(
234 net::NetLog* net_log, 234 net::NetLog* net_log,
235 BrowserContext* browser_context) 235 BrowserContext* browser_context)
236 : item_factory_(new DownloadItemFactoryImpl()), 236 : item_factory_(new DownloadItemFactoryImpl()),
237 file_factory_(new DownloadFileFactory()), 237 file_factory_(new DownloadFileFactory()),
238 history_size_(0), 238 history_size_(0),
239 shutdown_needed_(true), 239 shutdown_needed_(true),
240 browser_context_(browser_context), 240 browser_context_(browser_context),
241 delegate_(NULL), 241 delegate_(NULL),
242 net_log_(net_log) { 242 net_log_(net_log),
243 weak_factory_(this) {
243 DCHECK(browser_context); 244 DCHECK(browser_context);
244 } 245 }
245 246
246 DownloadManagerImpl::~DownloadManagerImpl() { 247 DownloadManagerImpl::~DownloadManagerImpl() {
247 DCHECK(!shutdown_needed_); 248 DCHECK(!shutdown_needed_);
248 } 249 }
249 250
250 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem( 251 DownloadItemImpl* DownloadManagerImpl::CreateActiveItem(
251 DownloadId id, const DownloadCreateInfo& info) { 252 DownloadId id, const DownloadCreateInfo& info) {
252 net::BoundNetLog bound_net_log = 253 net::BoundNetLog bound_net_log =
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 443 }
443 444
444 void DownloadManagerImpl::CheckForFileRemoval(DownloadItemImpl* download_item) { 445 void DownloadManagerImpl::CheckForFileRemoval(DownloadItemImpl* download_item) {
445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 446 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
446 if (download_item->IsComplete() && 447 if (download_item->IsComplete() &&
447 !download_item->GetFileExternallyRemoved() && 448 !download_item->GetFileExternallyRemoved() &&
448 delegate_) { 449 delegate_) {
449 delegate_->CheckForFileExistence( 450 delegate_->CheckForFileExistence(
450 download_item, 451 download_item,
451 base::Bind(&DownloadManagerImpl::OnFileExistenceChecked, 452 base::Bind(&DownloadManagerImpl::OnFileExistenceChecked,
452 this, download_item->GetId())); 453 weak_factory_.GetWeakPtr(), download_item->GetId()));
453 } 454 }
454 } 455 }
455 456
456 void DownloadManagerImpl::OnFileExistenceChecked(int32 download_id, 457 void DownloadManagerImpl::OnFileExistenceChecked(int32 download_id,
457 bool result) { 458 bool result) {
458 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 459 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
459 if (!result) { // File does not exist. 460 if (!result) { // File does not exist.
460 if (ContainsKey(downloads_, download_id)) 461 if (ContainsKey(downloads_, download_id))
461 downloads_[download_id]->OnDownloadedFileRemoved(); 462 downloads_[download_id]->OnDownloadedFileRemoved();
462 } 463 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 if (delegate_) 666 if (delegate_)
666 delegate_->OpenDownload(download); 667 delegate_->OpenDownload(download);
667 } 668 }
668 669
669 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 670 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
670 if (delegate_) 671 if (delegate_)
671 delegate_->ShowDownloadInShell(download); 672 delegate_->ShowDownloadInShell(download);
672 } 673 }
673 674
674 } // namespace content 675 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.h ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698