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

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: Rename to DownloadTestFileActivityObserver 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL; 658 return ContainsKey(downloads_, download_id) ? downloads_[download_id] : NULL;
660 } 659 }
661 660
662 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) { 661 void DownloadManagerImpl::GetAllDownloads(DownloadVector* downloads) {
663 for (DownloadMap::iterator it = downloads_.begin(); 662 for (DownloadMap::iterator it = downloads_.begin();
664 it != downloads_.end(); ++it) { 663 it != downloads_.end(); ++it) {
665 downloads->push_back(it->second); 664 downloads->push_back(it->second);
666 } 665 }
667 } 666 }
668 667
669 void DownloadManagerImpl::MockDownloadOpenForTesting() {
670 open_enabled_ = false;
671 }
672
673 void DownloadManagerImpl::OpenDownload(DownloadItemImpl* download) { 668 void DownloadManagerImpl::OpenDownload(DownloadItemImpl* download) {
674 int num_unopened = 0; 669 int num_unopened = 0;
675 for (DownloadMap::iterator it = downloads_.begin(); 670 for (DownloadMap::iterator it = downloads_.begin();
676 it != downloads_.end(); ++it) { 671 it != downloads_.end(); ++it) {
677 DownloadItemImpl* item = it->second; 672 DownloadItemImpl* item = it->second;
678 if (item->IsComplete() && 673 if (item->IsComplete() &&
679 !item->GetOpened()) 674 !item->GetOpened())
680 ++num_unopened; 675 ++num_unopened;
681 } 676 }
682 RecordOpensOutstanding(num_unopened); 677 RecordOpensOutstanding(num_unopened);
683 678
684 if (delegate_ && open_enabled_) // Some tests disable OpenDownload(). 679 if (delegate_)
685 delegate_->OpenDownload(download); 680 delegate_->OpenDownload(download);
686 } 681 }
687 682
688 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) { 683 void DownloadManagerImpl::ShowDownloadInShell(DownloadItemImpl* download) {
689 if (delegate_) 684 if (delegate_)
690 delegate_->ShowDownloadInShell(download); 685 delegate_->ShowDownloadInShell(download);
691 } 686 }
692 687
693 } // namespace content 688 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698