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

Side by Side Diff: content/public/test/download_test_observer.cc

Issue 10914158: Revert 155351 - Make DownloadManager::GetAllDownloads return all downloads regardless of state, per… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
« no previous file with comments | « content/public/browser/download_manager.h ('k') | content/public/test/mock_download_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/public/test/download_test_observer.h" 5 #include "content/public/test/download_test_observer.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 DownloadInFinalState(download); 131 DownloadInFinalState(download);
132 } 132 }
133 133
134 void DownloadTestObserver::ModelChanged(DownloadManager* manager) { 134 void DownloadTestObserver::ModelChanged(DownloadManager* manager) {
135 DCHECK_EQ(manager, download_manager_); 135 DCHECK_EQ(manager, download_manager_);
136 136
137 // Regenerate DownloadItem observers. If there are any download items 137 // Regenerate DownloadItem observers. If there are any download items
138 // in our final state, note them in |finished_downloads_| 138 // in our final state, note them in |finished_downloads_|
139 // (done by |OnDownloadUpdated()|). 139 // (done by |OnDownloadUpdated()|).
140 std::vector<DownloadItem*> downloads; 140 std::vector<DownloadItem*> downloads;
141 download_manager_->GetAllDownloads(&downloads); 141 download_manager_->GetAllDownloads(FilePath(), &downloads);
142 // As a test class, we're generally interested in whatever's there,
143 // so we include temporary downloads.
144 download_manager_->GetTemporaryDownloads(FilePath(), &downloads);
142 145
143 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); 146 for (std::vector<DownloadItem*>::iterator it = downloads.begin();
144 it != downloads.end(); ++it) { 147 it != downloads.end(); ++it) {
145 OnDownloadUpdated(*it); // Safe to call multiple times; checks state. 148 OnDownloadUpdated(*it); // Safe to call multiple times; checks state.
146 149
147 DownloadSet::const_iterator finished_it(finished_downloads_.find(*it)); 150 DownloadSet::const_iterator finished_it(finished_downloads_.find(*it));
148 DownloadSet::iterator observed_it(downloads_observed_.find(*it)); 151 DownloadSet::iterator observed_it(downloads_observed_.find(*it));
149 152
150 // If it isn't finished and we're aren't observing it, start. 153 // If it isn't finished and we're aren't observing it, start.
151 if (finished_it == finished_downloads_.end() && 154 if (finished_it == finished_downloads_.end() &&
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 286
284 // If we're waiting for that flush point, check the number 287 // If we're waiting for that flush point, check the number
285 // of downloads in the IN_PROGRESS state and take appropriate 288 // of downloads in the IN_PROGRESS state and take appropriate
286 // action. If requested, also observes all downloads while iterating. 289 // action. If requested, also observes all downloads while iterating.
287 void DownloadTestFlushObserver::CheckDownloadsInProgress( 290 void DownloadTestFlushObserver::CheckDownloadsInProgress(
288 bool observe_downloads) { 291 bool observe_downloads) {
289 if (waiting_for_zero_inprogress_) { 292 if (waiting_for_zero_inprogress_) {
290 int count = 0; 293 int count = 0;
291 294
292 std::vector<DownloadItem*> downloads; 295 std::vector<DownloadItem*> downloads;
293 download_manager_->GetAllDownloads(&downloads); 296 download_manager_->SearchDownloads(string16(), &downloads);
294 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); 297 for (std::vector<DownloadItem*>::iterator it = downloads.begin();
295 it != downloads.end(); ++it) { 298 it != downloads.end(); ++it) {
296 if ((*it)->GetState() == DownloadItem::IN_PROGRESS) 299 if ((*it)->GetState() == DownloadItem::IN_PROGRESS)
297 count++; 300 count++;
298 if (observe_downloads) { 301 if (observe_downloads) {
299 if (downloads_observed_.find(*it) == downloads_observed_.end()) { 302 if (downloads_observed_.find(*it) == downloads_observed_.end()) {
300 (*it)->AddObserver(this); 303 (*it)->AddObserver(this);
301 downloads_observed_.insert(*it); 304 downloads_observed_.insert(*it);
302 } 305 }
303 // Download items are forever, and we don't want to make 306 // Download items are forever, and we don't want to make
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 MessageLoopForUI::current()->Quit(); 379 MessageLoopForUI::current()->Quit();
377 } 380 }
378 381
379 const DownloadUrlParameters::OnStartedCallback 382 const DownloadUrlParameters::OnStartedCallback
380 DownloadTestItemCreationObserver::callback() { 383 DownloadTestItemCreationObserver::callback() {
381 return base::Bind( 384 return base::Bind(
382 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); 385 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
383 } 386 }
384 387
385 } // namespace content 388 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/download_manager.h ('k') | content/public/test/mock_download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698