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

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: Fixed CLANG issue. Created 8 years, 9 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 94f8f7d16d5e5de38218fda1706c56572bb4a8d5..56b061fd05c3125f3fb1d8d59b3e8e137a79c5e2 100644
--- a/chrome/browser/download/download_test_observer.cc
+++ b/chrome/browser/download/download_test_observer.cc
@@ -318,3 +318,42 @@ void DownloadTestFlushObserver::PingIOThread(int cycle) {
BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
}
}
+
+DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() {
cbentzel 2012/03/08 17:58:48 Nit: comes after the constructor.
ahendrickson 2012/03/08 21:33:07 Done.
+}
+
+DownloadTestItemCreationObserver::DownloadTestItemCreationObserver()
+ : download_id_(content::DownloadId::Invalid()),
+ error_(net::OK),
+ called_back_count_(0),
+ waiting_(false) {
+}
+
+void DownloadTestItemCreationObserver::WaitForDownloadItemCreation() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (called_back_count_ == 0) {
+ waiting_ = true;
+ ui_test_utils::RunMessageLoop();
+ waiting_ = false;
+ }
+}
+
+void DownloadTestItemCreationObserver::DownloadItemCreationCallback(
+ content::DownloadId download_id, net::Error error) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ download_id_ = download_id;
+ error_ = error;
+ ++called_back_count_;
+
+ if (waiting_ && (called_back_count_ > 0))
cbentzel 2012/03/08 17:58:48 called_back_count_ will always be > 0. Do you need
ahendrickson 2012/03/08 21:33:07 Ah, this is kind of left over from when I was wait
+ MessageLoopForUI::current()->Quit();
+}
+
+const content::DownloadManager::OnStartedCallback
+ DownloadTestItemCreationObserver::callback() {
+ return base::Bind(
+ &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
+}
+

Powered by Google App Engine
This is Rietveld 408576698