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

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: Exclude certain files from jumbo because of a Windows problem Created 3 years, 3 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 void DownloadWorker::OnUrlDownloadStarted( 98 void DownloadWorker::OnUrlDownloadStarted(
99 std::unique_ptr<DownloadCreateInfo> create_info, 99 std::unique_ptr<DownloadCreateInfo> create_info,
100 std::unique_ptr<DownloadManager::InputStream> input_stream, 100 std::unique_ptr<DownloadManager::InputStream> input_stream,
101 const DownloadUrlParameters::OnStartedCallback& callback) { 101 const DownloadUrlParameters::OnStartedCallback& callback) {
102 // |callback| is not used in subsequent requests. 102 // |callback| is not used in subsequent requests.
103 DCHECK(callback.is_null()); 103 DCHECK(callback.is_null());
104 104
105 // Destroy the request if user canceled. 105 // Destroy the request if user canceled.
106 if (is_canceled_) { 106 if (is_canceled_) {
107 VLOG(kVerboseLevel) << "Byte stream arrived after user cancel the request."; 107 VLOG(kWorkerVerbosityLevel) << "Byte stream arrived after user cancel the re quest.";
108 create_info->request_handle->CancelRequest(is_user_cancel_); 108 create_info->request_handle->CancelRequest(is_user_cancel_);
109 return; 109 return;
110 } 110 }
111 111
112 // TODO(xingliu): Add metric for error handling. 112 // TODO(xingliu): Add metric for error handling.
113 if (create_info->result != 113 if (create_info->result !=
114 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) { 114 DownloadInterruptReason::DOWNLOAD_INTERRUPT_REASON_NONE) {
115 VLOG(kVerboseLevel) << "Parallel download sub-request failed. reason = " 115 VLOG(kWorkerVerbosityLevel) << "Parallel download sub-request failed. reason = "
116 << create_info->result; 116 << create_info->result;
117 input_stream->stream_reader_.reset( 117 input_stream->stream_reader_.reset(
118 new CompletedByteStreamReader(create_info->result)); 118 new CompletedByteStreamReader(create_info->result));
119 } 119 }
120 120
121 request_handle_ = std::move(create_info->request_handle); 121 request_handle_ = std::move(create_info->request_handle);
122 122
123 // Pause the stream if user paused, still push the stream reader to the sink. 123 // Pause the stream if user paused, still push the stream reader to the sink.
124 if (is_paused_) { 124 if (is_paused_) {
125 VLOG(kVerboseLevel) << "Byte stream arrived after user pause the request."; 125 VLOG(kWorkerVerbosityLevel) << "Byte stream arrived after user pause the req uest.";
126 Pause(); 126 Pause();
127 } 127 }
128 128
129 delegate_->OnByteStreamReady(this, std::move(input_stream->stream_reader_)); 129 delegate_->OnByteStreamReady(this, std::move(input_stream->stream_reader_));
130 } 130 }
131 131
132 void DownloadWorker::OnUrlDownloadStopped(UrlDownloadHandler* downloader) { 132 void DownloadWorker::OnUrlDownloadStopped(UrlDownloadHandler* downloader) {
133 // Release the |url_download_handler_|, the object will be deleted on IO 133 // Release the |url_download_handler_|, the object will be deleted on IO
134 // thread. 134 // thread.
135 url_download_handler_.reset(); 135 url_download_handler_.reset();
136 } 136 }
137 137
138 void DownloadWorker::AddUrlDownloadHandler( 138 void DownloadWorker::AddUrlDownloadHandler(
139 std::unique_ptr<UrlDownloadHandler, BrowserThread::DeleteOnIOThread> 139 std::unique_ptr<UrlDownloadHandler, BrowserThread::DeleteOnIOThread>
140 downloader) { 140 downloader) {
141 url_download_handler_ = std::move(downloader); 141 url_download_handler_ = std::move(downloader);
142 } 142 }
143 143
144 } // namespace content 144 } // 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