Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/browser/renderer_host/download_throttling_resource_handler.cc

Issue 7192016: chrome.experimental.downloads (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: merged db_handle, id; onCreated, onErased Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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/download/download_util.h" 8 #include "chrome/browser/download/download_util.h"
9 #include "chrome/browser/renderer_host/download_resource_handler.h" 9 #include "chrome/browser/renderer_host/download_resource_handler.h"
10 #include "content/browser/renderer_host/resource_dispatcher_host.h" 10 #include "content/browser/renderer_host/resource_dispatcher_host.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 166
167 void DownloadThrottlingResourceHandler::CancelDownload() { 167 void DownloadThrottlingResourceHandler::CancelDownload() {
168 if (!request_closed_) 168 if (!request_closed_)
169 host_->CancelRequest(render_process_host_id_, request_id_, false); 169 host_->CancelRequest(render_process_host_id_, request_id_, false);
170 Release(); // Release the additional reference from constructor. 170 Release(); // Release the additional reference from constructor.
171 } 171 }
172 172
173 void DownloadThrottlingResourceHandler::ContinueDownload() { 173 void DownloadThrottlingResourceHandler::ContinueDownload() {
174 DCHECK(!download_handler_.get()); 174 DCHECK(!download_handler_.get());
175 if (!request_closed_) { 175 if (!request_closed_) {
176 download_handler_ = 176 download_handler_ = new DownloadResourceHandler(
177 new DownloadResourceHandler(host_, 177 host_,
178 render_process_host_id_, 178 render_process_host_id_,
179 render_view_id_, 179 render_view_id_,
180 request_id_, 180 request_id_,
181 url_, 181 url_,
182 host_->download_file_manager(), 182 host_->download_file_manager(),
183 request_, 183 request_,
184 false, 184 false,
185 DownloadSaveInfo()); 185 DownloadResourceHandler::OnStartedCallback(),
186 DownloadSaveInfo());
186 if (response_.get()) 187 if (response_.get())
187 download_handler_->OnResponseStarted(request_id_, response_.get()); 188 download_handler_->OnResponseStarted(request_id_, response_.get());
188 189
189 if (tmp_buffer_length_) 190 if (tmp_buffer_length_)
190 CopyTmpBufferToDownloadHandler(); 191 CopyTmpBufferToDownloadHandler();
191 192
192 // And let the request continue. 193 // And let the request continue.
193 host_->PauseRequest(render_process_host_id_, request_id_, false); 194 host_->PauseRequest(render_process_host_id_, request_id_, false);
194 } 195 }
195 Release(); // Release the addtional reference from constructor. 196 Release(); // Release the addtional reference from constructor.
196 } 197 }
197 198
198 void DownloadThrottlingResourceHandler::CopyTmpBufferToDownloadHandler() { 199 void DownloadThrottlingResourceHandler::CopyTmpBufferToDownloadHandler() {
199 // Copy over the tmp buffer. 200 // Copy over the tmp buffer.
200 net::IOBuffer* buffer; 201 net::IOBuffer* buffer;
201 int buf_size; 202 int buf_size;
202 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size, 203 if (download_handler_->OnWillRead(request_id_, &buffer, &buf_size,
203 tmp_buffer_length_)) { 204 tmp_buffer_length_)) {
204 CHECK(buf_size >= tmp_buffer_length_); 205 CHECK(buf_size >= tmp_buffer_length_);
205 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_); 206 memcpy(buffer->data(), tmp_buffer_->data(), tmp_buffer_length_);
206 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_); 207 download_handler_->OnReadCompleted(request_id_, &tmp_buffer_length_);
207 } 208 }
208 tmp_buffer_length_ = 0; 209 tmp_buffer_length_ = 0;
209 tmp_buffer_ = NULL; 210 tmp_buffer_ = NULL;
210 } 211 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/download_resource_handler.cc ('k') | chrome/browser/ui/webui/downloads_dom_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698