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

Unified Diff: content/browser/download/download_worker.cc

Issue 2872943003: Reduce unnecessary download interruptions due to parallel requests (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_worker.cc
diff --git a/content/browser/download/download_worker.cc b/content/browser/download/download_worker.cc
index 6e330a28f4ef41528d37a64fb7edd8f43fe5f24f..0fcc1c9a365e275982909362a3a5834d541537ee 100644
--- a/content/browser/download/download_worker.cc
+++ b/content/browser/download/download_worker.cc
@@ -13,6 +13,23 @@ namespace {
const int kVerboseLevel = 1;
+class CompletedByteStreamReader : public ByteStreamReader {
+ public:
+ CompletedByteStreamReader(int status) : status_(status){};
xingliu 2017/05/10 01:40:17 nit: space between ) and {}.
qinmin 2017/05/10 17:47:24 wierd, this is the result of "git cl format". Fixe
+ ~CompletedByteStreamReader() override = default;
+
+ // ByteStreamReader implementations:
+ ByteStreamReader::StreamState Read(scoped_refptr<net::IOBuffer>* data,
+ size_t* length) override {
+ return ByteStreamReader::STREAM_COMPLETE;
+ }
+ int GetStatus() const override { return status_; }
+ void RegisterCallback(const base::Closure& sink_callback) override{};
xingliu 2017/05/10 01:40:17 nit: also space here.
qinmin 2017/05/10 17:47:24 Done.
+
+ private:
+ int status_;
+};
+
std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>
CreateUrlDownloader(std::unique_ptr<DownloadUrlParameters> params,
base::WeakPtr<UrlDownloader::Delegate> delegate) {
@@ -94,9 +111,7 @@ void DownloadWorker::OnUrlDownloaderStarted(
DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) {
VLOG(kVerboseLevel) << "Parallel download sub-request failed. reason = "
<< create_info->result;
-
- delegate_->OnServerResponseError(this, create_info->result);
- return;
+ stream_reader.reset(new CompletedByteStreamReader(create_info->result));
}
request_handle_ = std::move(create_info->request_handle);

Powered by Google App Engine
This is Rietveld 408576698