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(); |
+} |