OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |