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

Unified Diff: content/public/test/download_test_observer.cc

Issue 10915180: Make DownloadHistory observe manager, items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: @r159248 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 side-by-side diff with in-line comments
Download patch
Index: content/public/test/download_test_observer.cc
diff --git a/content/public/test/download_test_observer.cc b/content/public/test/download_test_observer.cc
index 6455027ef6d6c9c32324d9d1a546879866a4d1bb..3b99adef07cb33a125e589ac070ad00ea41a2063 100644
--- a/content/public/test/download_test_observer.cc
+++ b/content/public/test/download_test_observer.cc
@@ -109,25 +109,11 @@ DownloadTestObserver::~DownloadTestObserver() {
void DownloadTestObserver::Init() {
download_manager_->AddObserver(this);
- // Regenerate DownloadItem observers. If there are any download items
- // in our final state, note them in |finished_downloads_|
- // (done by |OnDownloadUpdated()|).
std::vector<DownloadItem*> downloads;
download_manager_->GetAllDownloads(&downloads);
-
for (std::vector<DownloadItem*>::iterator it = downloads.begin();
it != downloads.end(); ++it) {
- OnDownloadUpdated(*it); // Safe to call multiple times; checks state.
-
- DownloadSet::const_iterator finished_it(finished_downloads_.find(*it));
- DownloadSet::iterator observed_it(downloads_observed_.find(*it));
-
- // If it isn't finished and we're aren't observing it, start.
- if (finished_it == finished_downloads_.end() &&
- observed_it == downloads_observed_.end()) {
- (*it)->AddObserver(this);
- downloads_observed_.insert(*it);
- }
+ OnDownloadCreated(download_manager_, *it);
}
finished_downloads_at_construction_ = finished_downloads_.size();
states_observed_.clear();
@@ -197,7 +183,9 @@ void DownloadTestObserver::OnDownloadUpdated(DownloadItem* download) {
void DownloadTestObserver::OnDownloadCreated(
DownloadManager* manager, DownloadItem* item) {
+ DCHECK_EQ(manager, download_manager_);
OnDownloadUpdated(item);
+
DownloadSet::const_iterator finished_it(finished_downloads_.find(item));
DownloadSet::iterator observed_it(downloads_observed_.find(item));

Powered by Google App Engine
This is Rietveld 408576698