| 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/renderer_host/async_resource_handler.h" | 5 #include "content/browser/renderer_host/async_resource_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return filter_->Send(new ResourceMsg_UploadProgress(routing_id_, request_id, | 137 return filter_->Send(new ResourceMsg_UploadProgress(routing_id_, request_id, |
| 138 position, size)); | 138 position, size)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool AsyncResourceHandler::OnRequestRedirected(int request_id, | 141 bool AsyncResourceHandler::OnRequestRedirected(int request_id, |
| 142 const GURL& new_url, | 142 const GURL& new_url, |
| 143 ResourceResponse* response, | 143 ResourceResponse* response, |
| 144 bool* defer) { | 144 bool* defer) { |
| 145 *defer = did_defer_ = true; | 145 *defer = did_defer_ = true; |
| 146 | 146 |
| 147 if (rdh_->delegate()) | 147 if (rdh_->delegate()) { |
| 148 rdh_->delegate()->OnRequestRedirected(request_, response); | 148 rdh_->delegate()->OnRequestRedirected(request_, filter_->resource_context(), |
| 149 response); |
| 150 } |
| 151 *defer = true; |
| 149 | 152 |
| 150 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); | 153 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); |
| 151 response->head.request_start = request_->creation_time(); | 154 response->head.request_start = request_->creation_time(); |
| 152 response->head.response_start = TimeTicks::Now(); | 155 response->head.response_start = TimeTicks::Now(); |
| 153 return filter_->Send(new ResourceMsg_ReceivedRedirect( | 156 return filter_->Send(new ResourceMsg_ReceivedRedirect( |
| 154 routing_id_, request_id, new_url, response->head)); | 157 routing_id_, request_id, new_url, response->head)); |
| 155 } | 158 } |
| 156 | 159 |
| 157 bool AsyncResourceHandler::OnResponseStarted(int request_id, | 160 bool AsyncResourceHandler::OnResponseStarted(int request_id, |
| 158 ResourceResponse* response, | 161 ResourceResponse* response, |
| 159 bool* defer) { | 162 bool* defer) { |
| 160 // For changes to the main frame, inform the renderer of the new URL's | 163 // For changes to the main frame, inform the renderer of the new URL's |
| 161 // per-host settings before the request actually commits. This way the | 164 // per-host settings before the request actually commits. This way the |
| 162 // renderer will be able to set these precisely at the time the | 165 // renderer will be able to set these precisely at the time the |
| 163 // request commits, avoiding the possibility of e.g. zooming the old content | 166 // request commits, avoiding the possibility of e.g. zooming the old content |
| 164 // or of having to layout the new content twice. | 167 // or of having to layout the new content twice. |
| 165 | 168 |
| 166 if (rdh_->delegate()) | 169 content::ResourceContext* resource_context = filter_->resource_context(); |
| 167 rdh_->delegate()->OnResponseStarted(request_, response, filter_); | 170 if (rdh_->delegate()) { |
| 171 rdh_->delegate()->OnResponseStarted(request_, resource_context, response, |
| 172 filter_); |
| 173 } |
| 168 | 174 |
| 169 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); | 175 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); |
| 170 | 176 |
| 171 ResourceContext* resource_context = filter_->resource_context(); | |
| 172 HostZoomMap* host_zoom_map = | 177 HostZoomMap* host_zoom_map = |
| 173 GetHostZoomMapForResourceContext(resource_context); | 178 GetHostZoomMapForResourceContext(resource_context); |
| 174 | 179 |
| 175 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); | 180 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); |
| 176 if (info->GetResourceType() == ResourceType::MAIN_FRAME && host_zoom_map) { | 181 if (info->GetResourceType() == ResourceType::MAIN_FRAME && host_zoom_map) { |
| 177 const GURL& request_url = request_->url(); | 182 const GURL& request_url = request_->url(); |
| 178 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( | 183 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( |
| 179 info->GetRouteID(), | 184 info->GetRouteID(), |
| 180 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL( | 185 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL( |
| 181 request_url)))); | 186 request_url)))); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 } | 335 } |
| 331 | 336 |
| 332 void AsyncResourceHandler::ResumeIfDeferred() { | 337 void AsyncResourceHandler::ResumeIfDeferred() { |
| 333 if (did_defer_) { | 338 if (did_defer_) { |
| 334 did_defer_ = false; | 339 did_defer_ = false; |
| 335 controller()->Resume(); | 340 controller()->Resume(); |
| 336 } | 341 } |
| 337 } | 342 } |
| 338 | 343 |
| 339 } // namespace content | 344 } // namespace content |
| OLD | NEW |