| 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..d5533cb1da3219f31b326b630907679682299c15 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,34 @@
|
|
|
| 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;
|
| +
|
| + // The filter passed may be called multiple times, even after it
|
| + // returns true.
|
| + 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_;
|
| + bool event_seen_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(DownloadUpdatedObserver);
|
| +};
|
| +
|
| // 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
|
|
|