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

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: . 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 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_);

Powered by Google App Engine
This is Rietveld 408576698