OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/url_downloader.h" | 5 #include "content/browser/download/url_downloader.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/threading/sequenced_task_runner_handle.h" | 10 #include "base/threading/sequenced_task_runner_handle.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 void UrlDownloader::StartReading(bool is_continuation) { | 138 void UrlDownloader::StartReading(bool is_continuation) { |
139 int bytes_read; | 139 int bytes_read; |
140 | 140 |
141 // Make sure we track the buffer in at least one place. This ensures it gets | 141 // Make sure we track the buffer in at least one place. This ensures it gets |
142 // deleted even in the case the request has already finished its job and | 142 // deleted even in the case the request has already finished its job and |
143 // doesn't use the buffer. | 143 // doesn't use the buffer. |
144 scoped_refptr<net::IOBuffer> buf; | 144 scoped_refptr<net::IOBuffer> buf; |
145 int buf_size; | 145 int buf_size; |
146 if (!core_.OnWillRead(&buf, &buf_size, -1)) { | 146 if (!core_.OnWillRead(&buf, &buf_size)) { |
147 int result = request_->CancelWithError(net::ERR_ABORTED); | 147 int result = request_->CancelWithError(net::ERR_ABORTED); |
148 base::SequencedTaskRunnerHandle::Get()->PostTask( | 148 base::SequencedTaskRunnerHandle::Get()->PostTask( |
149 FROM_HERE, base::Bind(&UrlDownloader::ResponseCompleted, | 149 FROM_HERE, base::Bind(&UrlDownloader::ResponseCompleted, |
150 weak_ptr_factory_.GetWeakPtr(), result)); | 150 weak_ptr_factory_.GetWeakPtr(), result)); |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
154 DCHECK(buf.get()); | 154 DCHECK(buf.get()); |
155 DCHECK(buf_size > 0); | 155 DCHECK(buf_size > 0); |
156 | 156 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 Destroy(); | 238 Destroy(); |
239 } | 239 } |
240 | 240 |
241 void UrlDownloader::Destroy() { | 241 void UrlDownloader::Destroy() { |
242 BrowserThread::PostTask( | 242 BrowserThread::PostTask( |
243 BrowserThread::UI, FROM_HERE, | 243 BrowserThread::UI, FROM_HERE, |
244 base::Bind(&DownloadManagerImpl::RemoveUrlDownloader, manager_, this)); | 244 base::Bind(&DownloadManagerImpl::RemoveUrlDownloader, manager_, this)); |
245 } | 245 } |
246 | 246 |
247 } // namespace content | 247 } // namespace content |
OLD | NEW |