Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(717)

Side by Side Diff: content/browser/renderer_host/async_resource_handler.cc

Issue 10416002: Seculative resource prefetching for URLs CL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moving to WeakPtrs and RVHD. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 bool AsyncResourceHandler::OnRequestRedirected( 103 bool AsyncResourceHandler::OnRequestRedirected(
104 int request_id, 104 int request_id,
105 const GURL& new_url, 105 const GURL& new_url,
106 content::ResourceResponse* response, 106 content::ResourceResponse* response,
107 bool* defer) { 107 bool* defer) {
108 *defer = true; 108 *defer = true;
109 net::URLRequest* request = rdh_->GetURLRequest( 109 net::URLRequest* request = rdh_->GetURLRequest(
110 GlobalRequestID(filter_->child_id(), request_id)); 110 GlobalRequestID(filter_->child_id(), request_id));
111 if (rdh_->delegate()) 111 if (rdh_->delegate())
112 rdh_->delegate()->OnRequestRedirected(request, response); 112 rdh_->delegate()->OnRequestRedirected(request, filter_->resource_context(),
113 response);
113 114
114 DevToolsNetLogObserver::PopulateResponseInfo(request, response); 115 DevToolsNetLogObserver::PopulateResponseInfo(request, response);
115 response->request_start = request->creation_time(); 116 response->request_start = request->creation_time();
116 response->response_start = TimeTicks::Now(); 117 response->response_start = TimeTicks::Now();
117 return filter_->Send(new ResourceMsg_ReceivedRedirect( 118 return filter_->Send(new ResourceMsg_ReceivedRedirect(
118 routing_id_, request_id, new_url, *response)); 119 routing_id_, request_id, new_url, *response));
119 } 120 }
120 121
121 bool AsyncResourceHandler::OnResponseStarted( 122 bool AsyncResourceHandler::OnResponseStarted(
122 int request_id, 123 int request_id,
123 content::ResourceResponse* response, 124 content::ResourceResponse* response,
124 bool* defer) { 125 bool* defer) {
125 // For changes to the main frame, inform the renderer of the new URL's 126 // For changes to the main frame, inform the renderer of the new URL's
126 // per-host settings before the request actually commits. This way the 127 // per-host settings before the request actually commits. This way the
127 // renderer will be able to set these precisely at the time the 128 // renderer will be able to set these precisely at the time the
128 // request commits, avoiding the possibility of e.g. zooming the old content 129 // request commits, avoiding the possibility of e.g. zooming the old content
129 // or of having to layout the new content twice. 130 // or of having to layout the new content twice.
130 net::URLRequest* request = rdh_->GetURLRequest( 131 net::URLRequest* request = rdh_->GetURLRequest(
131 GlobalRequestID(filter_->child_id(), request_id)); 132 GlobalRequestID(filter_->child_id(), request_id));
132 133
134 content::ResourceContext* resource_context = filter_->resource_context();
133 if (rdh_->delegate()) 135 if (rdh_->delegate())
134 rdh_->delegate()->OnResponseStarted(request, response, filter_); 136 rdh_->delegate()->OnResponseStarted(request, resource_context, response,
dominich 2012/05/30 15:35:01 nit: rdh_->delegate()->OnResponseStarted( requ
Shishir 2012/05/30 18:07:15 Its used in a couple of places so the var might be
137 filter_);
135 138
136 DevToolsNetLogObserver::PopulateResponseInfo(request, response); 139 DevToolsNetLogObserver::PopulateResponseInfo(request, response);
137 140
138 content::ResourceContext* resource_context = filter_->resource_context();
139 content::HostZoomMap* host_zoom_map = 141 content::HostZoomMap* host_zoom_map =
140 content::GetHostZoomMapForResourceContext(resource_context); 142 content::GetHostZoomMapForResourceContext(resource_context);
141 143
142 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 144 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
143 if (info->GetResourceType() == ResourceType::MAIN_FRAME && host_zoom_map) { 145 if (info->GetResourceType() == ResourceType::MAIN_FRAME && host_zoom_map) {
144 GURL request_url(request->url()); 146 GURL request_url(request->url());
145 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( 147 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL(
146 info->GetRouteID(), 148 info->GetRouteID(),
147 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL( 149 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(
148 request_url)))); 150 request_url))));
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 void AsyncResourceHandler::GlobalCleanup() { 284 void AsyncResourceHandler::GlobalCleanup() {
283 if (g_spare_read_buffer) { 285 if (g_spare_read_buffer) {
284 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). 286 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer().
285 SharedIOBuffer* tmp = g_spare_read_buffer; 287 SharedIOBuffer* tmp = g_spare_read_buffer;
286 g_spare_read_buffer = NULL; 288 g_spare_read_buffer = NULL;
287 tmp->Release(); 289 tmp->Release();
288 } 290 }
289 } 291 }
290 292
291 } // namespace content 293 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698