Chromium Code Reviews| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "content/browser/download/download_request_core.h" | 12 #include "content/browser/download/download_request_core.h" |
| 13 #include "content/public/browser/download_save_info.h" | 13 #include "content/public/browser/download_save_info.h" |
| 14 #include "content/public/browser/download_url_parameters.h" | 14 #include "content/public/browser/download_url_parameters.h" |
| 15 #include "content/public/common/referrer.h" | 15 #include "content/public/common/referrer.h" |
| 16 #include "net/url_request/redirect_info.h" | 16 #include "net/url_request/redirect_info.h" |
| 17 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class ByteStreamReader; | |
| 21 struct DownloadCreateInfo; | |
| 20 class DownloadManagerImpl; | 22 class DownloadManagerImpl; |
| 21 | 23 |
| 22 class UrlDownloader : public net::URLRequest::Delegate { | 24 class UrlDownloader : public net::URLRequest::Delegate { |
| 23 public: | 25 public: |
| 24 UrlDownloader( | 26 UrlDownloader( |
| 25 scoped_ptr<net::URLRequest> request, | 27 scoped_ptr<net::URLRequest> request, |
| 26 base::WeakPtr<DownloadManagerImpl> manager, | 28 base::WeakPtr<DownloadManagerImpl> manager, |
| 27 scoped_ptr<DownloadSaveInfo> save_info, | 29 scoped_ptr<DownloadSaveInfo> save_info, |
| 28 uint32_t download_id, | 30 uint32_t download_id, |
| 29 const DownloadUrlParameters::OnStartedCallback& on_started_callback); | 31 const DownloadUrlParameters::OnStartedCallback& on_started_callback); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 53 | 55 |
| 54 void CallStartedCallbackOnFailure(DownloadInterruptReason result); | 56 void CallStartedCallbackOnFailure(DownloadInterruptReason result); |
| 55 | 57 |
| 56 private: | 58 private: |
| 57 class RequestHandle; | 59 class RequestHandle; |
| 58 | 60 |
| 59 void PauseRequest(); | 61 void PauseRequest(); |
| 60 void ResumeRequest(); | 62 void ResumeRequest(); |
| 61 void CancelRequest(); | 63 void CancelRequest(); |
| 62 | 64 |
| 65 // Called when the UrlDownloader is done with the request. Posts a task to | |
| 66 // remove itself from its download manager, which in turn would cause the | |
| 67 // UrlDownloader to be freed. | |
| 68 void Done(); | |
|
svaldez
2016/01/13 17:29:18
Can we call it Destroy since this doesn't necessar
asanka
2016/01/28 02:24:17
Done.
| |
| 69 | |
| 63 scoped_ptr<net::URLRequest> request_; | 70 scoped_ptr<net::URLRequest> request_; |
| 64 base::WeakPtr<DownloadManagerImpl> manager_; | 71 base::WeakPtr<DownloadManagerImpl> manager_; |
| 65 uint32_t download_id_; | 72 uint32_t download_id_; |
| 66 DownloadUrlParameters::OnStartedCallback on_started_callback_; | 73 DownloadUrlParameters::OnStartedCallback on_started_callback_; |
| 67 | 74 |
| 68 DownloadRequestCore handler_; | 75 DownloadRequestCore handler_; |
| 69 | 76 |
| 70 base::WeakPtrFactory<UrlDownloader> weak_ptr_factory_; | 77 base::WeakPtrFactory<UrlDownloader> weak_ptr_factory_; |
| 71 }; | 78 }; |
| 72 | 79 |
| 73 } // namespace content | 80 } // namespace content |
| 74 | 81 |
| 75 #endif // CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ | 82 #endif // CONTENT_BROWSER_DOWNLOAD_URL_DOWNLOADER_H_ |
| OLD | NEW |