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

Unified Diff: content/browser/download/url_downloader.h

Issue 2689373003: Introduce ParallelDownloadJob. (Closed)
Patch Set: nits. Created 3 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: content/browser/download/url_downloader.h
diff --git a/content/browser/download/url_downloader.h b/content/browser/download/url_downloader.h
index ffbc7e6483eebbbfc352b493432739b43a43bbbb..4ba35d0c8a39c867564f0ab531a06b92e9e23a38 100644
--- a/content/browser/download/url_downloader.h
+++ b/content/browser/download/url_downloader.h
@@ -21,17 +21,30 @@
namespace content {
class ByteStreamReader;
struct DownloadCreateInfo;
-class DownloadManagerImpl;
class UrlDownloader : public net::URLRequest::Delegate,
public DownloadRequestCore::Delegate {
public:
+ // Implemented by the owner of UrlDownloader, functions need to be called on
+ // UI thread.
+ class Delegate {
+ public:
+ // Called after response is handled and the byte stream is established.
+ virtual void OnUrlDownloaderStarted(
+ std::unique_ptr<DownloadCreateInfo> download_create_info,
+ std::unique_ptr<ByteStreamReader> stream_reader,
+ const DownloadUrlParameters::OnStartedCallback& callback) = 0;
+
+ // Called after the connection is cannceled or finished.
+ virtual void OnUrlDownloaderStopped(UrlDownloader* downloader) = 0;
+ };
+
UrlDownloader(std::unique_ptr<net::URLRequest> request,
- base::WeakPtr<DownloadManagerImpl> manager);
+ base::WeakPtr<Delegate> delegate);
~UrlDownloader() override;
static std::unique_ptr<UrlDownloader> BeginDownload(
- base::WeakPtr<DownloadManagerImpl> download_manager,
+ base::WeakPtr<UrlDownloader::Delegate> delegate,
std::unique_ptr<net::URLRequest> request,
const Referrer& referrer);
@@ -67,7 +80,9 @@ class UrlDownloader : public net::URLRequest::Delegate,
void Destroy();
std::unique_ptr<net::URLRequest> request_;
- base::WeakPtr<DownloadManagerImpl> manager_;
+
+ // Live on UI thread, post task to call |delegate_| functions.
+ base::WeakPtr<Delegate> delegate_;
DownloadRequestCore core_;
base::WeakPtrFactory<UrlDownloader> weak_ptr_factory_;
« no previous file with comments | « content/browser/download/parallel_download_job_unittest.cc ('k') | content/browser/download/url_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698