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

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

Issue 10451023: Avoid double calling OnResponseStarted from BufferedResourceHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to LKGR. Created 8 years, 6 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
« no previous file with comments | « content/browser/download/download_resource_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
285 return false; 285 return UseAlternateResourceHandler(request_id, x509_cert_handler, defer);
286 } else if (info->allow_download() && ShouldDownload(NULL)) { 286 }
287
288 if (info->allow_download() && ShouldDownload(NULL)) {
287 // Forward the data to the download thread. 289 // Forward the data to the download thread.
288 290
289 if (response_->headers && // Can be NULL if FTP. 291 if (response_->headers && // Can be NULL if FTP.
290 response_->headers->response_code() / 100 != 2) { 292 response_->headers->response_code() / 100 != 2) {
291 // The response code indicates that this is an error page, but we don't 293 // 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 294 // know how to display the content. We follow Firefox here and show our
293 // own error page instead of triggering a download. 295 // own error page instead of triggering a download.
294 // TODO(abarth): We should abstract the response_code test, but this kind 296 // TODO(abarth): We should abstract the response_code test, but this kind
295 // of check is scattered throughout our codebase. 297 // of check is scattered throughout our codebase.
296 request_->CancelWithError(net::ERR_FILE_NOT_FOUND); 298 request_->CancelWithError(net::ERR_FILE_NOT_FOUND);
297 return false; 299 return false;
298 } 300 }
299 301
300 info->set_is_download(true); 302 info->set_is_download(true);
301 303
302 scoped_refptr<ResourceHandler> handler( 304 scoped_refptr<ResourceHandler> handler(
303 host_->CreateResourceHandlerForDownload( 305 host_->CreateResourceHandlerForDownload(
304 request_, 306 request_,
305 info->GetContext(), 307 info->GetContext(),
306 info->GetChildID(), 308 info->GetChildID(),
307 info->GetRouteID(), 309 info->GetRouteID(),
308 info->GetRequestID(), 310 info->GetRequestID(),
309 true, // is_content_initiated 311 true, // is_content_initiated
310 DownloadSaveInfo(), 312 DownloadSaveInfo(),
311 DownloadResourceHandler::OnStartedCallback())); 313 DownloadResourceHandler::OnStartedCallback()));
312 314
313 if (!UseAlternateResourceHandler(request_id, handler, defer)) 315 return UseAlternateResourceHandler(request_id, handler, defer);
314 return false;
315 } 316 }
316 317
317 if (*defer) 318 if (*defer)
318 return true; 319 return true;
319 320
320 return next_handler_->OnResponseStarted(request_id, response_, defer); 321 return next_handler_->OnResponseStarted(request_id, response_, defer);
321 } 322 }
322 323
323 bool BufferedResourceHandler::ShouldWaitForPlugins() { 324 bool BufferedResourceHandler::ShouldWaitForPlugins() {
324 bool need_plugin_list; 325 bool need_plugin_list;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 456
456 bool defer = false; 457 bool defer = false;
457 if (!CompleteResponseStarted(request_id, &defer)) { 458 if (!CompleteResponseStarted(request_id, &defer)) {
458 host_->CancelRequest(child_id, request_id, false); 459 host_->CancelRequest(child_id, request_id, false);
459 } else if (!defer && needs_resume) { 460 } else if (!defer && needs_resume) {
460 host_->ResumeDeferredRequest(child_id, request_id); 461 host_->ResumeDeferredRequest(child_id, request_id);
461 } 462 }
462 } 463 }
463 464
464 } // namespace content 465 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_resource_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698