| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "content/browser/download/download_job_impl.h" | 5 #include "content/browser/download/download_job_impl.h" |
| 6 | 6 |
| 7 #include "content/public/browser/web_contents.h" | 7 #include "content/public/browser/web_contents.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| 11 DownloadJobImpl::DownloadJobImpl( | 11 DownloadJobImpl::DownloadJobImpl( |
| 12 DownloadItemImpl* download_item, | 12 DownloadItemImpl* download_item, |
| 13 std::unique_ptr<DownloadRequestHandleInterface> request_handle, | 13 std::unique_ptr<DownloadRequestHandleInterface> request_handle, |
| 14 bool is_parallizable) | 14 bool is_parallizable) |
| 15 : DownloadJob(download_item), | 15 : DownloadJob(download_item), |
| 16 request_handle_(std::move(request_handle)), | 16 request_handle_(std::move(request_handle)), |
| 17 is_parallizable_(is_parallizable) {} | 17 is_parallizable_(is_parallizable) {} |
| 18 | 18 |
| 19 DownloadJobImpl::~DownloadJobImpl() = default; | 19 DownloadJobImpl::~DownloadJobImpl() = default; |
| 20 | 20 |
| 21 void DownloadJobImpl::Start() { | |
| 22 DownloadJob::StartDownload(); | |
| 23 } | |
| 24 | |
| 25 void DownloadJobImpl::Cancel(bool user_cancel) { | 21 void DownloadJobImpl::Cancel(bool user_cancel) { |
| 26 if (request_handle_) | 22 if (request_handle_) |
| 27 request_handle_->CancelRequest(); | 23 request_handle_->CancelRequest(); |
| 28 } | 24 } |
| 29 | 25 |
| 30 void DownloadJobImpl::Pause() { | 26 void DownloadJobImpl::Pause() { |
| 31 DownloadJob::Pause(); | 27 DownloadJob::Pause(); |
| 32 if (request_handle_) | 28 if (request_handle_) |
| 33 request_handle_->PauseRequest(); | 29 request_handle_->PauseRequest(); |
| 34 } | 30 } |
| 35 | 31 |
| 36 void DownloadJobImpl::Resume(bool resume_request) { | 32 void DownloadJobImpl::Resume(bool resume_request) { |
| 37 DownloadJob::Resume(resume_request); | 33 DownloadJob::Resume(resume_request); |
| 38 if (!resume_request) | 34 if (!resume_request) |
| 39 return; | 35 return; |
| 40 | 36 |
| 41 if (request_handle_) | 37 if (request_handle_) |
| 42 request_handle_->ResumeRequest(); | 38 request_handle_->ResumeRequest(); |
| 43 } | 39 } |
| 44 | 40 |
| 45 WebContents* DownloadJobImpl::GetWebContents() const { | 41 WebContents* DownloadJobImpl::GetWebContents() const { |
| 46 return request_handle_ ? request_handle_->GetWebContents() : nullptr; | 42 return request_handle_ ? request_handle_->GetWebContents() : nullptr; |
| 47 } | 43 } |
| 48 | 44 |
| 49 bool DownloadJobImpl::IsParallelizable() const { | 45 bool DownloadJobImpl::IsParallelizable() const { |
| 50 return is_parallizable_; | 46 return is_parallizable_; |
| 51 } | 47 } |
| 52 | 48 |
| 53 } // namespace content | 49 } // namespace content |
| OLD | NEW |