| OLD | NEW |
| 1 // Copyright (c) 2006-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/download_throttling_resource_handler.h" | 5 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/renderer_host/download_resource_handler.h" | 8 #include "chrome/browser/renderer_host/download_resource_handler.h" |
| 9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 9 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 10 #include "chrome/common/resource_response.h" | 10 #include "chrome/common/resource_response.h" |
| 11 #include "net/base/io_buffer.h" | 11 #include "net/base/io_buffer.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 CopyTmpBufferToDownloadHandler(); | 112 CopyTmpBufferToDownloadHandler(); |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 if (download_handler_.get()) | 115 if (download_handler_.get()) |
| 116 return download_handler_->OnReadCompleted(request_id, bytes_read); | 116 return download_handler_->OnReadCompleted(request_id, bytes_read); |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool DownloadThrottlingResourceHandler::OnResponseCompleted( | 120 bool DownloadThrottlingResourceHandler::OnResponseCompleted( |
| 121 int request_id, | 121 int request_id, |
| 122 const URLRequestStatus& status, | 122 const net::URLRequestStatus& status, |
| 123 const std::string& security_info) { | 123 const std::string& security_info) { |
| 124 if (download_handler_.get()) | 124 if (download_handler_.get()) |
| 125 return download_handler_->OnResponseCompleted(request_id, status, | 125 return download_handler_->OnResponseCompleted(request_id, status, |
| 126 security_info); | 126 security_info); |
| 127 | 127 |
| 128 // For a download, if ResourceDispatcher::Read() fails, | 128 // For a download, if ResourceDispatcher::Read() fails, |
| 129 // ResourceDispatcher::OnresponseStarted() will call | 129 // ResourceDispatcher::OnresponseStarted() will call |
| 130 // OnResponseCompleted(), and we will end up here with an error | 130 // OnResponseCompleted(), and we will end up here with an error |
| 131 // status. | 131 // status. |
| 132 if (!status.is_success()) | 132 if (!status.is_success()) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 int buf_size; | 176 int buf_size; |
| 177 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size, | 177 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size, |
| 178 tmp_buffer_length_)) { | 178 tmp_buffer_length_)) { |
| 179 CHECK(buf_size >= tmp_buffer_length_); | 179 CHECK(buf_size >= tmp_buffer_length_); |
| 180 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_); | 180 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_); |
| 181 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_); | 181 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_); |
| 182 } | 182 } |
| 183 tmp_buffer_length_ = 0; | 183 tmp_buffer_length_ = 0; |
| 184 tmp_buffer_ = NULL; | 184 tmp_buffer_ = NULL; |
| 185 } | 185 } |
| OLD | NEW |