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 85caf410ade5d3706840c7ca8ac9ebf8c7d99b43..aec26876158ba7b656b786a62cbb9d9a7914d8b3 100644 |
--- a/content/public/test/download_test_observer.cc |
+++ b/content/public/test/download_test_observer.cc |
@@ -131,6 +131,29 @@ void DownloadTestObserver::OnDownloadUpdated(DownloadItem* download) { |
DownloadInFinalState(download); |
} |
+void DownloadTestObserver::OnDownloadCreated( |
Randy Smith (Not in Mondays)
2012/09/13 19:53:19
It seems wrong to use *both* OnDownloadCreated() a
benjhayden
2012/09/21 20:45:46
Done.
|
+ 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)); |
+ |
+ // If it isn't finished and we're aren't observing it, start. |
+ if (finished_it == finished_downloads_.end() && |
+ observed_it == downloads_observed_.end()) { |
+ item->AddObserver(this); |
+ downloads_observed_.insert(item); |
+ } |
+ |
+ // If it is finished and we are observing it, stop. |
+ if (finished_it != finished_downloads_.end() && |
+ observed_it != downloads_observed_.end()) { |
+ item->RemoveObserver(this); |
+ downloads_observed_.erase(observed_it); |
+ } |
+} |
+ |
void DownloadTestObserver::ModelChanged(DownloadManager* manager) { |
DCHECK_EQ(manager, download_manager_); |