OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ | 5 #ifndef CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ |
6 #define CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ | 6 #define CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "content/browser/download/download_request_core.h" | 10 #include "content/browser/download/download_request_core.h" |
11 #include "content/public/browser/download_save_info.h" | 11 #include "content/public/browser/download_save_info.h" |
12 #include "content/public/browser/download_url_parameters.h" | 12 #include "content/public/browser/download_url_parameters.h" |
13 #include "content/public/common/referrer.h" | 13 #include "content/public/common/referrer.h" |
14 #include "net/url_request/redirect_info.h" | 14 #include "net/url_request/redirect_info.h" |
15 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class ByteStreamReader; | |
19 struct DownloadCreateInfo; | |
svaldez
2015/12/17 16:53:32
Are these still needed?
asanka
2015/12/21 20:14:02
Nope. Only DownloadManagerImpl is needed. Thanks!
| |
18 class DownloadManagerImpl; | 20 class DownloadManagerImpl; |
19 class DownloadRequestCore; | 21 class DownloadRequestCore; |
20 | 22 |
21 class UrlDownloader : public net::URLRequest::Delegate { | 23 class UrlDownloader : public net::URLRequest::Delegate { |
22 public: | 24 public: |
23 UrlDownloader(scoped_ptr<net::URLRequest> request, | 25 UrlDownloader( |
24 scoped_ptr<DownloadRequestCore> handler, | 26 scoped_ptr<net::URLRequest> request, |
25 base::WeakPtr<DownloadManagerImpl> manager); | 27 base::WeakPtr<DownloadManagerImpl> manager, |
28 scoped_ptr<DownloadSaveInfo> save_info, | |
29 uint32 download_id, | |
30 const DownloadUrlParameters::OnStartedCallback& on_started_callback); | |
26 ~UrlDownloader() override; | 31 ~UrlDownloader() override; |
27 | 32 |
28 static scoped_ptr<UrlDownloader> BeginDownload( | 33 static scoped_ptr<UrlDownloader> BeginDownload( |
29 base::WeakPtr<DownloadManagerImpl> download_manager, | 34 base::WeakPtr<DownloadManagerImpl> download_manager, |
30 scoped_ptr<net::URLRequest> request, | 35 scoped_ptr<net::URLRequest> request, |
31 const Referrer& referrer, | 36 const Referrer& referrer, |
32 bool is_content_initiated, | |
33 bool prefer_cache, | 37 bool prefer_cache, |
34 bool do_not_prompt_for_login, | |
35 scoped_ptr<DownloadSaveInfo> save_info, | 38 scoped_ptr<DownloadSaveInfo> save_info, |
36 uint32 download_id, | 39 uint32 download_id, |
37 const DownloadUrlParameters::OnStartedCallback& started_callback); | 40 const DownloadUrlParameters::OnStartedCallback& started_callback); |
38 | 41 |
39 // URLRequest::Delegate: | 42 // URLRequest::Delegate: |
40 void OnReceivedRedirect(net::URLRequest* request, | 43 void OnReceivedRedirect(net::URLRequest* request, |
41 const net::RedirectInfo& redirect_info, | 44 const net::RedirectInfo& redirect_info, |
42 bool* defer_redirect) override; | 45 bool* defer_redirect) override; |
43 void OnResponseStarted(net::URLRequest* request) override; | 46 void OnResponseStarted(net::URLRequest* request) override; |
44 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | 47 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
45 | 48 |
46 void StartReading(bool is_continuation); | 49 void StartReading(bool is_continuation); |
47 void ResponseCompleted(); | 50 void ResponseCompleted(); |
48 | 51 |
49 void Start(); | 52 void Start(); |
50 void ResumeReading(); | 53 void ResumeReading(); |
51 | 54 |
55 void CallStartedCallbackOnFailure(DownloadInterruptReason result); | |
56 | |
52 private: | 57 private: |
58 class RequestHandle; | |
59 | |
60 void PauseRequest(); | |
61 void ResumeRequest(); | |
62 void CancelRequest(); | |
63 | |
53 scoped_ptr<net::URLRequest> request_; | 64 scoped_ptr<net::URLRequest> request_; |
54 scoped_ptr<DownloadRequestCore> handler_; | |
55 base::WeakPtr<DownloadManagerImpl> manager_; | 65 base::WeakPtr<DownloadManagerImpl> manager_; |
66 uint32 download_id_; | |
67 DownloadUrlParameters::OnStartedCallback on_started_callback_; | |
68 | |
69 DownloadRequestCore handler_; | |
56 | 70 |
57 base::WeakPtrFactory<UrlDownloader> weak_ptr_factory_; | 71 base::WeakPtrFactory<UrlDownloader> weak_ptr_factory_; |
58 }; | 72 }; |
59 | 73 |
60 } // namespace content | 74 } // namespace content |
61 | 75 |
62 #endif // CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ | 76 #endif // CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ |
OLD | NEW |