OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/network/url_loader_impl.h" | 5 #include "mojo/services/network/url_loader_impl.h" |
6 | 6 |
7 #include "mojo/common/common_type_converters.h" | 7 #include "mojo/common/common_type_converters.h" |
8 #include "mojo/services/network/network_context.h" | 8 #include "mojo/services/network/network_context.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/load_flags.h" | 10 #include "net/base/load_flags.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 client()->OnReceivedError(error.Pass()); | 200 client()->OnReceivedError(error.Pass()); |
201 } | 201 } |
202 | 202 |
203 void URLLoaderImpl::ReadMore() { | 203 void URLLoaderImpl::ReadMore() { |
204 DCHECK(!pending_write_); | 204 DCHECK(!pending_write_); |
205 | 205 |
206 pending_write_ = new PendingWriteToDataPipe(response_body_stream_.Pass()); | 206 pending_write_ = new PendingWriteToDataPipe(response_body_stream_.Pass()); |
207 | 207 |
208 uint32_t num_bytes; | 208 uint32_t num_bytes; |
209 if (!pending_write_->BeginWrite(&num_bytes)) | 209 if (!pending_write_->BeginWrite(&num_bytes)) |
210 CHECK(false); // Oops! | 210 CHECK(false); // Oops! TODO(darin): crbug/386877: The pipe might be full! |
211 if (num_bytes > static_cast<uint32_t>(std::numeric_limits<int>::max())) | 211 if (num_bytes > static_cast<uint32_t>(std::numeric_limits<int>::max())) |
212 CHECK(false); // Oops! | 212 CHECK(false); // Oops! |
213 | 213 |
214 scoped_refptr<net::IOBuffer> buf = new DependentIOBuffer(pending_write_); | 214 scoped_refptr<net::IOBuffer> buf = new DependentIOBuffer(pending_write_); |
215 | 215 |
216 int bytes_read; | 216 int bytes_read; |
217 url_request_->Read(buf, static_cast<int>(num_bytes), &bytes_read); | 217 url_request_->Read(buf, static_cast<int>(num_bytes), &bytes_read); |
218 | 218 |
219 // Drop our reference to the buffer. | 219 // Drop our reference to the buffer. |
220 buf = NULL; | 220 buf = NULL; |
(...skipping 23 matching lines...) Expand all Loading... |
244 if (completed_synchronously) { | 244 if (completed_synchronously) { |
245 base::MessageLoop::current()->PostTask( | 245 base::MessageLoop::current()->PostTask( |
246 FROM_HERE, | 246 FROM_HERE, |
247 base::Bind(&URLLoaderImpl::ReadMore, weak_ptr_factory_.GetWeakPtr())); | 247 base::Bind(&URLLoaderImpl::ReadMore, weak_ptr_factory_.GetWeakPtr())); |
248 } else { | 248 } else { |
249 ReadMore(); | 249 ReadMore(); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 } // namespace mojo | 253 } // namespace mojo |
OLD | NEW |