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

Side by Side Diff: content/browser/renderer_host/buffered_resource_handler.cc

Issue 10392111: Use ByteStream in downloads system to decouple source and sink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments and fixed tests. Created 8 years, 7 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/buffered_resource_handler.h" 5 #include "content/browser/renderer_host/buffered_resource_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // TODO(abarth): We should abstract the response_code test, but this kind 274 // TODO(abarth): We should abstract the response_code test, but this kind
275 // of check is scattered throughout our codebase. 275 // of check is scattered throughout our codebase.
276 request_->CancelWithError(net::ERR_FILE_NOT_FOUND); 276 request_->CancelWithError(net::ERR_FILE_NOT_FOUND);
277 return false; 277 return false;
278 } 278 }
279 279
280 X509UserCertResourceHandler* x509_cert_handler = 280 X509UserCertResourceHandler* x509_cert_handler =
281 new X509UserCertResourceHandler(request_, 281 new X509UserCertResourceHandler(request_,
282 info->GetChildID(), 282 info->GetChildID(),
283 info->GetRouteID()); 283 info->GetRouteID());
284 if (!UseAlternateResourceHandler(request_id, x509_cert_handler, defer)) 284 return UseAlternateResourceHandler(request_id, x509_cert_handler, defer);
benjhayden 2012/05/26 20:42:02 Is it ok to not run next_handler_->OnResponseStart
Randy Smith (Not in Mondays) 2012/05/28 02:51:37 UseAlternateResourceHandler() takes responsibility
285 return false;
286 } else if (info->allow_download() && ShouldDownload(NULL)) { 285 } else if (info->allow_download() && ShouldDownload(NULL)) {
287 // Forward the data to the download thread. 286 // Forward the data to the download thread.
288 287
289 if (response_->headers && // Can be NULL if FTP. 288 if (response_->headers && // Can be NULL if FTP.
290 response_->headers->response_code() / 100 != 2) { 289 response_->headers->response_code() / 100 != 2) {
291 // The response code indicates that this is an error page, but we don't 290 // The response code indicates that this is an error page, but we don't
292 // know how to display the content. We follow Firefox here and show our 291 // know how to display the content. We follow Firefox here and show our
293 // own error page instead of triggering a download. 292 // own error page instead of triggering a download.
294 // TODO(abarth): We should abstract the response_code test, but this kind 293 // TODO(abarth): We should abstract the response_code test, but this kind
295 // of check is scattered throughout our codebase. 294 // of check is scattered throughout our codebase.
296 request_->CancelWithError(net::ERR_FILE_NOT_FOUND); 295 request_->CancelWithError(net::ERR_FILE_NOT_FOUND);
297 return false; 296 return false;
298 } 297 }
299 298
300 info->set_is_download(true); 299 info->set_is_download(true);
301 300
302 scoped_refptr<ResourceHandler> handler( 301 scoped_refptr<ResourceHandler> handler(
303 host_->CreateResourceHandlerForDownload( 302 host_->CreateResourceHandlerForDownload(
304 request_, 303 request_,
305 info->GetContext(), 304 info->GetContext(),
306 info->GetChildID(), 305 info->GetChildID(),
307 info->GetRouteID(), 306 info->GetRouteID(),
308 info->GetRequestID(), 307 info->GetRequestID(),
309 true, // is_content_initiated 308 true, // is_content_initiated
310 DownloadSaveInfo(), 309 DownloadSaveInfo(),
311 DownloadResourceHandler::OnStartedCallback())); 310 DownloadResourceHandler::OnStartedCallback()));
312 311
313 if (!UseAlternateResourceHandler(request_id, handler, defer)) 312 return UseAlternateResourceHandler(request_id, handler, defer);
314 return false;
315 } 313 }
316 314
317 if (*defer) 315 if (*defer)
318 return true; 316 return true;
319 317
320 return next_handler_->OnResponseStarted(request_id, response_, defer); 318 return next_handler_->OnResponseStarted(request_id, response_, defer);
321 } 319 }
322 320
323 bool BufferedResourceHandler::ShouldWaitForPlugins() { 321 bool BufferedResourceHandler::ShouldWaitForPlugins() {
324 bool need_plugin_list; 322 bool need_plugin_list;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 453
456 bool defer = false; 454 bool defer = false;
457 if (!CompleteResponseStarted(request_id, &defer)) { 455 if (!CompleteResponseStarted(request_id, &defer)) {
458 host_->CancelRequest(child_id, request_id, false); 456 host_->CancelRequest(child_id, request_id, false);
459 } else if (!defer && needs_resume) { 457 } else if (!defer && needs_resume) {
460 host_->ResumeDeferredRequest(child_id, request_id); 458 host_->ResumeDeferredRequest(child_id, request_id);
461 } 459 }
462 } 460 }
463 461
464 } // namespace content 462 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698