| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
| 6 | 6 |
| 7 #include "content/child/resource_dispatcher.h" | 7 #include "content/child/resource_dispatcher.h" |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 void OnReceiveResponse(const ResourceResponseHead& response_head) override { | 93 void OnReceiveResponse(const ResourceResponseHead& response_head) override { |
| 94 has_received_response_ = true; | 94 has_received_response_ = true; |
| 95 if (body_consumer_) | 95 if (body_consumer_) |
| 96 body_consumer_->Start(task_runner_.get()); | 96 body_consumer_->Start(task_runner_.get()); |
| 97 resource_dispatcher_->OnMessageReceived( | 97 resource_dispatcher_->OnMessageReceived( |
| 98 ResourceMsg_ReceivedResponse(request_id_, response_head)); | 98 ResourceMsg_ReceivedResponse(request_id_, response_head)); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void OnReceiveRedirect(const net::RedirectInfo& redirect_info, |
| 102 const ResourceResponseHead& response_head) override { |
| 103 DCHECK(!has_received_response_); |
| 104 DCHECK(!body_consumer_); |
| 105 resource_dispatcher_->OnMessageReceived(ResourceMsg_ReceivedRedirect( |
| 106 request_id_, redirect_info, response_head)); |
| 107 } |
| 108 |
| 101 void OnDataDownloaded(int64_t data_len, int64_t encoded_data_len) override { | 109 void OnDataDownloaded(int64_t data_len, int64_t encoded_data_len) override { |
| 102 resource_dispatcher_->OnMessageReceived( | 110 resource_dispatcher_->OnMessageReceived( |
| 103 ResourceMsg_DataDownloaded(request_id_, data_len, encoded_data_len)); | 111 ResourceMsg_DataDownloaded(request_id_, data_len, encoded_data_len)); |
| 104 } | 112 } |
| 105 | 113 |
| 106 void OnStartLoadingResponseBody( | 114 void OnStartLoadingResponseBody( |
| 107 mojo::ScopedDataPipeConsumerHandle body) override { | 115 mojo::ScopedDataPipeConsumerHandle body) override { |
| 108 DCHECK(!body_consumer_); | 116 DCHECK(!body_consumer_); |
| 109 body_consumer_ = new URLResponseBodyConsumer( | 117 body_consumer_ = new URLResponseBodyConsumer( |
| 110 request_id_, resource_dispatcher_, std::move(body), task_runner_); | 118 request_id_, resource_dispatcher_, std::move(body), task_runner_); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 411 } |
| 404 } else { | 412 } else { |
| 405 Cancel(request_id); | 413 Cancel(request_id); |
| 406 } | 414 } |
| 407 } | 415 } |
| 408 | 416 |
| 409 void ResourceDispatcher::FollowPendingRedirect( | 417 void ResourceDispatcher::FollowPendingRedirect( |
| 410 int request_id, | 418 int request_id, |
| 411 PendingRequestInfo* request_info) { | 419 PendingRequestInfo* request_info) { |
| 412 IPC::Message* msg = request_info->pending_redirect_message.release(); | 420 IPC::Message* msg = request_info->pending_redirect_message.release(); |
| 413 if (msg) | 421 if (msg) { |
| 414 message_sender_->Send(msg); | 422 if (request_info->url_loader) { |
| 423 request_info->url_loader->FollowRedirect(); |
| 424 delete msg; |
| 425 } else { |
| 426 message_sender_->Send(msg); |
| 427 } |
| 428 } |
| 415 } | 429 } |
| 416 | 430 |
| 417 void ResourceDispatcher::OnRequestComplete( | 431 void ResourceDispatcher::OnRequestComplete( |
| 418 int request_id, | 432 int request_id, |
| 419 const ResourceRequestCompletionStatus& request_complete_data) { | 433 const ResourceRequestCompletionStatus& request_complete_data) { |
| 420 TRACE_EVENT0("loader", "ResourceDispatcher::OnRequestComplete"); | 434 TRACE_EVENT0("loader", "ResourceDispatcher::OnRequestComplete"); |
| 421 | 435 |
| 422 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 436 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 423 if (!request_info) | 437 if (!request_info) |
| 424 return; | 438 return; |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 delete message; | 851 delete message; |
| 838 } | 852 } |
| 839 } | 853 } |
| 840 | 854 |
| 841 void ResourceDispatcher::SetResourceSchedulingFilter( | 855 void ResourceDispatcher::SetResourceSchedulingFilter( |
| 842 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { | 856 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter) { |
| 843 resource_scheduling_filter_ = resource_scheduling_filter; | 857 resource_scheduling_filter_ = resource_scheduling_filter; |
| 844 } | 858 } |
| 845 | 859 |
| 846 } // namespace content | 860 } // namespace content |
| OLD | NEW |