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/buffered_resource_handler.h" | 5 #include "chrome/browser/renderer_host/buffered_resource_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 bool BufferedResourceHandler::OnResponseStarted(int request_id, | 82 bool BufferedResourceHandler::OnResponseStarted(int request_id, |
83 ResourceResponse* response) { | 83 ResourceResponse* response) { |
84 response_ = response; | 84 response_ = response; |
85 if (!DelayResponse()) | 85 if (!DelayResponse()) |
86 return CompleteResponseStarted(request_id, false); | 86 return CompleteResponseStarted(request_id, false); |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 bool BufferedResourceHandler::OnResponseCompleted( | 90 bool BufferedResourceHandler::OnResponseCompleted( |
91 int request_id, | 91 int request_id, |
92 const URLRequestStatus& status, | 92 const net::URLRequestStatus& status, |
93 const std::string& security_info) { | 93 const std::string& security_info) { |
94 return real_handler_->OnResponseCompleted(request_id, status, security_info); | 94 return real_handler_->OnResponseCompleted(request_id, status, security_info); |
95 } | 95 } |
96 | 96 |
97 void BufferedResourceHandler::OnRequestClosed() { | 97 void BufferedResourceHandler::OnRequestClosed() { |
98 request_ = NULL; | 98 request_ = NULL; |
99 real_handler_->OnRequestClosed(); | 99 real_handler_->OnRequestClosed(); |
100 } | 100 } |
101 | 101 |
102 bool BufferedResourceHandler::OnWillStart(int request_id, | 102 bool BufferedResourceHandler::OnWillStart(int request_id, |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 net::IOBuffer* buf = NULL; | 448 net::IOBuffer* buf = NULL; |
449 int buf_len = 0; | 449 int buf_len = 0; |
450 handler->OnWillRead(request_id, &buf, &buf_len, bytes_read_); | 450 handler->OnWillRead(request_id, &buf, &buf_len, bytes_read_); |
451 CHECK((buf_len >= bytes_read_) && (bytes_read_ >= 0)); | 451 CHECK((buf_len >= bytes_read_) && (bytes_read_ >= 0)); |
452 memcpy(buf->data(), read_buffer_->data(), bytes_read_); | 452 memcpy(buf->data(), read_buffer_->data(), bytes_read_); |
453 } | 453 } |
454 | 454 |
455 // Inform the original ResourceHandler that this will be handled entirely by | 455 // Inform the original ResourceHandler that this will be handled entirely by |
456 // the new ResourceHandler. | 456 // the new ResourceHandler. |
457 real_handler_->OnResponseStarted(info->request_id(), response_); | 457 real_handler_->OnResponseStarted(info->request_id(), response_); |
458 URLRequestStatus status(URLRequestStatus::HANDLED_EXTERNALLY, 0); | 458 net::URLRequestStatus status(net::URLRequestStatus::HANDLED_EXTERNALLY, 0); |
459 real_handler_->OnResponseCompleted(info->request_id(), status, std::string()); | 459 real_handler_->OnResponseCompleted(info->request_id(), status, std::string()); |
460 | 460 |
461 // Remove the non-owning pointer to the CrossSiteResourceHandler, if any, | 461 // Remove the non-owning pointer to the CrossSiteResourceHandler, if any, |
462 // from the extra request info because the CrossSiteResourceHandler (part of | 462 // from the extra request info because the CrossSiteResourceHandler (part of |
463 // the original ResourceHandler chain) will be deleted by the next statement. | 463 // the original ResourceHandler chain) will be deleted by the next statement. |
464 info->set_cross_site_handler(NULL); | 464 info->set_cross_site_handler(NULL); |
465 | 465 |
466 // This is handled entirely within the new ResourceHandler, so just reset the | 466 // This is handled entirely within the new ResourceHandler, so just reset the |
467 // original ResourceHandler. | 467 // original ResourceHandler. |
468 real_handler_ = handler; | 468 real_handler_ = handler; |
(...skipping 12 matching lines...) Expand all Loading... |
481 wait_for_plugins_ = false; | 481 wait_for_plugins_ = false; |
482 if (!request_) | 482 if (!request_) |
483 return; | 483 return; |
484 | 484 |
485 ResourceDispatcherHostRequestInfo* info = | 485 ResourceDispatcherHostRequestInfo* info = |
486 ResourceDispatcherHost::InfoForRequest(request_); | 486 ResourceDispatcherHost::InfoForRequest(request_); |
487 host_->PauseRequest(info->child_id(), info->request_id(), false); | 487 host_->PauseRequest(info->child_id(), info->request_id(), false); |
488 if (!CompleteResponseStarted(info->request_id(), false)) | 488 if (!CompleteResponseStarted(info->request_id(), false)) |
489 host_->CancelRequest(info->child_id(), info->request_id(), false); | 489 host_->CancelRequest(info->child_id(), info->request_id(), false); |
490 } | 490 } |
OLD | NEW |