| 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_resource_handler.h" | 5 #include "chrome/browser/renderer_host/download_resource_handler.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 // TODO(port): Remove the temporary scaffolding after porting the headers below. | 8 // TODO(port): Remove the temporary scaffolding after porting the headers below. |
| 9 #include "chrome/common/temp_scaffolding_stubs.h" | 9 #include "chrome/common/temp_scaffolding_stubs.h" |
| 10 #elif defined(OS_WIN) | 10 #elif defined(OS_WIN) |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // We schedule a pause outside of the read loop if there is too much file | 112 // We schedule a pause outside of the read loop if there is too much file |
| 113 // writing work to do. | 113 // writing work to do. |
| 114 if (buffer_->contents.size() > kLoadsToWrite) | 114 if (buffer_->contents.size() > kLoadsToWrite) |
| 115 StartPauseTimer(); | 115 StartPauseTimer(); |
| 116 | 116 |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool DownloadResourceHandler::OnResponseCompleted( | 120 bool DownloadResourceHandler::OnResponseCompleted( |
| 121 int request_id, | 121 int request_id, |
| 122 const URLRequestStatus& status) { | 122 const URLRequestStatus& status, |
| 123 const std::string& security_info) { |
| 123 download_manager_->file_loop()->PostTask(FROM_HERE, | 124 download_manager_->file_loop()->PostTask(FROM_HERE, |
| 124 NewRunnableMethod(download_manager_, | 125 NewRunnableMethod(download_manager_, |
| 125 &DownloadFileManager::DownloadFinished, | 126 &DownloadFileManager::DownloadFinished, |
| 126 download_id_, | 127 download_id_, |
| 127 buffer_)); | 128 buffer_)); |
| 128 read_buffer_ = NULL; | 129 read_buffer_ = NULL; |
| 129 | 130 |
| 130 // 'buffer_' is deleted by the DownloadFileManager. | 131 // 'buffer_' is deleted by the DownloadFileManager. |
| 131 buffer_ = NULL; | 132 buffer_ = NULL; |
| 132 return true; | 133 return true; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 should_pause); | 169 should_pause); |
| 169 is_paused_ = should_pause; | 170 is_paused_ = should_pause; |
| 170 } | 171 } |
| 171 } | 172 } |
| 172 | 173 |
| 173 void DownloadResourceHandler::StartPauseTimer() { | 174 void DownloadResourceHandler::StartPauseTimer() { |
| 174 if (!pause_timer_.IsRunning()) | 175 if (!pause_timer_.IsRunning()) |
| 175 pause_timer_.Start(base::TimeDelta::FromMilliseconds(kThrottleTimeMs), this, | 176 pause_timer_.Start(base::TimeDelta::FromMilliseconds(kThrottleTimeMs), this, |
| 176 &DownloadResourceHandler::CheckWriteProgress); | 177 &DownloadResourceHandler::CheckWriteProgress); |
| 177 } | 178 } |
| OLD | NEW |