OLD | NEW |
1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/async_resource_handler.h" | 5 #include "chrome/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" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 222 } |
223 | 223 |
224 void AsyncResourceHandler::OnDataDownloaded( | 224 void AsyncResourceHandler::OnDataDownloaded( |
225 int request_id, int bytes_downloaded) { | 225 int request_id, int bytes_downloaded) { |
226 filter_->Send(new ViewMsg_Resource_DataDownloaded( | 226 filter_->Send(new ViewMsg_Resource_DataDownloaded( |
227 routing_id_, request_id, bytes_downloaded)); | 227 routing_id_, request_id, bytes_downloaded)); |
228 } | 228 } |
229 | 229 |
230 bool AsyncResourceHandler::OnResponseCompleted( | 230 bool AsyncResourceHandler::OnResponseCompleted( |
231 int request_id, | 231 int request_id, |
232 const URLRequestStatus& status, | 232 const net::URLRequestStatus& status, |
233 const std::string& security_info) { | 233 const std::string& security_info) { |
234 Time completion_time = Time::Now(); | 234 Time completion_time = Time::Now(); |
235 filter_->Send(new ViewMsg_Resource_RequestComplete(routing_id_, | 235 filter_->Send(new ViewMsg_Resource_RequestComplete(routing_id_, |
236 request_id, | 236 request_id, |
237 status, | 237 status, |
238 security_info, | 238 security_info, |
239 completion_time)); | 239 completion_time)); |
240 | 240 |
241 // If we still have a read buffer, then see about caching it for later... | 241 // If we still have a read buffer, then see about caching it for later... |
242 // Note that we have to make sure the buffer is not still being used, so we | 242 // Note that we have to make sure the buffer is not still being used, so we |
243 // have to perform an explicit check on the status code. | 243 // have to perform an explicit check on the status code. |
244 if (g_spare_read_buffer || URLRequestStatus::SUCCESS != status.status()) { | 244 if (g_spare_read_buffer || |
| 245 net::URLRequestStatus::SUCCESS != status.status()) { |
245 read_buffer_ = NULL; | 246 read_buffer_ = NULL; |
246 } else if (read_buffer_.get()) { | 247 } else if (read_buffer_.get()) { |
247 DCHECK(read_buffer_->data()); | 248 DCHECK(read_buffer_->data()); |
248 read_buffer_.swap(&g_spare_read_buffer); | 249 read_buffer_.swap(&g_spare_read_buffer); |
249 } | 250 } |
250 return true; | 251 return true; |
251 } | 252 } |
252 | 253 |
253 void AsyncResourceHandler::OnRequestClosed() { | 254 void AsyncResourceHandler::OnRequestClosed() { |
254 } | 255 } |
255 | 256 |
256 // static | 257 // static |
257 void AsyncResourceHandler::GlobalCleanup() { | 258 void AsyncResourceHandler::GlobalCleanup() { |
258 if (g_spare_read_buffer) { | 259 if (g_spare_read_buffer) { |
259 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). | 260 // Avoid the CHECK in SharedIOBuffer::~SharedIOBuffer(). |
260 SharedIOBuffer* tmp = g_spare_read_buffer; | 261 SharedIOBuffer* tmp = g_spare_read_buffer; |
261 g_spare_read_buffer = NULL; | 262 g_spare_read_buffer = NULL; |
262 tmp->Release(); | 263 tmp->Release(); |
263 } | 264 } |
264 } | 265 } |
OLD | NEW |