| 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 11 matching lines...) Expand all Loading... |
| 22 #include "content/browser/loader/resource_request_info_impl.h" | 22 #include "content/browser/loader/resource_request_info_impl.h" |
| 23 #include "content/browser/resource_context_impl.h" | 23 #include "content/browser/resource_context_impl.h" |
| 24 #include "content/common/resource_messages.h" | 24 #include "content/common/resource_messages.h" |
| 25 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
| 26 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 26 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 27 #include "content/public/common/resource_response.h" | 27 #include "content/public/common/resource_response.h" |
| 28 #include "net/base/io_buffer.h" | 28 #include "net/base/io_buffer.h" |
| 29 #include "net/base/load_flags.h" | 29 #include "net/base/load_flags.h" |
| 30 #include "net/base/net_log.h" | 30 #include "net/base/net_log.h" |
| 31 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
| 32 #include "net/url_request/redirect_info.h" |
| 32 | 33 |
| 33 using base::TimeTicks; | 34 using base::TimeTicks; |
| 34 | 35 |
| 35 namespace content { | 36 namespace content { |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 static int kBufferSize = 1024 * 512; | 39 static int kBufferSize = 1024 * 512; |
| 39 static int kMinAllocationSize = 1024 * 4; | 40 static int kMinAllocationSize = 1024 * 4; |
| 40 static int kMaxAllocationSize = 1024 * 32; | 41 static int kMaxAllocationSize = 1024 * 32; |
| 41 | 42 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 128 |
| 128 bool AsyncResourceHandler::OnUploadProgress(uint64 position, | 129 bool AsyncResourceHandler::OnUploadProgress(uint64 position, |
| 129 uint64 size) { | 130 uint64 size) { |
| 130 ResourceMessageFilter* filter = GetFilter(); | 131 ResourceMessageFilter* filter = GetFilter(); |
| 131 if (!filter) | 132 if (!filter) |
| 132 return false; | 133 return false; |
| 133 return filter->Send( | 134 return filter->Send( |
| 134 new ResourceMsg_UploadProgress(GetRequestID(), position, size)); | 135 new ResourceMsg_UploadProgress(GetRequestID(), position, size)); |
| 135 } | 136 } |
| 136 | 137 |
| 137 bool AsyncResourceHandler::OnRequestRedirected(const GURL& new_url, | 138 bool AsyncResourceHandler::OnRequestRedirected( |
| 138 ResourceResponse* response, | 139 const net::RedirectInfo& redirect_info, |
| 139 bool* defer) { | 140 ResourceResponse* response, |
| 141 bool* defer) { |
| 140 const ResourceRequestInfoImpl* info = GetRequestInfo(); | 142 const ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 141 if (!info->filter()) | 143 if (!info->filter()) |
| 142 return false; | 144 return false; |
| 143 | 145 |
| 144 *defer = did_defer_ = true; | 146 *defer = did_defer_ = true; |
| 145 OnDefer(); | 147 OnDefer(); |
| 146 | 148 |
| 147 if (rdh_->delegate()) { | 149 if (rdh_->delegate()) { |
| 148 rdh_->delegate()->OnRequestRedirected( | 150 rdh_->delegate()->OnRequestRedirected( |
| 149 new_url, request(), info->GetContext(), response); | 151 redirect_info.url, request(), info->GetContext(), response); |
| 150 } | 152 } |
| 151 | 153 |
| 152 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); | 154 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); |
| 153 response->head.encoded_data_length = request()->GetTotalReceivedBytes(); | 155 response->head.encoded_data_length = request()->GetTotalReceivedBytes(); |
| 154 reported_transfer_size_ = 0; | 156 reported_transfer_size_ = 0; |
| 155 response->head.request_start = request()->creation_time(); | 157 response->head.request_start = request()->creation_time(); |
| 156 response->head.response_start = TimeTicks::Now(); | 158 response->head.response_start = TimeTicks::Now(); |
| 157 // TODO(davidben): Is it necessary to pass the new first party URL for | 159 // TODO(davidben): Is it necessary to pass the new first party URL for |
| 158 // cookies? The only case where it can change is top-level navigation requests | 160 // cookies? The only case where it can change is top-level navigation requests |
| 159 // and hopefully those will eventually all be owned by the browser. It's | 161 // and hopefully those will eventually all be owned by the browser. It's |
| 160 // possible this is still needed while renderer-owned ones exist. | 162 // possible this is still needed while renderer-owned ones exist. |
| 161 return info->filter()->Send(new ResourceMsg_ReceivedRedirect( | 163 return info->filter()->Send(new ResourceMsg_ReceivedRedirect( |
| 162 GetRequestID(), new_url, request()->first_party_for_cookies(), | 164 GetRequestID(), redirect_info, response->head)); |
| 163 response->head)); | |
| 164 } | 165 } |
| 165 | 166 |
| 166 bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response, | 167 bool AsyncResourceHandler::OnResponseStarted(ResourceResponse* response, |
| 167 bool* defer) { | 168 bool* defer) { |
| 168 // For changes to the main frame, inform the renderer of the new URL's | 169 // For changes to the main frame, inform the renderer of the new URL's |
| 169 // per-host settings before the request actually commits. This way the | 170 // per-host settings before the request actually commits. This way the |
| 170 // renderer will be able to set these precisely at the time the | 171 // renderer will be able to set these precisely at the time the |
| 171 // request commits, avoiding the possibility of e.g. zooming the old content | 172 // request commits, avoiding the possibility of e.g. zooming the old content |
| 172 // or of having to layout the new content twice. | 173 // or of having to layout the new content twice. |
| 173 | 174 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 request()->LogUnblocked(); | 391 request()->LogUnblocked(); |
| 391 controller()->Resume(); | 392 controller()->Resume(); |
| 392 } | 393 } |
| 393 } | 394 } |
| 394 | 395 |
| 395 void AsyncResourceHandler::OnDefer() { | 396 void AsyncResourceHandler::OnDefer() { |
| 396 request()->LogBlockedBy("AsyncResourceHandler"); | 397 request()->LogBlockedBy("AsyncResourceHandler"); |
| 397 } | 398 } |
| 398 | 399 |
| 399 } // namespace content | 400 } // namespace content |
| OLD | NEW |