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

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

Issue 14593012: BrowserContext should simply own DownloadManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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..75ecef3181dfa7056e1573c669711227993f053c 100644
--- a/content/public/test/download_test_observer.h
+++ b/content/public/test/download_test_observer.h
@@ -55,11 +55,7 @@ class DownloadUpdatedObserver : public DownloadItem::Observer {
// - Specific events, such as a select file dialog.
// Callers may either probe for the finished state, or wait on it.
//
-// 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.)
+// TODO: Transition to finish when manager goes down.
benjhayden 2013/05/17 14:50:03 Does this require more than `if (waiting_) base::M
cmarcelo 2013/05/20 15:22:06 It would work in current code base, but would brea
class DownloadTestObserver : public DownloadManager::Observer,
public DownloadItem::Observer {
public:
@@ -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);
};

Powered by Google App Engine
This is Rietveld 408576698