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

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 c802b50e0d6ad5838814eb84439ff8815a40510d..0e46080f235f052bcb6a0e8862222b1563f56e6d 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(
+ DownloadManager* manager, DownloadItem* item) {
+ DCHECK_EQ(manager, download_manager_);
+ OnDownloadUpdated(item);
+
+ DownloadSet::const_iterator finished_it(finished_downloads_.find(item));
Randy Smith (Not in Mondays) 2012/09/11 18:36:53 How could item ever be in finished_downloads_ when
benjhayden 2012/09/13 15:18:16 OnDownloadUpdated() is called before this code. Th
+ 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