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

Side by Side Diff: content/browser/download/download_worker.cc

Issue 2786523002: Add control to use If-Range header for range request. (Closed)
Patch Set: Rebase. Created 3 years, 8 months 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 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // |callback| is not used in subsequent requests. 82 // |callback| is not used in subsequent requests.
83 DCHECK(callback.is_null()); 83 DCHECK(callback.is_null());
84 84
85 // Destroy the request if user canceled. 85 // Destroy the request if user canceled.
86 if (is_canceled_) { 86 if (is_canceled_) {
87 VLOG(kVerboseLevel) << "Byte stream arrived after user cancel the request."; 87 VLOG(kVerboseLevel) << "Byte stream arrived after user cancel the request.";
88 create_info->request_handle->CancelRequest(); 88 create_info->request_handle->CancelRequest();
89 return; 89 return;
90 } 90 }
91 91
92 // TODO(xingliu): Add the interrupt reason and metric data for precondition 92 // TODO(xingliu): Add metric for error handling.
93 // failure. Make DownloadRequestCore know if it should return error if the
94 // the server gives a different part of the content, e.g. "If-Match" return
95 // http 200.
96 if (create_info->result != 93 if (create_info->result !=
97 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) { 94 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) {
98 VLOG(kVerboseLevel) << "Parallel download sub-request failed. reason = " 95 VLOG(kVerboseLevel) << "Parallel download sub-request failed. reason = "
99 << create_info->result; 96 << create_info->result;
97
98 // Ignore HTTP 416 for the workers.
99 if (create_info->result ==
qinmin 2017/03/30 05:21:43 {} needed as this if statement spans multiple line
xingliu 2017/03/30 17:16:46 Done.
100 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_SERVER_NO_RANGE)
101 return;
102
100 delegate_->OnServerResponseError(this, create_info->result); 103 delegate_->OnServerResponseError(this, create_info->result);
101 return; 104 return;
102 } 105 }
103 106
104 request_handle_ = std::move(create_info->request_handle); 107 request_handle_ = std::move(create_info->request_handle);
105 108
106 // Pause the stream if user paused, still push the stream reader to the sink. 109 // Pause the stream if user paused, still push the stream reader to the sink.
107 if (is_paused_) { 110 if (is_paused_) {
108 VLOG(kVerboseLevel) << "Byte stream arrived after user pause the request."; 111 VLOG(kVerboseLevel) << "Byte stream arrived after user pause the request.";
109 Pause(); 112 Pause();
110 } 113 }
111 114
112 delegate_->OnByteStreamReady(this, std::move(stream_reader)); 115 delegate_->OnByteStreamReady(this, std::move(stream_reader));
113 } 116 }
114 117
115 void DownloadWorker::OnUrlDownloaderStopped(UrlDownloader* downloader) { 118 void DownloadWorker::OnUrlDownloaderStopped(UrlDownloader* downloader) {
116 // Release the |url_downloader_|, the object will be deleted on IO thread. 119 // Release the |url_downloader_|, the object will be deleted on IO thread.
117 url_downloader_.reset(); 120 url_downloader_.reset();
118 } 121 }
119 122
120 void DownloadWorker::AddUrlDownloader( 123 void DownloadWorker::AddUrlDownloader(
121 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> 124 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>
122 downloader) { 125 downloader) {
123 url_downloader_ = std::move(downloader); 126 url_downloader_ = std::move(downloader);
124 } 127 }
125 128
126 } // namespace content 129 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698