summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 15:15:04 +0000
committerrdsmith@chromium.org <rdsmith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-29 15:15:04 +0000
commit5a9d58fa5e3b30f2a69f350bfbd55310bb2fb4c2 (patch)
treeb4f837abd5996b9c943f6bc04da2e66ec4d1444c
parent12ea4192cd69e4b77ca3c50a9efab250c7697714 (diff)
downloadchromium_src-5a9d58fa5e3b30f2a69f350bfbd55310bb2fb4c2.zip
chromium_src-5a9d58fa5e3b30f2a69f350bfbd55310bb2fb4c2.tar.gz
chromium_src-5a9d58fa5e3b30f2a69f350bfbd55310bb2fb4c2.tar.bz2
Avoid double calling OnResponseStarted from BufferedResourceHandler
BUG=129646 R=darin@chromium.org Review URL: https://chromiumcodereview.appspot.com/10451023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139295 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/download/download_resource_handler.cc7
-rw-r--r--content/browser/download/download_resource_handler.h3
-rw-r--r--content/browser/renderer_host/buffered_resource_handler.cc11
3 files changed, 15 insertions, 6 deletions
diff --git a/content/browser/download/download_resource_handler.cc b/content/browser/download/download_resource_handler.cc
index 84ab673..757e274 100644
--- a/content/browser/download/download_resource_handler.cc
+++ b/content/browser/download/download_resource_handler.cc
@@ -72,7 +72,8 @@ DownloadResourceHandler::DownloadResourceHandler(
last_buffer_size_(0),
bytes_read_(0),
pause_count_(0),
- was_deferred_(false) {
+ was_deferred_(false),
+ on_response_started_called_(false) {
download_stats::RecordDownloadCount(download_stats::UNTHROTTLED_COUNT);
}
@@ -96,6 +97,10 @@ bool DownloadResourceHandler::OnResponseStarted(
int request_id,
content::ResourceResponse* response,
bool* defer) {
+ // There can be only one (call)
+ DCHECK(!on_response_started_called_);
+ on_response_started_called_ = true;
+
VLOG(20) << __FUNCTION__ << "()" << DebugString()
<< " request_id = " << request_id;
download_start_time_ = base::TimeTicks::Now();
diff --git a/content/browser/download/download_resource_handler.h b/content/browser/download/download_resource_handler.h
index 6cb273c..66b69b7 100644
--- a/content/browser/download/download_resource_handler.h
+++ b/content/browser/download/download_resource_handler.h
@@ -138,6 +138,9 @@ class DownloadResourceHandler : public ResourceHandler {
int pause_count_;
bool was_deferred_;
+ // For DCHECKing
+ bool on_response_started_called_;
+
static const int kReadBufSize = 32768; // bytes
static const int kThrottleTimeMs = 200; // milliseconds
diff --git a/content/browser/renderer_host/buffered_resource_handler.cc b/content/browser/renderer_host/buffered_resource_handler.cc
index b0de440..2d700bc 100644
--- a/content/browser/renderer_host/buffered_resource_handler.cc
+++ b/content/browser/renderer_host/buffered_resource_handler.cc
@@ -281,9 +281,11 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id,
new X509UserCertResourceHandler(request_,
info->GetChildID(),
info->GetRouteID());
- if (!UseAlternateResourceHandler(request_id, x509_cert_handler, defer))
- return false;
- } else if (info->allow_download() && ShouldDownload(NULL)) {
+
+ return UseAlternateResourceHandler(request_id, x509_cert_handler, defer);
+ }
+
+ if (info->allow_download() && ShouldDownload(NULL)) {
// Forward the data to the download thread.
if (response_->headers && // Can be NULL if FTP.
@@ -310,8 +312,7 @@ bool BufferedResourceHandler::CompleteResponseStarted(int request_id,
DownloadSaveInfo(),
DownloadResourceHandler::OnStartedCallback()));
- if (!UseAlternateResourceHandler(request_id, handler, defer))
- return false;
+ return UseAlternateResourceHandler(request_id, handler, defer);
}
if (*defer)