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

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, 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
« no previous file with comments | « chrome/browser/download/download_test_observer.h ('k') | chrome/browser/extensions/webstore_installer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 9d8ca881539d603b61e207e396103acc05cf07bc..5624128c82d17afc164bf872caf6cc44fab32f7d 100644
--- a/chrome/browser/download/download_test_observer.cc
+++ b/chrome/browser/download/download_test_observer.cc
@@ -360,3 +360,43 @@ void DownloadTestFlushObserver::PingIOThread(int cycle) {
BrowserThread::UI, FROM_HERE, MessageLoop::QuitClosure());
}
}
+
+DownloadTestItemCreationObserver::DownloadTestItemCreationObserver()
+ : download_id_(content::DownloadId::Invalid()),
+ error_(net::OK),
+ called_back_count_(0),
+ waiting_(false) {
+}
+
+DownloadTestItemCreationObserver::~DownloadTestItemCreationObserver() {
+}
+
+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_;
+ DCHECK_EQ(1u, called_back_count_);
+
+ if (waiting_)
+ MessageLoopForUI::current()->Quit();
+}
+
+const content::DownloadManager::OnStartedCallback
+ DownloadTestItemCreationObserver::callback() {
+ return base::Bind(
+ &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this);
+}
+
« no previous file with comments | « chrome/browser/download/download_test_observer.h ('k') | chrome/browser/extensions/webstore_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698