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 #include "content/browser/loader/async_resource_handler.h" | 5 #include "content/browser/loader/async_resource_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 bool* message_was_ok) { | 101 bool* message_was_ok) { |
102 bool handled = true; | 102 bool handled = true; |
103 IPC_BEGIN_MESSAGE_MAP_EX(AsyncResourceHandler, message, *message_was_ok) | 103 IPC_BEGIN_MESSAGE_MAP_EX(AsyncResourceHandler, message, *message_was_ok) |
104 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) | 104 IPC_MESSAGE_HANDLER(ResourceHostMsg_FollowRedirect, OnFollowRedirect) |
105 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) | 105 IPC_MESSAGE_HANDLER(ResourceHostMsg_DataReceived_ACK, OnDataReceivedACK) |
106 IPC_MESSAGE_UNHANDLED(handled = false) | 106 IPC_MESSAGE_UNHANDLED(handled = false) |
107 IPC_END_MESSAGE_MAP_EX() | 107 IPC_END_MESSAGE_MAP_EX() |
108 return handled; | 108 return handled; |
109 } | 109 } |
110 | 110 |
111 void AsyncResourceHandler::OnFollowRedirect( | 111 void AsyncResourceHandler::OnFollowRedirect(int request_id) { |
112 int request_id, | |
113 bool has_new_first_party_for_cookies, | |
114 const GURL& new_first_party_for_cookies) { | |
115 if (!request()->status().is_success()) { | 112 if (!request()->status().is_success()) { |
116 DVLOG(1) << "OnFollowRedirect for invalid request"; | 113 DVLOG(1) << "OnFollowRedirect for invalid request"; |
117 return; | 114 return; |
118 } | 115 } |
119 | 116 |
120 if (has_new_first_party_for_cookies) | |
121 request()->set_first_party_for_cookies(new_first_party_for_cookies); | |
122 | |
123 ResumeIfDeferred(); | 117 ResumeIfDeferred(); |
124 } | 118 } |
125 | 119 |
126 void AsyncResourceHandler::OnDataReceivedACK(int request_id) { | 120 void AsyncResourceHandler::OnDataReceivedACK(int request_id) { |
127 if (pending_data_count_) { | 121 if (pending_data_count_) { |
128 --pending_data_count_; | 122 --pending_data_count_; |
129 | 123 |
130 buffer_->RecycleLeastRecentlyAllocated(); | 124 buffer_->RecycleLeastRecentlyAllocated(); |
131 if (buffer_->CanAllocate()) | 125 if (buffer_->CanAllocate()) |
132 ResumeIfDeferred(); | 126 ResumeIfDeferred(); |
(...skipping 24 matching lines...) Expand all Loading... |
157 if (rdh_->delegate()) { | 151 if (rdh_->delegate()) { |
158 rdh_->delegate()->OnRequestRedirected( | 152 rdh_->delegate()->OnRequestRedirected( |
159 new_url, request(), info->GetContext(), response); | 153 new_url, request(), info->GetContext(), response); |
160 } | 154 } |
161 | 155 |
162 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); | 156 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); |
163 response->head.encoded_data_length = request()->GetTotalReceivedBytes(); | 157 response->head.encoded_data_length = request()->GetTotalReceivedBytes(); |
164 reported_transfer_size_ = 0; | 158 reported_transfer_size_ = 0; |
165 response->head.request_start = request()->creation_time(); | 159 response->head.request_start = request()->creation_time(); |
166 response->head.response_start = TimeTicks::Now(); | 160 response->head.response_start = TimeTicks::Now(); |
| 161 // TODO(davidben): Is it necessary to pass the new first party URL for |
| 162 // cookies? The only case where it can change is top-level navigation requests |
| 163 // and hopefully those will eventually all be owned by the browser. It's |
| 164 // possible this is still needed while renderer-owned ones exist. |
167 return info->filter()->Send(new ResourceMsg_ReceivedRedirect( | 165 return info->filter()->Send(new ResourceMsg_ReceivedRedirect( |
168 request_id, new_url, response->head)); | 166 request_id, new_url, request()->first_party_for_cookies(), |
| 167 response->head)); |
169 } | 168 } |
170 | 169 |
171 bool AsyncResourceHandler::OnResponseStarted(int request_id, | 170 bool AsyncResourceHandler::OnResponseStarted(int request_id, |
172 ResourceResponse* response, | 171 ResourceResponse* response, |
173 bool* defer) { | 172 bool* defer) { |
174 // For changes to the main frame, inform the renderer of the new URL's | 173 // For changes to the main frame, inform the renderer of the new URL's |
175 // per-host settings before the request actually commits. This way the | 174 // per-host settings before the request actually commits. This way the |
176 // renderer will be able to set these precisely at the time the | 175 // renderer will be able to set these precisely at the time the |
177 // request commits, avoiding the possibility of e.g. zooming the old content | 176 // request commits, avoiding the possibility of e.g. zooming the old content |
178 // or of having to layout the new content twice. | 177 // or of having to layout the new content twice. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 request()->LogUnblocked(); | 403 request()->LogUnblocked(); |
405 controller()->Resume(); | 404 controller()->Resume(); |
406 } | 405 } |
407 } | 406 } |
408 | 407 |
409 void AsyncResourceHandler::OnDefer() { | 408 void AsyncResourceHandler::OnDefer() { |
410 request()->LogBlockedBy("AsyncResourceHandler"); | 409 request()->LogBlockedBy("AsyncResourceHandler"); |
411 } | 410 } |
412 | 411 |
413 } // namespace content | 412 } // namespace content |
OLD | NEW |