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

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

Issue 8680036: Move ResourceResponse struct into the Content API, since it's used in Chrome. While at it, I also... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: add gypi changes Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/hash_tables.h" 10 #include "base/hash_tables.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/shared_memory.h" 12 #include "base/shared_memory.h"
13 #include "content/browser/debugger/devtools_netlog_observer.h" 13 #include "content/browser/debugger/devtools_netlog_observer.h"
14 #include "content/browser/host_zoom_map.h" 14 #include "content/browser/host_zoom_map.h"
15 #include "content/browser/renderer_host/global_request_id.h" 15 #include "content/browser/renderer_host/global_request_id.h"
16 #include "content/browser/renderer_host/resource_dispatcher_host.h" 16 #include "content/browser/renderer_host/resource_dispatcher_host.h"
17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" 17 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h"
18 #include "content/browser/renderer_host/resource_message_filter.h" 18 #include "content/browser/renderer_host/resource_message_filter.h"
19 #include "content/browser/resource_context.h" 19 #include "content/browser/resource_context.h"
20 #include "content/common/resource_response.h"
21 #include "content/common/resource_messages.h" 20 #include "content/common/resource_messages.h"
22 #include "content/common/view_messages.h" 21 #include "content/common/view_messages.h"
23 #include "content/public/browser/resource_dispatcher_host_delegate.h" 22 #include "content/public/browser/resource_dispatcher_host_delegate.h"
23 #include "content/public/common/resource_response.h"
24 #include "net/base/io_buffer.h" 24 #include "net/base/io_buffer.h"
25 #include "net/base/load_flags.h" 25 #include "net/base/load_flags.h"
26 #include "net/base/net_log.h" 26 #include "net/base/net_log.h"
27 #include "webkit/glue/resource_loader_bridge.h" 27 #include "webkit/glue/resource_loader_bridge.h"
28 28
29 using base::Time; 29 using base::Time;
30 using base::TimeTicks; 30 using base::TimeTicks;
31 31
32 namespace { 32 namespace {
33 33
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 AsyncResourceHandler::~AsyncResourceHandler() { 91 AsyncResourceHandler::~AsyncResourceHandler() {
92 } 92 }
93 93
94 bool AsyncResourceHandler::OnUploadProgress(int request_id, 94 bool AsyncResourceHandler::OnUploadProgress(int request_id,
95 uint64 position, 95 uint64 position,
96 uint64 size) { 96 uint64 size) {
97 return filter_->Send(new ResourceMsg_UploadProgress(routing_id_, request_id, 97 return filter_->Send(new ResourceMsg_UploadProgress(routing_id_, request_id,
98 position, size)); 98 position, size));
99 } 99 }
100 100
101 bool AsyncResourceHandler::OnRequestRedirected(int request_id, 101 bool AsyncResourceHandler::OnRequestRedirected(
102 const GURL& new_url, 102 int request_id,
103 ResourceResponse* response, 103 const GURL& new_url,
104 bool* defer) { 104 content::ResourceResponse* response,
105 bool* defer) {
105 *defer = true; 106 *defer = true;
106 net::URLRequest* request = rdh_->GetURLRequest( 107 net::URLRequest* request = rdh_->GetURLRequest(
107 GlobalRequestID(filter_->child_id(), request_id)); 108 GlobalRequestID(filter_->child_id(), request_id));
108 if (rdh_->delegate()) 109 if (rdh_->delegate())
109 rdh_->delegate()->OnRequestRedirected(request, response, filter_); 110 rdh_->delegate()->OnRequestRedirected(request, response, filter_);
110 111
111 DevToolsNetLogObserver::PopulateResponseInfo(request, response); 112 DevToolsNetLogObserver::PopulateResponseInfo(request, response);
112 return filter_->Send(new ResourceMsg_ReceivedRedirect( 113 return filter_->Send(new ResourceMsg_ReceivedRedirect(
113 routing_id_, request_id, new_url, response->response_head)); 114 routing_id_, request_id, new_url, *response));
114 } 115 }
115 116
116 bool AsyncResourceHandler::OnResponseStarted(int request_id, 117 bool AsyncResourceHandler::OnResponseStarted(
117 ResourceResponse* response) { 118 int request_id,
119 content::ResourceResponse* response) {
118 // For changes to the main frame, inform the renderer of the new URL's 120 // For changes to the main frame, inform the renderer of the new URL's
119 // per-host settings before the request actually commits. This way the 121 // per-host settings before the request actually commits. This way the
120 // renderer will be able to set these precisely at the time the 122 // renderer will be able to set these precisely at the time the
121 // request commits, avoiding the possibility of e.g. zooming the old content 123 // request commits, avoiding the possibility of e.g. zooming the old content
122 // or of having to layout the new content twice. 124 // or of having to layout the new content twice.
123 net::URLRequest* request = rdh_->GetURLRequest( 125 net::URLRequest* request = rdh_->GetURLRequest(
124 GlobalRequestID(filter_->child_id(), request_id)); 126 GlobalRequestID(filter_->child_id(), request_id));
125 127
126 if (rdh_->delegate()) 128 if (rdh_->delegate())
127 rdh_->delegate()->OnResponseStarted(request, response, filter_); 129 rdh_->delegate()->OnResponseStarted(request, response, filter_);
128 130
129 DevToolsNetLogObserver::PopulateResponseInfo(request, response); 131 DevToolsNetLogObserver::PopulateResponseInfo(request, response);
130 132
131 const content::ResourceContext& resource_context = 133 const content::ResourceContext& resource_context =
132 filter_->resource_context(); 134 filter_->resource_context();
133 HostZoomMap* host_zoom_map = resource_context.host_zoom_map(); 135 HostZoomMap* host_zoom_map = resource_context.host_zoom_map();
134 136
135 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request); 137 ResourceDispatcherHostRequestInfo* info = rdh_->InfoForRequest(request);
136 if (info->resource_type() == ResourceType::MAIN_FRAME && host_zoom_map) { 138 if (info->resource_type() == ResourceType::MAIN_FRAME && host_zoom_map) {
137 GURL request_url(request->url()); 139 GURL request_url(request->url());
138 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( 140 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL(
139 info->route_id(), 141 info->route_id(),
140 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL( 142 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(
141 request_url)))); 143 request_url))));
142 } 144 }
143 145
144 filter_->Send(new ResourceMsg_ReceivedResponse( 146 filter_->Send(new ResourceMsg_ReceivedResponse(
145 routing_id_, request_id, response->response_head)); 147 routing_id_, request_id, *response));
146 148
147 if (request->response_info().metadata) { 149 if (request->response_info().metadata) {
148 std::vector<char> copy(request->response_info().metadata->data(), 150 std::vector<char> copy(request->response_info().metadata->data(),
149 request->response_info().metadata->data() + 151 request->response_info().metadata->data() +
150 request->response_info().metadata->size()); 152 request->response_info().metadata->size());
151 filter_->Send(new ResourceMsg_ReceivedCachedMetadata( 153 filter_->Send(new ResourceMsg_ReceivedCachedMetadata(
152 routing_id_, request_id, copy)); 154 routing_id_, request_id, copy));
153 } 155 }
154 156
155 return true; 157 return true;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 266
265 // static 267 // static
266 void AsyncResourceHandler::GlobalCleanup() { 268 void AsyncResourceHandler::GlobalCleanup() {
267 if (g_spare_read_buffer) { 269 if (g_spare_read_buffer) {
268 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). 270 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer().
269 SharedIOBuffer* tmp = g_spare_read_buffer; 271 SharedIOBuffer* tmp = g_spare_read_buffer;
270 g_spare_read_buffer = NULL; 272 g_spare_read_buffer = NULL;
271 tmp->Release(); 273 tmp->Release();
272 } 274 }
273 } 275 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/async_resource_handler.h ('k') | content/browser/renderer_host/buffered_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698