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

Unified Diff: chrome/browser/download/download_test_observer.cc

Issue 9570005: Added callback to DownloadUrl() so we can find download failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with parent Created 8 years, 10 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: chrome/browser/download/download_test_observer.cc
diff --git a/chrome/browser/download/download_test_observer.cc b/chrome/browser/download/download_test_observer.cc
index 6e82cc9eef1506c3cf4d84fc231a2523d2a05e71..02038739b2ce12d827c184e650288d24bf4f11eb 100644
--- a/chrome/browser/download/download_test_observer.cc
+++ b/chrome/browser/download/download_test_observer.cc
@@ -346,3 +346,32 @@ void DownloadTestFlushObserver::PingIOThread(int cycle) {
BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
}
}
+
+DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() {
+}
+
+DownloadTestItemCreationObserver::DownloadTestItemCreationObserver()
+ : called_back_count_(0),
+ waiting_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(callback_(base::Bind(
+ &DownloadTestItemCreationObserver::DownloadItemCreationCallback,
+ this))) {
+}
+
+void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
+ if (called_back_count_ == 0) {
+ waiting_ = true;
+ ui_test_utils::RunMessageLoop();
+ waiting_ = false;
+ }
+}
+
+void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
+ content::DownloadId download_id, net::Error error) {
+ creation_info_.download_id = download_id;
cbentzel 2012/03/02 21:00:18 Can you add a DCHECK that this is called on the UI
ahendrickson 2012/03/02 21:51:41 Done.
+ creation_info_.error = error;
+ ++called_back_count_;
+
+ if (waiting_ && (called_back_count_ > 0))
+ MessageLoopForUI::current()->Quit();
+}

Powered by Google App Engine
This is Rietveld 408576698