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

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

Issue 10912173: Replace the DownloadFileManager with direct ownership of DownloadFileImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to LKGR (r156083) 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.h
diff --git a/content/public/test/download_test_observer.h b/content/public/test/download_test_observer.h
index 8df29882e721d00190c21ea4411ac1582457f614..674306f09b0a3af10ff75e6e60131bc8219fd028 100644
--- a/content/public/test/download_test_observer.h
+++ b/content/public/test/download_test_observer.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/callback_forward.h"
#include "base/memory/ref_counted.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/download_manager.h"
@@ -17,6 +18,29 @@
namespace content {
+// Detects an arbitrary change on a download item.
+// TODO: Rewrite other observers to use this (or be replaced by it).
+class DownloadUpdatedObserver : public DownloadItem::Observer {
+ public:
+ typedef base::Callback<bool(DownloadItem*)> EventFilter;
+
+ DownloadUpdatedObserver(DownloadItem* item, EventFilter filter);
+ ~DownloadUpdatedObserver();
+
+ // Returns false if the waiting ended because of the destruction of the
+ // DownloadItem rather than because of the expected event occuring.
+ bool WaitForEvent();
+
+ private:
+ // DownloadItem::Observer
+ void OnDownloadUpdated(DownloadItem* item) OVERRIDE;
+ void OnDownloadDestroyed(DownloadItem* item) OVERRIDE;
+
+ DownloadItem* item_;
+ EventFilter filter_;
+ bool waiting_;
+};
+
// Detects changes to the downloads after construction.
// Finishes when one of the following happens:
// - A specified number of downloads change to a terminal state (defined

Powered by Google App Engine
This is Rietveld 408576698