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

Side by Side Diff: content/browser/download/url_downloader.h

Issue 1533583002: [Downloads] Factor out request handling logic between DRH and UD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and change .Pass() -> std::move(...) per PRESUBMIT check Created 5 years 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 unified diff | Download patch
OLDNEW
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 DownloadManagerImpl; 18 class DownloadManagerImpl;
19 class DownloadRequestCore;
20 19
21 class UrlDownloader : public net::URLRequest::Delegate { 20 class UrlDownloader : public net::URLRequest::Delegate {
22 public: 21 public:
23 UrlDownloader(scoped_ptr<net::URLRequest> request, 22 UrlDownloader(
24 scoped_ptr<DownloadRequestCore> handler, 23 scoped_ptr<net::URLRequest> request,
25 base::WeakPtr<DownloadManagerImpl> manager); 24 base::WeakPtr<DownloadManagerImpl> manager,
25 scoped_ptr<DownloadSaveInfo> save_info,
26 uint32 download_id,
27 const DownloadUrlParameters::OnStartedCallback& on_started_callback);
26 ~UrlDownloader() override; 28 ~UrlDownloader() override;
27 29
28 static scoped_ptr<UrlDownloader> BeginDownload( 30 static scoped_ptr<UrlDownloader> BeginDownload(
29 base::WeakPtr<DownloadManagerImpl> download_manager, 31 base::WeakPtr<DownloadManagerImpl> download_manager,
30 scoped_ptr<net::URLRequest> request, 32 scoped_ptr<net::URLRequest> request,
31 const Referrer& referrer, 33 const Referrer& referrer,
32 bool is_content_initiated,
33 bool prefer_cache, 34 bool prefer_cache,
34 bool do_not_prompt_for_login,
35 scoped_ptr<DownloadSaveInfo> save_info, 35 scoped_ptr<DownloadSaveInfo> save_info,
36 uint32 download_id, 36 uint32 download_id,
37 const DownloadUrlParameters::OnStartedCallback& started_callback); 37 const DownloadUrlParameters::OnStartedCallback& started_callback);
38 38
39 // URLRequest::Delegate: 39 // URLRequest::Delegate:
40 void OnReceivedRedirect(net::URLRequest* request, 40 void OnReceivedRedirect(net::URLRequest* request,
41 const net::RedirectInfo& redirect_info, 41 const net::RedirectInfo& redirect_info,
42 bool* defer_redirect) override; 42 bool* defer_redirect) override;
43 void OnResponseStarted(net::URLRequest* request) override; 43 void OnResponseStarted(net::URLRequest* request) override;
44 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; 44 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
45 45
46 void StartReading(bool is_continuation); 46 void StartReading(bool is_continuation);
47 void ResponseCompleted(); 47 void ResponseCompleted();
48 48
49 void Start(); 49 void Start();
50 void ResumeReading(); 50 void ResumeReading();
51 51
52 void CallStartedCallbackOnFailure(DownloadInterruptReason result);
53
52 private: 54 private:
55 class RequestHandle;
56
57 void PauseRequest();
58 void ResumeRequest();
59 void CancelRequest();
60
53 scoped_ptr<net::URLRequest> request_; 61 scoped_ptr<net::URLRequest> request_;
54 scoped_ptr<DownloadRequestCore> handler_;
55 base::WeakPtr<DownloadManagerImpl> manager_; 62 base::WeakPtr<DownloadManagerImpl> manager_;
63 uint32 download_id_;
64 DownloadUrlParameters::OnStartedCallback on_started_callback_;
65
66 DownloadRequestCore handler_;
56 67
57 base::WeakPtrFactory<UrlDownloader> weak_ptr_factory_; 68 base::WeakPtrFactory<UrlDownloader> weak_ptr_factory_;
58 }; 69 };
59 70
60 } // namespace content 71 } // namespace content
61 72
62 #endif // CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ 73 #endif // CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_
OLDNEW
« no previous file with comments | « content/browser/download/download_resource_handler.cc ('k') | content/browser/download/url_downloader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698