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

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

Issue 2867693004: Snapshot of all changes to get jumbo in blink and content.
Patch Set: Rebased again Created 3 years, 5 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
11 namespace content { 11 namespace content {
12 namespace { 12 namespace {
13 13
14 const int kVerboseLevel = 1; 14 const int kWorkerVerbosityLevel = 1;
15 15
16 class CompletedByteStreamReader : public ByteStreamReader { 16 class CompletedByteStreamReader : public ByteStreamReader {
17 public: 17 public:
18 CompletedByteStreamReader(int status) : status_(status) {}; 18 CompletedByteStreamReader(int status) : status_(status) {};
19 ~CompletedByteStreamReader() override = default; 19 ~CompletedByteStreamReader() override = default;
20 20
21 // ByteStreamReader implementations: 21 // ByteStreamReader implementations:
22 ByteStreamReader::StreamState Read(scoped_refptr<net::IOBuffer>* data, 22 ByteStreamReader::StreamState Read(scoped_refptr<net::IOBuffer>* data,
23 size_t* length) override { 23 size_t* length) override {
24 return ByteStreamReader::STREAM_COMPLETE; 24 return ByteStreamReader::STREAM_COMPLETE;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 void DownloadWorker::OnUrlDownloaderStarted( 97 void DownloadWorker::OnUrlDownloaderStarted(
98 std::unique_ptr<DownloadCreateInfo> create_info, 98 std::unique_ptr<DownloadCreateInfo> create_info,
99 std::unique_ptr<ByteStreamReader> stream_reader, 99 std::unique_ptr<ByteStreamReader> stream_reader,
100 const DownloadUrlParameters::OnStartedCallback& callback) { 100 const DownloadUrlParameters::OnStartedCallback& callback) {
101 // |callback| is not used in subsequent requests. 101 // |callback| is not used in subsequent requests.
102 DCHECK(callback.is_null()); 102 DCHECK(callback.is_null());
103 103
104 // Destroy the request if user canceled. 104 // Destroy the request if user canceled.
105 if (is_canceled_) { 105 if (is_canceled_) {
106 VLOG(kVerboseLevel) << "Byte stream arrived after user cancel the request."; 106 VLOG(kWorkerVerbosityLevel) << "Byte stream arrived after user cancel the re quest.";
107 create_info->request_handle->CancelRequest(is_user_cancel_); 107 create_info->request_handle->CancelRequest(is_user_cancel_);
108 return; 108 return;
109 } 109 }
110 110
111 // TODO(xingliu): Add metric for error handling. 111 // TODO(xingliu): Add metric for error handling.
112 if (create_info->result != 112 if (create_info->result !=
113 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) { 113 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) {
114 VLOG(kVerboseLevel) << "Parallel download sub-request failed. reason = " 114 VLOG(kWorkerVerbosityLevel) << "Parallel download sub-request failed. reason = "
115 << create_info->result; 115 << create_info->result;
116 stream_reader.reset(new CompletedByteStreamReader(create_info->result)); 116 stream_reader.reset(new CompletedByteStreamReader(create_info->result));
117 } 117 }
118 118
119 request_handle_ = std::move(create_info->request_handle); 119 request_handle_ = std::move(create_info->request_handle);
120 120
121 // Pause the stream if user paused, still push the stream reader to the sink. 121 // Pause the stream if user paused, still push the stream reader to the sink.
122 if (is_paused_) { 122 if (is_paused_) {
123 VLOG(kVerboseLevel) << "Byte stream arrived after user pause the request."; 123 VLOG(kWorkerVerbosityLevel) << "Byte stream arrived after user pause the req uest.";
124 Pause(); 124 Pause();
125 } 125 }
126 126
127 delegate_->OnByteStreamReady(this, std::move(stream_reader)); 127 delegate_->OnByteStreamReady(this, std::move(stream_reader));
128 } 128 }
129 129
130 void DownloadWorker::OnUrlDownloaderStopped(UrlDownloader* downloader) { 130 void DownloadWorker::OnUrlDownloaderStopped(UrlDownloader* downloader) {
131 // Release the |url_downloader_|, the object will be deleted on IO thread. 131 // Release the |url_downloader_|, the object will be deleted on IO thread.
132 url_downloader_.reset(); 132 url_downloader_.reset();
133 } 133 }
134 134
135 void DownloadWorker::AddUrlDownloader( 135 void DownloadWorker::AddUrlDownloader(
136 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread> 136 std::unique_ptr<UrlDownloader, BrowserThread::DeleteOnIOThread>
137 downloader) { 137 downloader) {
138 url_downloader_ = std::move(downloader); 138 url_downloader_ = std::move(downloader);
139 } 139 }
140 140
141 } // namespace content 141 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/dom_storage/local_storage_context_mojo.cc ('k') | content/browser/fileapi/fileapi_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698