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 |