| 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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 472 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 473 if (!request_info) | 473 if (!request_info) |
| 474 return; | 474 return; |
| 475 | 475 |
| 476 request_info->peer->OnDownloadedData(data_len, encoded_data_length); | 476 request_info->peer->OnDownloadedData(data_len, encoded_data_length); |
| 477 } | 477 } |
| 478 | 478 |
| 479 void ResourceDispatcher::OnReceivedRedirect( | 479 void ResourceDispatcher::OnReceivedRedirect( |
| 480 int request_id, | 480 int request_id, |
| 481 const GURL& new_url, | 481 const GURL& new_url, |
| 482 const GURL& new_first_party_for_cookies, |
| 482 const ResourceResponseHead& response_head) { | 483 const ResourceResponseHead& response_head) { |
| 483 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedRedirect"); | 484 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedRedirect"); |
| 484 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 485 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 485 if (!request_info) | 486 if (!request_info) |
| 486 return; | 487 return; |
| 487 request_info->response_start = ConsumeIOTimestamp(); | 488 request_info->response_start = ConsumeIOTimestamp(); |
| 488 | 489 |
| 489 bool has_new_first_party_for_cookies = false; | |
| 490 GURL new_first_party_for_cookies; | |
| 491 ResourceResponseInfo renderer_response_info; | 490 ResourceResponseInfo renderer_response_info; |
| 492 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info); | 491 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info); |
| 493 if (request_info->peer->OnReceivedRedirect(new_url, renderer_response_info, | 492 if (request_info->peer->OnReceivedRedirect( |
| 494 &has_new_first_party_for_cookies, | 493 new_url, new_first_party_for_cookies, renderer_response_info)) { |
| 495 &new_first_party_for_cookies)) { | |
| 496 // Double-check if the request is still around. The call above could | 494 // Double-check if the request is still around. The call above could |
| 497 // potentially remove it. | 495 // potentially remove it. |
| 498 request_info = GetPendingRequestInfo(request_id); | 496 request_info = GetPendingRequestInfo(request_id); |
| 499 if (!request_info) | 497 if (!request_info) |
| 500 return; | 498 return; |
| 501 // We update the response_url here so that we can send it to | 499 // We update the response_url here so that we can send it to |
| 502 // SiteIsolationPolicy later when OnReceivedResponse is called. | 500 // SiteIsolationPolicy later when OnReceivedResponse is called. |
| 503 request_info->response_url = new_url; | 501 request_info->response_url = new_url; |
| 504 request_info->pending_redirect_message.reset( | 502 request_info->pending_redirect_message.reset( |
| 505 new ResourceHostMsg_FollowRedirect(request_id, | 503 new ResourceHostMsg_FollowRedirect(request_id)); |
| 506 has_new_first_party_for_cookies, | |
| 507 new_first_party_for_cookies)); | |
| 508 if (!request_info->is_deferred) { | 504 if (!request_info->is_deferred) { |
| 509 FollowPendingRedirect(request_id, *request_info); | 505 FollowPendingRedirect(request_id, *request_info); |
| 510 } | 506 } |
| 511 } else { | 507 } else { |
| 512 CancelPendingRequest(request_id); | 508 CancelPendingRequest(request_id); |
| 513 } | 509 } |
| 514 } | 510 } |
| 515 | 511 |
| 516 void ResourceDispatcher::FollowPendingRedirect( | 512 void ResourceDispatcher::FollowPendingRedirect( |
| 517 int request_id, | 513 int request_id, |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 801 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
| 806 while (!queue->empty()) { | 802 while (!queue->empty()) { |
| 807 IPC::Message* message = queue->front(); | 803 IPC::Message* message = queue->front(); |
| 808 ReleaseResourcesInDataMessage(*message); | 804 ReleaseResourcesInDataMessage(*message); |
| 809 queue->pop_front(); | 805 queue->pop_front(); |
| 810 delete message; | 806 delete message; |
| 811 } | 807 } |
| 812 } | 808 } |
| 813 | 809 |
| 814 } // namespace content | 810 } // namespace content |
| OLD | NEW |