OLD | NEW |
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/network/url_loader_impl.h" | 5 #include "content/network/url_loader_impl.h" |
6 | 6 |
7 #include "base/task_scheduler/post_task.h" | 7 #include "base/task_scheduler/post_task.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "content/common/url_loader_factory.mojom.h" | 10 #include "content/common/url_loader_factory.mojom.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 std::move(downloaded_file_ptr)); | 261 std::move(downloaded_file_ptr)); |
262 | 262 |
263 net::IOBufferWithSize* metadata = url_request->response_info().metadata.get(); | 263 net::IOBufferWithSize* metadata = url_request->response_info().metadata.get(); |
264 if (metadata) { | 264 if (metadata) { |
265 const uint8_t* data = reinterpret_cast<const uint8_t*>(metadata->data()); | 265 const uint8_t* data = reinterpret_cast<const uint8_t*>(metadata->data()); |
266 | 266 |
267 url_loader_client_->OnReceiveCachedMetadata( | 267 url_loader_client_->OnReceiveCachedMetadata( |
268 std::vector<uint8_t>(data, data + metadata->size())); | 268 std::vector<uint8_t>(data, data + metadata->size())); |
269 } | 269 } |
270 | 270 |
271 MojoCreateDataPipeOptions options; | 271 mojo::DataPipe data_pipe(kDefaultAllocationSize); |
272 options.struct_size = sizeof(MojoCreateDataPipeOptions); | |
273 options.flags = MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE; | |
274 options.element_num_bytes = 1; | |
275 options.capacity_num_bytes = kDefaultAllocationSize; | |
276 mojo::DataPipe data_pipe(options); | |
277 | |
278 DCHECK(data_pipe.producer_handle.is_valid()); | |
279 DCHECK(data_pipe.consumer_handle.is_valid()); | |
280 | 272 |
281 response_body_stream_ = std::move(data_pipe.producer_handle); | 273 response_body_stream_ = std::move(data_pipe.producer_handle); |
282 response_body_consumer_handle_ = std::move(data_pipe.consumer_handle); | 274 response_body_consumer_handle_ = std::move(data_pipe.consumer_handle); |
283 peer_closed_handle_watcher_.Watch( | 275 peer_closed_handle_watcher_.Watch( |
284 response_body_stream_.get(), MOJO_HANDLE_SIGNAL_PEER_CLOSED, | 276 response_body_stream_.get(), MOJO_HANDLE_SIGNAL_PEER_CLOSED, |
285 base::Bind(&URLLoaderImpl::OnResponseBodyStreamClosed, | 277 base::Bind(&URLLoaderImpl::OnResponseBodyStreamClosed, |
286 base::Unretained(this))); | 278 base::Unretained(this))); |
287 peer_closed_handle_watcher_.ArmOrNotify(); | 279 peer_closed_handle_watcher_.ArmOrNotify(); |
288 | 280 |
289 writable_handle_watcher_.Watch( | 281 writable_handle_watcher_.Watch( |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 ReadMore(); | 395 ReadMore(); |
404 } | 396 } |
405 | 397 |
406 void URLLoaderImpl::DeleteIfNeeded() { | 398 void URLLoaderImpl::DeleteIfNeeded() { |
407 bool has_data_pipe = pending_write_.get() || response_body_stream_.is_valid(); | 399 bool has_data_pipe = pending_write_.get() || response_body_stream_.is_valid(); |
408 if (!connected_ && !has_data_pipe) | 400 if (!connected_ && !has_data_pipe) |
409 delete this; | 401 delete this; |
410 } | 402 } |
411 | 403 |
412 } // namespace content | 404 } // namespace content |
OLD | NEW |