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

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

Issue 15485002: DownloadTestObserver should know when the DownloadManager was shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use CHECK_EQ Created 7 years, 7 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
« no previous file with comments | « no previous file | content/public/test/download_test_observer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6626ffe5ece6d5bac9e3c2e3342ef159e8f00a17..c5e94765da7380f38e75712cf6e6e3e71a9e801f 100644
--- a/content/public/test/download_test_observer.h
+++ b/content/public/test/download_test_observer.h
@@ -49,17 +49,13 @@ class DownloadUpdatedObserver : public DownloadItem::Observer {
};
// 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
// in derived classes).
-// - Specific events, such as a select file dialog.
-// Callers may either probe for the finished state, or wait on it.
+// - The download manager was shutdown.
//
-// TODO(rdsmith): Detect manager going down, remove pointer to
-// DownloadManager, transition to finished. (For right now we
-// just use a scoped_refptr<> to keep it around, but that may cause
-// timeouts on waiting if a DownloadManager::Shutdown() occurs which
-// cancels our in-progress downloads.)
+// Callers may either probe for the finished state, or wait on it.
class DownloadTestObserver : public DownloadManager::Observer,
public DownloadItem::Observer {
public:
@@ -79,10 +75,10 @@ class DownloadTestObserver : public DownloadManager::Observer,
virtual ~DownloadTestObserver();
- // Wait for the requested number of downloads to enter a terminal state.
+ // Wait for one of the finish conditions.
void WaitForFinished();
- // Return true if everything's happened that we're configured for.
+ // Return true if we reached one of the finish conditions.
bool IsFinished() const;
// DownloadItem::Observer
@@ -92,6 +88,7 @@ class DownloadTestObserver : public DownloadManager::Observer,
// DownloadManager::Observer
virtual void OnDownloadCreated(
DownloadManager* manager, DownloadItem* item) OVERRIDE;
+ virtual void ManagerGoingDown(DownloadManager* manager) OVERRIDE;
size_t NumDangerousDownloadsSeen() const;
@@ -118,8 +115,14 @@ class DownloadTestObserver : public DownloadManager::Observer,
void SignalIfFinished();
+ // Fake user click on "Accept".
+ void AcceptDangerousDownload(int32 download_id);
+
+ // Fake user click on "Deny".
+ void DenyDangerousDownload(int32 download_id);
+
// The observed download manager.
- scoped_refptr<DownloadManager> download_manager_;
+ DownloadManager* download_manager_;
// The set of DownloadItem's that have transitioned to their finished state
// since construction of this object. When the size of this array
@@ -159,6 +162,8 @@ class DownloadTestObserver : public DownloadManager::Observer,
// Holds the download ids which were dangerous.
std::set<int32> dangerous_downloads_seen_;
+ base::WeakPtrFactory<DownloadTestObserver> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadTestObserver);
};
@@ -166,9 +171,6 @@ class DownloadTestObserverTerminal : public DownloadTestObserver {
public:
// Create an object that will be considered finished when |wait_count|
// download items have entered a terminal state (any but IN_PROGRESS).
- // If |finish_on_select_file| is true, the object will also be
- // considered finished if the DownloadManager raises a
- // SelectFileDialogDisplayed() notification.
DownloadTestObserverTerminal(
DownloadManager* download_manager,
size_t wait_count,
@@ -184,16 +186,13 @@ class DownloadTestObserverTerminal : public DownloadTestObserver {
// Detects changes to the downloads after construction.
// Finishes when a specified number of downloads change to the
-// IN_PROGRESS state, or a Select File Dialog has appeared.
+// IN_PROGRESS state, or when the download manager is destroyed.
// Dangerous downloads are accepted.
// Callers may either probe for the finished state, or wait on it.
class DownloadTestObserverInProgress : public DownloadTestObserver {
public:
// Create an object that will be considered finished when |wait_count|
// download items have entered state |IN_PROGRESS|.
- // If |finish_on_select_file| is true, the object will also be
- // considered finished if the DownloadManager raises a
- // SelectFileDialogDisplayed() notification.
DownloadTestObserverInProgress(
DownloadManager* download_manager, size_t wait_count);
« no previous file with comments | « no previous file | content/public/test/download_test_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698