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

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

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_browsertest.cc ('k') | chrome/browser/download/download_test_observer.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.h
diff --git a/chrome/browser/download/download_test_observer.h b/chrome/browser/download/download_test_observer.h
index 1a3a2a018137c138dc14c3bce732ea51c684c128..1be27bec4d69edb2511f986a8df4c65c60a479a6 100644
--- a/chrome/browser/download/download_test_observer.h
+++ b/chrome/browser/download/download_test_observer.h
@@ -7,11 +7,13 @@
#pragma once
#include <set>
+#include <vector>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/download_manager.h"
+#include "net/base/net_errors.h"
// Detects changes to the downloads after construction.
// Finishes when one of the following happens:
@@ -239,4 +241,42 @@ class DownloadTestFlushObserver
DISALLOW_COPY_AND_ASSIGN(DownloadTestFlushObserver);
};
+// Waits for a callback indicating that the DownloadItem is about to be created,
+// or that an error occurred and it won't be created.
+class DownloadTestItemCreationObserver
+ : public base::RefCountedThreadSafe<DownloadTestItemCreationObserver> {
+ public:
+ DownloadTestItemCreationObserver();
+
+ void WaitForDownloadItemCreation();
+
+ content::DownloadId download_id() const { return download_id_; }
+ net::Error error() const { return error_; }
+ bool started() const { return called_back_count_ > 0; }
+ bool succeeded() const { return started() && (error_ == net::OK); }
+
+ const content::DownloadManager::OnStartedCallback callback();
+
+ private:
+ friend class base::RefCountedThreadSafe<DownloadTestItemCreationObserver>;
+
+ ~DownloadTestItemCreationObserver();
+
+ void DownloadItemCreationCallback(content::DownloadId download_id,
+ net::Error error);
+
+ // The download creation information we received.
+ content::DownloadId download_id_;
+
+ net::Error error_;
+
+ // Count of callbacks.
+ size_t called_back_count_;
+
+ // We are in the message loop.
+ bool waiting_;
+
+ DISALLOW_COPY_AND_ASSIGN(DownloadTestItemCreationObserver);
+};
+
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TEST_OBSERVER_H_
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/download/download_test_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698