| 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_worker.h" | 5 #include "content/browser/download/download_worker.h" |
| 6 | 6 |
| 7 #include "content/browser/download/download_create_info.h" | 7 #include "content/browser/download/download_create_info.h" |
| 8 #include "content/public/browser/download_interrupt_reasons.h" | 8 #include "content/public/browser/download_interrupt_reasons.h" |
| 9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
| 10 | 10 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 create_info->request_handle->CancelRequest(); | 88 create_info->request_handle->CancelRequest(); |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // TODO(xingliu): Add metric for error handling. | 92 // TODO(xingliu): Add metric for error handling. |
| 93 if (create_info->result != | 93 if (create_info->result != |
| 94 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) { | 94 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) { |
| 95 VLOG(kVerboseLevel) << "Parallel download sub-request failed. reason = " | 95 VLOG(kVerboseLevel) << "Parallel download sub-request failed. reason = " |
| 96 << create_info->result; | 96 << create_info->result; |
| 97 | 97 |
| 98 // Ignore HTTP 416 for the workers. | |
| 99 if (create_info->result == | |
| 100 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE) { | |
| 101 return; | |
| 102 } | |
| 103 | |
| 104 delegate_->OnServerResponseError(this, create_info->result); | 98 delegate_->OnServerResponseError(this, create_info->result); |
| 105 return; | 99 return; |
| 106 } | 100 } |
| 107 | 101 |
| 108 request_handle_ = std::move(create_info->request_handle); | 102 request_handle_ = std::move(create_info->request_handle); |
| 109 | 103 |
| 110 // Pause the stream if user paused, still push the stream reader to the sink. | 104 // Pause the stream if user paused, still push the stream reader to the sink. |
| 111 if (is_paused_) { | 105 if (is_paused_) { |
| 112 VLOG(kVerboseLevel) << "Byte stream arrived after user pause the request."; | 106 VLOG(kVerboseLevel) << "Byte stream arrived after user pause the request."; |
| 113 Pause(); | 107 Pause(); |
| 114 } | 108 } |
| 115 | 109 |
| 116 delegate_->OnByteStreamReady(this, std::move(stream_reader)); | 110 delegate_->OnByteStreamReady(this, std::move(stream_reader)); |
| 117 } | 111 } |
| 118 | 112 |
| 119 void DownloadWorker::OnUrlDownloaderStopped(UrlDownloader* downloader) { | 113 void DownloadWorker::OnUrlDownloaderStopped(UrlDownloader* downloader) { |
| 120 // Release the |url_downloader_|, the object will be deleted on IO thread. | 114 // Release the |url_downloader_|, the object will be deleted on IO thread. |
| 121 url_downloader_.reset(); | 115 url_downloader_.reset(); |
| 122 } | 116 } |
| 123 | 117 |
| 124 void DownloadWorker::AddUrlDownloader( | 118 void DownloadWorker::AddUrlDownloader( |
| 125 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> | 119 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> |
| 126 downloader) { | 120 downloader) { |
| 127 url_downloader_ = std::move(downloader); | 121 url_downloader_ = std::move(downloader); |
| 128 } | 122 } |
| 129 | 123 |
| 130 } // namespace content | 124 } // namespace content |
| OLD | NEW |