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

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 trunk 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 729d5bbc4e0846edf716a15b5c9af47247778ca3..3e7ac7067a398bbc15b5d01ba1475137d0fac6ab 100644
--- a/chrome/browser/download/download_test_observer.cc
+++ b/chrome/browser/download/download_test_observer.cc
@@ -341,3 +341,33 @@ void DownloadTestFlushObserver::PingIOThread(int cycle) {
BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
}
}
+
+DownloadTestItemCreationObserver::DownloadTestItemCreationObserver(size_t count)
+ : expected_count_(count),
+ called_back_count_(0),
+ waiting_(false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(callback_(base::Bind(
+ &DownloadTestItemCreationObserver::DownloadItemCreationCallback,
+ this))) {
+ creation_info_.resize(count);
+}
+
+void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
+ if (called_back_count_ < expected_count_) {
+ waiting_ = true;
+ ui_test_utils::RunMessageLoop();
+ waiting_ = false;
+ }
+}
+
+void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
+ content::DownloadId download_id, net::Error error) {
+ if (called_back_count_ >= creation_info_.size())
+ creation_info_.resize(creation_info_.size() + 1);
+ creation_info_[called_back_count_].download_id = download_id;
+ creation_info_[called_back_count_].error = error;
+ ++called_back_count_;
+
+ if (waiting_ && (called_back_count_ >= expected_count_))
+ MessageLoopForUI::current()->Quit();
+}

Powered by Google App Engine
This is Rietveld 408576698