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

Side by Side Diff: chrome/browser/download/download_test_observer.cc

Issue 8487002: Basic tests for DownloadUrl/DownloadUrlToFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ifdef out breaking chromeos behavior with bug pointer. Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/task.h" 10 #include "base/task.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 DownloadInFinalState(download); 135 DownloadInFinalState(download);
136 } 136 }
137 } 137 }
138 138
139 void DownloadTestObserver::ModelChanged() { 139 void DownloadTestObserver::ModelChanged() {
140 // Regenerate DownloadItem observers. If there are any download items 140 // Regenerate DownloadItem observers. If there are any download items
141 // in our final state, note them in |finished_downloads_| 141 // in our final state, note them in |finished_downloads_|
142 // (done by |OnDownloadUpdated()|). 142 // (done by |OnDownloadUpdated()|).
143 std::vector<DownloadItem*> downloads; 143 std::vector<DownloadItem*> downloads;
144 download_manager_->GetAllDownloads(FilePath(), &downloads); 144 download_manager_->GetAllDownloads(FilePath(), &downloads);
145 // As a test class, we're generally interested in whatever's there,
146 // so we include temporary downloads.
147 download_manager_->GetTemporaryDownloads(FilePath(), &downloads);
145 148
146 for (std::vector<DownloadItem*>::iterator it = downloads.begin(); 149 for (std::vector<DownloadItem*>::iterator it = downloads.begin();
147 it != downloads.end(); ++it) { 150 it != downloads.end(); ++it) {
148 OnDownloadUpdated(*it); // Safe to call multiple times; checks state. 151 OnDownloadUpdated(*it); // Safe to call multiple times; checks state.
149 152
150 DownloadSet::const_iterator finished_it(finished_downloads_.find(*it)); 153 DownloadSet::const_iterator finished_it(finished_downloads_.find(*it));
151 DownloadSet::iterator observed_it(downloads_observed_.find(*it)); 154 DownloadSet::iterator observed_it(downloads_observed_.find(*it));
152 155
153 // If it isn't finished and we're aren't observing it, start. 156 // If it isn't finished and we're aren't observing it, start.
154 if (finished_it == finished_downloads_.end() && 157 if (finished_it == finished_downloads_.end() &&
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (--cycle) { 293 if (--cycle) {
291 BrowserThread::PostTask( 294 BrowserThread::PostTask(
292 BrowserThread::UI, FROM_HERE, 295 BrowserThread::UI, FROM_HERE,
293 NewRunnableMethod(this, &DownloadTestFlushObserver::PingFileThread, 296 NewRunnableMethod(this, &DownloadTestFlushObserver::PingFileThread,
294 cycle)); 297 cycle));
295 } else { 298 } else {
296 BrowserThread::PostTask( 299 BrowserThread::PostTask(
297 BrowserThread::UI, FROM_HERE, new MessageLoop::QuitTask()); 300 BrowserThread::UI, FROM_HERE, new MessageLoop::QuitTask());
298 } 301 }
299 } 302 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | content/browser/download/download_file_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698