| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/download_resource_handler.h" | 7 #include "chrome/browser/renderer_host/download_resource_handler.h" |
| 8 #include "net/base/io_buffer.h" | 8 #include "net/base/io_buffer.h" |
| 9 | 9 |
| 10 DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler( | 10 DownloadThrottlingResourceHandler::DownloadThrottlingResourceHandler( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return true; | 97 return true; |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool DownloadThrottlingResourceHandler::OnResponseCompleted( | 100 bool DownloadThrottlingResourceHandler::OnResponseCompleted( |
| 101 int request_id, | 101 int request_id, |
| 102 const URLRequestStatus& status, | 102 const URLRequestStatus& status, |
| 103 const std::string& security_info) { | 103 const std::string& security_info) { |
| 104 if (download_handler_.get()) | 104 if (download_handler_.get()) |
| 105 return download_handler_->OnResponseCompleted(request_id, status, | 105 return download_handler_->OnResponseCompleted(request_id, status, |
| 106 security_info); | 106 security_info); |
| 107 |
| 108 // For a download, if ResourceDispatcher::Read() fails, |
| 109 // ResourceDispatcher::OnresponseStarted() will call |
| 110 // OnResponseCompleted(), and we will end up here with an error |
| 111 // status. |
| 112 if (!status.is_success()) |
| 113 return false; |
| 107 NOTREACHED(); | 114 NOTREACHED(); |
| 108 return true; | 115 return true; |
| 109 } | 116 } |
| 110 | 117 |
| 111 void DownloadThrottlingResourceHandler::CancelDownload() { | 118 void DownloadThrottlingResourceHandler::CancelDownload() { |
| 112 host_->CancelRequest(render_process_host_id_, request_id_, false); | 119 host_->CancelRequest(render_process_host_id_, request_id_, false); |
| 113 } | 120 } |
| 114 | 121 |
| 115 void DownloadThrottlingResourceHandler::ContinueDownload() { | 122 void DownloadThrottlingResourceHandler::ContinueDownload() { |
| 116 DCHECK(!download_handler_.get()); | 123 DCHECK(!download_handler_.get()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 139 int buf_size; | 146 int buf_size; |
| 140 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size, | 147 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size, |
| 141 tmp_buffer_length_)) { | 148 tmp_buffer_length_)) { |
| 142 CHECK(buf_size >= tmp_buffer_length_); | 149 CHECK(buf_size >= tmp_buffer_length_); |
| 143 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_); | 150 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_); |
| 144 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_); | 151 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_); |
| 145 } | 152 } |
| 146 tmp_buffer_length_ = 0; | 153 tmp_buffer_length_ = 0; |
| 147 tmp_buffer_ = NULL; | 154 tmp_buffer_ = NULL; |
| 148 } | 155 } |
| OLD | NEW |