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

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

Issue 12047039: download: Remove DownloadManager::MockDownloadOpenForTesting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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) 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } // namespace 216 } // namespace
217 217
218 DownloadManagerImpl::DownloadManagerImpl( 218 DownloadManagerImpl::DownloadManagerImpl(
219 net::NetLog* net_log) 219 net::NetLog* net_log)
220 : item_factory_(new DownloadItemFactoryImpl()), 220 : item_factory_(new DownloadItemFactoryImpl()),
221 file_factory_(new DownloadFileFactory()), 221 file_factory_(new DownloadFileFactory()),
222 history_size_(0), 222 history_size_(0),
223 shutdown_needed_(false), 223 shutdown_needed_(false),
224 browser_context_(NULL), 224 browser_context_(NULL),
225 delegate_(NULL), 225 delegate_(NULL),
226 net_log_(net_log), 226 net_log_(net_log) {
227 open_enabled_(true) {
228 } 227 }
229 228
230 DownloadManagerImpl::~DownloadManagerImpl() { 229 DownloadManagerImpl::~DownloadManagerImpl() {
231 DCHECK(!shutdown_needed_); 230 DCHECK(!shutdown_needed_);
232 } 231 }
233 232
234 DownloadId DownloadManagerImpl::GetNextId() { 233 DownloadId DownloadManagerImpl::GetNextId() {
235 DownloadId id; 234 DownloadId id;
236 if (delegate_) 235 if (delegate_)
237 id = delegate_->GetNextId(); 236 id = delegate_->GetNextId();
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; 652 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL;
654 } 653 }
655 654
656 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { 655 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) {
657 for (DownloadMap::iterator it = downloads_.begin(); 656 for (DownloadMap::iterator it = downloads_.begin();
658 it != downloads_.end(); ++it) { 657 it != downloads_.end(); ++it) {
659 downloads->push_back(it->second); 658 downloads->push_back(it->second);
660 } 659 }
661 } 660 }
662 661
663 void DownloadManagerImpl::MockDownloadOpenForTesting() {
664 open_enabled_ = false;
665 }
666
667 void DownloadManagerImpl::OpenDownload(DownloadItemImpl* download) { 662 void DownloadManagerImpl::OpenDownload(DownloadItemImpl* download) {
668 int num_unopened = 0; 663 int num_unopened = 0;
669 for (DownloadMap::iterator it = downloads_.begin(); 664 for (DownloadMap::iterator it = downloads_.begin();
670 it != downloads_.end(); ++it) { 665 it != downloads_.end(); ++it) {
671 DownloadItemImpl* item = it->second; 666 DownloadItemImpl* item = it->second;
672 if (item->IsComplete() && 667 if (item->IsComplete() &&
673 !item->GetOpened()) 668 !item->GetOpened())
674 ++num_unopened; 669 ++num_unopened;
675 } 670 }
676 RecordOpensOutstanding(num_unopened); 671 RecordOpensOutstanding(num_unopened);
677 672
678 if (delegate_ && open_enabled_) // Some tests disable OpenDownload(). 673 if (delegate_)
679 delegate_->OpenDownload(download); 674 delegate_->OpenDownload(download);
680 } 675 }
681 676
682 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 677 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
683 if (delegate_) 678 if (delegate_)
684 delegate_->ShowDownloadInShell(download); 679 delegate_->ShowDownloadInShell(download);
685 } 680 }
686 681
687 } // namespace content 682 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698