Chromium Code Reviews| 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/loader/async_resource_handler.h" | 5 #include "content/browser/loader/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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 ResumeIfDeferred(); | 131 ResumeIfDeferred(); |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 | 134 |
| 135 bool AsyncResourceHandler::OnUploadProgress(int request_id, | 135 bool AsyncResourceHandler::OnUploadProgress(int request_id, |
| 136 uint64 position, | 136 uint64 position, |
| 137 uint64 size) { | 137 uint64 size) { |
| 138 const ResourceRequestInfoImpl* info = | 138 const ResourceRequestInfoImpl* info = |
| 139 ResourceRequestInfoImpl::ForRequest(request_); | 139 ResourceRequestInfoImpl::ForRequest(request_); |
| 140 if (!info->filter()) | 140 if (!info->filter()) |
| 141 return false; | 141 return false; |
|
asanka
2013/10/16 20:42:37
Should this also return info->is_detachable()?
<a
mmenke
2013/10/17 18:33:48
Yea, <a ping>'s are POSTs with 4-character bodies.
jkarlin2
2013/10/24 15:33:11
Done.
jkarlin2
2013/10/24 15:33:11
Done.
| |
| 142 return info->filter()->Send( | 142 return info->filter()->Send( |
| 143 new ResourceMsg_UploadProgress(request_id, position, size)); | 143 new ResourceMsg_UploadProgress(request_id, position, size)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 bool AsyncResourceHandler::OnRequestRedirected(int request_id, | 146 bool AsyncResourceHandler::OnRequestRedirected(int request_id, |
| 147 const GURL& new_url, | 147 const GURL& new_url, |
| 148 ResourceResponse* response, | 148 ResourceResponse* response, |
| 149 bool* defer) { | 149 bool* defer) { |
| 150 const ResourceRequestInfoImpl* info = | 150 const ResourceRequestInfoImpl* info = |
| 151 ResourceRequestInfoImpl::ForRequest(request_); | 151 ResourceRequestInfoImpl::ForRequest(request_); |
| 152 if (!info->filter()) | 152 if (!info->filter()) |
| 153 return false; | 153 return info->is_detachable(); |
|
mmenke
2013/10/17 18:33:48
I think all of these need a comment along the line
jkarlin2
2013/10/24 15:33:11
Done.
| |
| 154 | 154 |
| 155 *defer = did_defer_ = true; | 155 *defer = did_defer_ = true; |
| 156 | 156 |
| 157 if (rdh_->delegate()) { | 157 if (rdh_->delegate()) { |
| 158 rdh_->delegate()->OnRequestRedirected( | 158 rdh_->delegate()->OnRequestRedirected( |
| 159 new_url, request_, info->GetContext(), response); | 159 new_url, request_, info->GetContext(), response); |
| 160 } | 160 } |
| 161 | 161 |
| 162 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); | 162 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); |
| 163 response->head.request_start = request_->creation_time(); | 163 response->head.request_start = request_->creation_time(); |
| 164 response->head.response_start = TimeTicks::Now(); | 164 response->head.response_start = TimeTicks::Now(); |
| 165 return info->filter()->Send(new ResourceMsg_ReceivedRedirect( | 165 return info->filter()->Send(new ResourceMsg_ReceivedRedirect( |
| 166 request_id, new_url, response->head)); | 166 request_id, new_url, response->head)); |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool AsyncResourceHandler::OnResponseStarted(int request_id, | 169 bool AsyncResourceHandler::OnResponseStarted(int request_id, |
| 170 ResourceResponse* response, | 170 ResourceResponse* response, |
| 171 bool* defer) { | 171 bool* defer) { |
| 172 // For changes to the main frame, inform the renderer of the new URL's | 172 // For changes to the main frame, inform the renderer of the new URL's |
| 173 // per-host settings before the request actually commits. This way the | 173 // per-host settings before the request actually commits. This way the |
| 174 // renderer will be able to set these precisely at the time the | 174 // renderer will be able to set these precisely at the time the |
| 175 // request commits, avoiding the possibility of e.g. zooming the old content | 175 // request commits, avoiding the possibility of e.g. zooming the old content |
| 176 // or of having to layout the new content twice. | 176 // or of having to layout the new content twice. |
| 177 | 177 |
| 178 const ResourceRequestInfoImpl* info = | 178 const ResourceRequestInfoImpl* info = |
| 179 ResourceRequestInfoImpl::ForRequest(request_); | 179 ResourceRequestInfoImpl::ForRequest(request_); |
| 180 if (!info->filter()) | 180 if (!info->filter()) |
| 181 return false; | 181 return info->is_detachable(); |
| 182 | 182 |
| 183 if (rdh_->delegate()) { | 183 if (rdh_->delegate()) { |
| 184 rdh_->delegate()->OnResponseStarted( | 184 rdh_->delegate()->OnResponseStarted( |
| 185 request_, info->GetContext(), response, info->filter()); | 185 request_, info->GetContext(), response, info->filter()); |
| 186 } | 186 } |
| 187 | 187 |
| 188 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); | 188 DevToolsNetLogObserver::PopulateResponseInfo(request_, response); |
| 189 | 189 |
| 190 HostZoomMap* host_zoom_map = | 190 HostZoomMap* host_zoom_map = |
| 191 GetHostZoomMapForResourceContext(info->GetContext()); | 191 GetHostZoomMapForResourceContext(info->GetContext()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 return true; | 242 return true; |
| 243 } | 243 } |
| 244 | 244 |
| 245 bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, | 245 bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, |
| 246 bool* defer) { | 246 bool* defer) { |
| 247 if (!bytes_read) | 247 if (!bytes_read) |
| 248 return true; | 248 return true; |
| 249 | 249 |
| 250 const ResourceRequestInfoImpl* info = | 250 const ResourceRequestInfoImpl* info = |
| 251 ResourceRequestInfoImpl::ForRequest(request_); | 251 ResourceRequestInfoImpl::ForRequest(request_); |
| 252 if (info->is_detachable()) { | |
|
mmenke
2013/10/17 18:33:48
Again, comment that renderers don't care about rea
jkarlin2
2013/10/24 15:33:11
Done.
| |
| 253 buffer_->RecycleLeastRecentlyAllocated(); | |
| 254 return true; | |
| 255 } | |
| 252 if (!info->filter()) | 256 if (!info->filter()) |
| 253 return false; | 257 return false; |
| 254 | 258 |
| 255 buffer_->ShrinkLastAllocation(bytes_read); | 259 buffer_->ShrinkLastAllocation(bytes_read); |
| 256 | 260 |
| 257 UMA_HISTOGRAM_CUSTOM_COUNTS( | 261 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 258 "Net.AsyncResourceHandler_SharedIOBuffer_Used", | 262 "Net.AsyncResourceHandler_SharedIOBuffer_Used", |
| 259 bytes_read, 0, kMaxAllocationSize, 100); | 263 bytes_read, 0, kMaxAllocationSize, 100); |
| 260 UMA_HISTOGRAM_PERCENTAGE( | 264 UMA_HISTOGRAM_PERCENTAGE( |
| 261 "Net.AsyncResourceHandler_SharedIOBuffer_UsedPercentage", | 265 "Net.AsyncResourceHandler_SharedIOBuffer_UsedPercentage", |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 } | 309 } |
| 306 } | 310 } |
| 307 | 311 |
| 308 bool AsyncResourceHandler::OnResponseCompleted( | 312 bool AsyncResourceHandler::OnResponseCompleted( |
| 309 int request_id, | 313 int request_id, |
| 310 const net::URLRequestStatus& status, | 314 const net::URLRequestStatus& status, |
| 311 const std::string& security_info) { | 315 const std::string& security_info) { |
| 312 const ResourceRequestInfoImpl* info = | 316 const ResourceRequestInfoImpl* info = |
| 313 ResourceRequestInfoImpl::ForRequest(request_); | 317 ResourceRequestInfoImpl::ForRequest(request_); |
| 314 if (!info->filter()) | 318 if (!info->filter()) |
| 315 return false; | 319 return info->is_detachable(); |
|
mmenke
2013/10/17 18:33:48
Hmm....Wonder about returning false in this case i
jkarlin2
2013/10/24 15:33:11
Noted. It's unclear to me. The loader seems to in
| |
| 316 | 320 |
| 317 // If we crash here, figure out what URL the renderer was requesting. | 321 // If we crash here, figure out what URL the renderer was requesting. |
| 318 // http://crbug.com/107692 | 322 // http://crbug.com/107692 |
| 319 char url_buf[128]; | 323 char url_buf[128]; |
| 320 base::strlcpy(url_buf, request_->url().spec().c_str(), arraysize(url_buf)); | 324 base::strlcpy(url_buf, request_->url().spec().c_str(), arraysize(url_buf)); |
| 321 base::debug::Alias(url_buf); | 325 base::debug::Alias(url_buf); |
| 322 | 326 |
| 323 // TODO(gavinp): Remove this CHECK when we figure out the cause of | 327 // TODO(gavinp): Remove this CHECK when we figure out the cause of |
| 324 // http://crbug.com/124680 . This check mirrors closely check in | 328 // http://crbug.com/124680 . This check mirrors closely check in |
| 325 // WebURLLoaderImpl::OnCompletedRequest that routes this message to a WebCore | 329 // WebURLLoaderImpl::OnCompletedRequest that routes this message to a WebCore |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 } | 382 } |
| 379 | 383 |
| 380 void AsyncResourceHandler::ResumeIfDeferred() { | 384 void AsyncResourceHandler::ResumeIfDeferred() { |
| 381 if (did_defer_) { | 385 if (did_defer_) { |
| 382 did_defer_ = false; | 386 did_defer_ = false; |
| 383 controller()->Resume(); | 387 controller()->Resume(); |
| 384 } | 388 } |
| 385 } | 389 } |
| 386 | 390 |
| 387 } // namespace content | 391 } // namespace content |
| OLD | NEW |