| 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 479 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 480 if (!request_info) | 480 if (!request_info) |
| 481 return; | 481 return; |
| 482 | 482 |
| 483 request_info->peer->OnDownloadedData(data_len, encoded_data_length); | 483 request_info->peer->OnDownloadedData(data_len, encoded_data_length); |
| 484 } | 484 } |
| 485 | 485 |
| 486 void ResourceDispatcher::OnReceivedRedirect( | 486 void ResourceDispatcher::OnReceivedRedirect( |
| 487 int request_id, | 487 int request_id, |
| 488 const GURL& new_url, | 488 const GURL& new_url, |
| 489 const GURL& new_first_party_for_cookies, |
| 489 const ResourceResponseHead& response_head) { | 490 const ResourceResponseHead& response_head) { |
| 490 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedRedirect"); | 491 TRACE_EVENT0("loader", "ResourceDispatcher::OnReceivedRedirect"); |
| 491 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); | 492 PendingRequestInfo* request_info = GetPendingRequestInfo(request_id); |
| 492 if (!request_info) | 493 if (!request_info) |
| 493 return; | 494 return; |
| 494 request_info->response_start = ConsumeIOTimestamp(); | 495 request_info->response_start = ConsumeIOTimestamp(); |
| 495 | 496 |
| 496 bool has_new_first_party_for_cookies = false; | |
| 497 GURL new_first_party_for_cookies; | |
| 498 ResourceResponseInfo renderer_response_info; | 497 ResourceResponseInfo renderer_response_info; |
| 499 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info); | 498 ToResourceResponseInfo(*request_info, response_head, &renderer_response_info); |
| 500 if (request_info->peer->OnReceivedRedirect(new_url, renderer_response_info, | 499 if (request_info->peer->OnReceivedRedirect( |
| 501 &has_new_first_party_for_cookies, | 500 new_url, new_first_party_for_cookies, renderer_response_info)) { |
| 502 &new_first_party_for_cookies)) { | |
| 503 // Double-check if the request is still around. The call above could | 501 // Double-check if the request is still around. The call above could |
| 504 // potentially remove it. | 502 // potentially remove it. |
| 505 request_info = GetPendingRequestInfo(request_id); | 503 request_info = GetPendingRequestInfo(request_id); |
| 506 if (!request_info) | 504 if (!request_info) |
| 507 return; | 505 return; |
| 508 // We update the response_url here so that we can send it to | 506 // We update the response_url here so that we can send it to |
| 509 // SiteIsolationPolicy later when OnReceivedResponse is called. | 507 // SiteIsolationPolicy later when OnReceivedResponse is called. |
| 510 request_info->response_url = new_url; | 508 request_info->response_url = new_url; |
| 511 request_info->pending_redirect_message.reset( | 509 request_info->pending_redirect_message.reset( |
| 512 new ResourceHostMsg_FollowRedirect(request_id, | 510 new ResourceHostMsg_FollowRedirect(request_id)); |
| 513 has_new_first_party_for_cookies, | |
| 514 new_first_party_for_cookies)); | |
| 515 if (!request_info->is_deferred) { | 511 if (!request_info->is_deferred) { |
| 516 FollowPendingRedirect(request_id, *request_info); | 512 FollowPendingRedirect(request_id, *request_info); |
| 517 } | 513 } |
| 518 } else { | 514 } else { |
| 519 CancelPendingRequest(request_id); | 515 CancelPendingRequest(request_id); |
| 520 } | 516 } |
| 521 } | 517 } |
| 522 | 518 |
| 523 void ResourceDispatcher::FollowPendingRedirect( | 519 void ResourceDispatcher::FollowPendingRedirect( |
| 524 int request_id, | 520 int request_id, |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { | 867 void ResourceDispatcher::ReleaseResourcesInMessageQueue(MessageQueue* queue) { |
| 872 while (!queue->empty()) { | 868 while (!queue->empty()) { |
| 873 IPC::Message* message = queue->front(); | 869 IPC::Message* message = queue->front(); |
| 874 ReleaseResourcesInDataMessage(*message); | 870 ReleaseResourcesInDataMessage(*message); |
| 875 queue->pop_front(); | 871 queue->pop_front(); |
| 876 delete message; | 872 delete message; |
| 877 } | 873 } |
| 878 } | 874 } |
| 879 | 875 |
| 880 } // namespace content | 876 } // namespace content |
| OLD | NEW |