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

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: Fixing enum name. 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 bool AsyncResourceHandler::OnRequestRedirected(int request_id, 103 bool AsyncResourceHandler::OnRequestRedirected(int request_id,
104 const GURL& new_url, 104 const GURL& new_url,
105 ResourceResponse* response, 105 ResourceResponse* response,
106 bool* defer) { 106 bool* defer) {
107 *defer = true; 107 *defer = true;
108 net::URLRequest* request = rdh_->GetURLRequest( 108 net::URLRequest* request = rdh_->GetURLRequest(
109 GlobalRequestID(filter_->child_id(), request_id)); 109 GlobalRequestID(filter_->child_id(), request_id));
110 if (rdh_->delegate()) 110 if (rdh_->delegate())
111 rdh_->delegate()->OnRequestRedirected(request, response); 111 rdh_->delegate()->OnRequestRedirected(request, filter_->resource_context(),
112 response);
112 113
113 DevToolsNetLogObserver::PopulateResponseInfo(request, response); 114 DevToolsNetLogObserver::PopulateResponseInfo(request, response);
114 response->request_start = request->creation_time(); 115 response->request_start = request->creation_time();
115 response->response_start = TimeTicks::Now(); 116 response->response_start = TimeTicks::Now();
116 return filter_->Send(new ResourceMsg_ReceivedRedirect( 117 return filter_->Send(new ResourceMsg_ReceivedRedirect(
117 routing_id_, request_id, new_url, *response)); 118 routing_id_, request_id, new_url, *response));
118 } 119 }
119 120
120 bool AsyncResourceHandler::OnResponseStarted(int request_id, 121 bool AsyncResourceHandler::OnResponseStarted(int request_id,
121 ResourceResponse* response, 122 ResourceResponse* response,
122 bool* defer) { 123 bool* defer) {
123 // For changes to the main frame, inform the renderer of the new URL's 124 // For changes to the main frame, inform the renderer of the new URL's
124 // per-host settings before the request actually commits. This way the 125 // per-host settings before the request actually commits. This way the
125 // renderer will be able to set these precisely at the time the 126 // renderer will be able to set these precisely at the time the
126 // request commits, avoiding the possibility of e.g. zooming the old content 127 // request commits, avoiding the possibility of e.g. zooming the old content
127 // or of having to layout the new content twice. 128 // or of having to layout the new content twice.
128 net::URLRequest* request = rdh_->GetURLRequest( 129 net::URLRequest* request = rdh_->GetURLRequest(
129 GlobalRequestID(filter_->child_id(), request_id)); 130 GlobalRequestID(filter_->child_id(), request_id));
130 131
132 content::ResourceContext* resource_context = filter_->resource_context();
131 if (rdh_->delegate()) 133 if (rdh_->delegate())
132 rdh_->delegate()->OnResponseStarted(request, response, filter_); 134 rdh_->delegate()->OnResponseStarted(request, resource_context, response,
135 filter_);
133 136
134 DevToolsNetLogObserver::PopulateResponseInfo(request, response); 137 DevToolsNetLogObserver::PopulateResponseInfo(request, response);
135 138
136 ResourceContext* resource_context = filter_->resource_context();
137 HostZoomMap* host_zoom_map = 139 HostZoomMap* host_zoom_map =
138 GetHostZoomMapForResourceContext(resource_context); 140 GetHostZoomMapForResourceContext(resource_context);
139 141
140 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 142 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
141 if (info->GetResourceType() == ResourceType::MAIN_FRAME && host_zoom_map) { 143 if (info->GetResourceType() == ResourceType::MAIN_FRAME && host_zoom_map) {
142 GURL request_url(request->url()); 144 GURL request_url(request->url());
143 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( 145 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL(
144 info->GetRouteID(), 146 info->GetRouteID(),
145 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL( 147 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(
146 request_url)))); 148 request_url))));
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 void AsyncResourceHandler::GlobalCleanup() { 279 void AsyncResourceHandler::GlobalCleanup() {
278 if (g_spare_read_buffer) { 280 if (g_spare_read_buffer) {
279 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). 281 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer().
280 SharedIOBuffer* tmp = g_spare_read_buffer; 282 SharedIOBuffer* tmp = g_spare_read_buffer;
281 g_spare_read_buffer = NULL; 283 g_spare_read_buffer = NULL;
282 tmp->Release(); 284 tmp->Release();
283 } 285 }
284 } 286 }
285 287
286 } // namespace content 288 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698