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

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

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 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
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/command_line.h" 10 #include "base/command_line.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 bool* defer) { 157 bool* defer) {
158 // For changes to the main frame, inform the renderer of the new URL's 158 // For changes to the main frame, inform the renderer of the new URL's
159 // per-host settings before the request actually commits. This way the 159 // per-host settings before the request actually commits. This way the
160 // renderer will be able to set these precisely at the time the 160 // renderer will be able to set these precisely at the time the
161 // request commits, avoiding the possibility of e.g. zooming the old content 161 // request commits, avoiding the possibility of e.g. zooming the old content
162 // or of having to layout the new content twice. 162 // or of having to layout the new content twice.
163 163
164 ResourceContext* resource_context = filter_->resource_context(); 164 ResourceContext* resource_context = filter_->resource_context();
165 if (rdh_->delegate()) { 165 if (rdh_->delegate()) {
166 rdh_->delegate()->OnResponseStarted(request_, resource_context, response, 166 rdh_->delegate()->OnResponseStarted(request_, resource_context, response,
167 filter_); 167 filter_.get());
168 } 168 }
169 169
170 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); 170 DevToolsNetLogObserver::PopulateResponseInfo(request_, response);
171 171
172 HostZoomMap* host_zoom_map = 172 HostZoomMap* host_zoom_map =
173 GetHostZoomMapForResourceContext(resource_context); 173 GetHostZoomMapForResourceContext(resource_context);
174 174
175 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); 175 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
176 if (info->GetResourceType() == ResourceType::MAIN_FRAME && host_zoom_map) { 176 if (info->GetResourceType() == ResourceType::MAIN_FRAME && host_zoom_map) {
177 const GURL& request_url = request_->url(); 177 const GURL& request_url = request_->url();
178 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL( 178 filter_->Send(new ViewMsg_SetZoomLevelForLoadingURL(
179 info->GetRouteID(), 179 info->GetRouteID(),
180 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL( 180 request_url, host_zoom_map->GetZoomLevel(net::GetHostOrSpecFromURL(
181 request_url)))); 181 request_url))));
182 } 182 }
183 183
184 response->head.request_start = request_->creation_time(); 184 response->head.request_start = request_->creation_time();
185 response->head.response_start = TimeTicks::Now(); 185 response->head.response_start = TimeTicks::Now();
186 filter_->Send(new ResourceMsg_ReceivedResponse( 186 filter_->Send(new ResourceMsg_ReceivedResponse(
187 routing_id_, request_id, response->head)); 187 routing_id_, request_id, response->head));
188 sent_received_response_msg_ = true; 188 sent_received_response_msg_ = true;
189 189
190 if (request_->response_info().metadata) { 190 if (request_->response_info().metadata.get()) {
191 std::vector<char> copy(request_->response_info().metadata->data(), 191 std::vector<char> copy(request_->response_info().metadata->data(),
192 request_->response_info().metadata->data() + 192 request_->response_info().metadata->data() +
193 request_->response_info().metadata->size()); 193 request_->response_info().metadata->size());
194 filter_->Send(new ResourceMsg_ReceivedCachedMetadata( 194 filter_->Send(new ResourceMsg_ReceivedCachedMetadata(
195 routing_id_, request_id, copy)); 195 routing_id_, request_id, copy));
196 } 196 }
197 197
198 return true; 198 return true;
199 } 199 }
200 200
201 bool AsyncResourceHandler::OnWillStart(int request_id, 201 bool AsyncResourceHandler::OnWillStart(int request_id,
202 const GURL& url, 202 const GURL& url,
203 bool* defer) { 203 bool* defer) {
204 return true; 204 return true;
205 } 205 }
206 206
207 bool AsyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf, 207 bool AsyncResourceHandler::OnWillRead(int request_id, net::IOBuffer** buf,
208 int* buf_size, int min_size) { 208 int* buf_size, int min_size) {
209 DCHECK_EQ(-1, min_size); 209 DCHECK_EQ(-1, min_size);
210 210
211 if (!EnsureResourceBufferIsInitialized()) 211 if (!EnsureResourceBufferIsInitialized())
212 return false; 212 return false;
213 213
214 DCHECK(buffer_->CanAllocate()); 214 DCHECK(buffer_->CanAllocate());
215 char* memory = buffer_->Allocate(&allocation_size_); 215 char* memory = buffer_->Allocate(&allocation_size_);
216 CHECK(memory); 216 CHECK(memory);
217 217
218 *buf = new DependentIOBuffer(buffer_, memory); 218 *buf = new DependentIOBuffer(buffer_.get(), memory);
219 *buf_size = allocation_size_; 219 *buf_size = allocation_size_;
220 220
221 UMA_HISTOGRAM_CUSTOM_COUNTS( 221 UMA_HISTOGRAM_CUSTOM_COUNTS(
222 "Net.AsyncResourceHandler_SharedIOBuffer_Alloc", 222 "Net.AsyncResourceHandler_SharedIOBuffer_Alloc",
223 *buf_size, 0, kMaxAllocationSize, 100); 223 *buf_size, 0, kMaxAllocationSize, 100);
224 return true; 224 return true;
225 } 225 }
226 226
227 bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, 227 bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read,
228 bool* defer) { 228 bool* defer) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 filter_->Send(new ResourceMsg_RequestComplete(routing_id_, 319 filter_->Send(new ResourceMsg_RequestComplete(routing_id_,
320 request_id, 320 request_id,
321 error_code, 321 error_code,
322 was_ignored_by_handler, 322 was_ignored_by_handler,
323 security_info, 323 security_info,
324 completion_time)); 324 completion_time));
325 return true; 325 return true;
326 } 326 }
327 327
328 bool AsyncResourceHandler::EnsureResourceBufferIsInitialized() { 328 bool AsyncResourceHandler::EnsureResourceBufferIsInitialized() {
329 if (buffer_ && buffer_->IsInitialized()) 329 if (buffer_.get() && buffer_->IsInitialized())
330 return true; 330 return true;
331 331
332 buffer_ = new ResourceBuffer(); 332 buffer_ = new ResourceBuffer();
333 return buffer_->Initialize(kBufferSize, 333 return buffer_->Initialize(kBufferSize,
334 kMinAllocationSize, 334 kMinAllocationSize,
335 kMaxAllocationSize); 335 kMaxAllocationSize);
336 } 336 }
337 337
338 void AsyncResourceHandler::ResumeIfDeferred() { 338 void AsyncResourceHandler::ResumeIfDeferred() {
339 if (did_defer_) { 339 if (did_defer_) {
340 did_defer_ = false; 340 did_defer_ = false;
341 controller()->Resume(); 341 controller()->Resume();
342 } 342 }
343 } 343 }
344 344
345 } // namespace content 345 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/ppapi_plugin_process_host.cc ('k') | content/browser/renderer_host/database_message_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698