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/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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 DevToolsNetLogObserver::PopulateResponseInfo(request, response); | 114 DevToolsNetLogObserver::PopulateResponseInfo(request, response); |
115 response->request_start = request->creation_time(); | 115 response->request_start = request->creation_time(); |
116 response->response_start = TimeTicks::Now(); | 116 response->response_start = TimeTicks::Now(); |
117 return filter_->Send(new ResourceMsg_ReceivedRedirect( | 117 return filter_->Send(new ResourceMsg_ReceivedRedirect( |
118 routing_id_, request_id, new_url, *response)); | 118 routing_id_, request_id, new_url, *response)); |
119 } | 119 } |
120 | 120 |
121 bool AsyncResourceHandler::OnResponseStarted( | 121 bool AsyncResourceHandler::OnResponseStarted( |
122 int request_id, | 122 int request_id, |
123 content::ResourceResponse* response) { | 123 content::ResourceResponse* response, |
| 124 bool* defer) { |
124 // For changes to the main frame, inform the renderer of the new URL's | 125 // For changes to the main frame, inform the renderer of the new URL's |
125 // per-host settings before the request actually commits. This way the | 126 // per-host settings before the request actually commits. This way the |
126 // renderer will be able to set these precisely at the time the | 127 // renderer will be able to set these precisely at the time the |
127 // request commits, avoiding the possibility of e.g. zooming the old content | 128 // request commits, avoiding the possibility of e.g. zooming the old content |
128 // or of having to layout the new content twice. | 129 // or of having to layout the new content twice. |
129 net::URLRequest* request = rdh_->GetURLRequest( | 130 net::URLRequest* request = rdh_->GetURLRequest( |
130 GlobalRequestID(filter_->child_id(), request_id)); | 131 GlobalRequestID(filter_->child_id(), request_id)); |
131 | 132 |
132 if (rdh_->delegate()) | 133 if (rdh_->delegate()) |
133 rdh_->delegate()->OnResponseStarted(request, response, filter_); | 134 rdh_->delegate()->OnResponseStarted(request, response, filter_); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return false; | 189 return false; |
189 } | 190 } |
190 DCHECK(read_buffer_->data()); | 191 DCHECK(read_buffer_->data()); |
191 *buf = read_buffer_.get(); | 192 *buf = read_buffer_.get(); |
192 *buf_size = next_buffer_size_; | 193 *buf_size = next_buffer_size_; |
193 } | 194 } |
194 | 195 |
195 return true; | 196 return true; |
196 } | 197 } |
197 | 198 |
198 bool AsyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read) { | 199 bool AsyncResourceHandler::OnReadCompleted(int request_id, int* bytes_read, |
| 200 bool* defer) { |
199 if (!*bytes_read) | 201 if (!*bytes_read) |
200 return true; | 202 return true; |
201 DCHECK(read_buffer_.get()); | 203 DCHECK(read_buffer_.get()); |
202 | 204 |
203 if (read_buffer_->buffer_size() == *bytes_read) { | 205 if (read_buffer_->buffer_size() == *bytes_read) { |
204 // The network layer has saturated our buffer. Next time, we should give it | 206 // The network layer has saturated our buffer. Next time, we should give it |
205 // a bigger buffer for it to fill, to minimize the number of round trips we | 207 // a bigger buffer for it to fill, to minimize the number of round trips we |
206 // do with the renderer process. | 208 // do with the renderer process. |
207 next_buffer_size_ = std::min(next_buffer_size_ * 2, kMaxReadBufSize); | 209 next_buffer_size_ = std::min(next_buffer_size_ * 2, kMaxReadBufSize); |
208 } | 210 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 void AsyncResourceHandler::GlobalCleanup() { | 282 void AsyncResourceHandler::GlobalCleanup() { |
281 if (g_spare_read_buffer) { | 283 if (g_spare_read_buffer) { |
282 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). | 284 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). |
283 SharedIOBuffer* tmp = g_spare_read_buffer; | 285 SharedIOBuffer* tmp = g_spare_read_buffer; |
284 g_spare_read_buffer = NULL; | 286 g_spare_read_buffer = NULL; |
285 tmp->Release(); | 287 tmp->Release(); |
286 } | 288 } |
287 } | 289 } |
288 | 290 |
289 } // namespace content | 291 } // namespace content |
OLD | NEW |