summaryrefslogtreecommitdiffstats
path: root/content/browser/appcache
diff options
context:
space:
mode:
authorxunjieli <xunjieli@chromium.org>2015-11-18 06:34:06 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-18 14:34:50 +0000
commitd77911ac82186d65a8f11555a7a6b1678c769ba2 (patch)
treefb9165f7669c9397052b5c0d8a3eef1f58f40908 /content/browser/appcache
parent03eaf889ebe699c3a5af069d4a2ef2206c6431ad (diff)
downloadchromium_src-d77911ac82186d65a8f11555a7a6b1678c769ba2.zip
chromium_src-d77911ac82186d65a8f11555a7a6b1678c769ba2.tar.gz
chromium_src-d77911ac82186d65a8f11555a7a6b1678c769ba2.tar.bz2
Reland: URLRequestJob: change ReadRawData contract
This CL is to reland crrev.com/1410643007 which was reverted in crrev.com/1437523002. Previously, the interface for URLRequestJob::ReadRawData was as follows: bool ReadRawData(IOBuffer*, int, int*) Subclasses were expected to signal completion of the ReadRawData call by calling NotifyDone, SetStatus, or maybe one of the other Notify* functions on URLRequestJob, most of which do internal housekeeping and also drive the URLRequest's state machine. This made it difficult to reason about the URLRequestJob's state machine and needlessly complicated most of URLRequestJob. The new interface is as follows: int ReadRawData(IOBuffer*, int) Subclasses are required to either: a) Return ERR_IO_PENDING, and call ReadRawDataComplete when the read completes in any way, or b) Return a count of bytes read >= 0, indicating synchronous success, or c) Return another error code < 0, indicating synchronous failure. This substantially narrows the interface between URLRequestJob and its subclasses and moves the logic for the URLRequest state machine largely into URLRequestJob. Also, the signature of URLRequestJob::ReadFilteredData and some other internal URLRequestJob helpers changes to propagate detailed error codes instead of coercing all errors to FAILED. TBR=michaeln@chromium.org,mtomasz@chromium.org,jianli@chromium.org,zork@chromium.org BUG=474859 BUG=329902 Review URL: https://codereview.chromium.org/1439953006 Cr-Commit-Position: refs/heads/master@{#360327}
Diffstat (limited to 'content/browser/appcache')
-rw-r--r--content/browser/appcache/appcache_url_request_job.cc14
-rw-r--r--content/browser/appcache/appcache_url_request_job.h2
2 files changed, 4 insertions, 12 deletions
diff --git a/content/browser/appcache/appcache_url_request_job.cc b/content/browser/appcache/appcache_url_request_job.cc
index 82997f7..de924a1 100644
--- a/content/browser/appcache/appcache_url_request_job.cc
+++ b/content/browser/appcache/appcache_url_request_job.cc
@@ -341,7 +341,6 @@ void AppCacheURLRequestJob::SetupRangeResponse() {
void AppCacheURLRequestJob::OnReadComplete(int result) {
DCHECK(is_delivering_appcache_response());
if (result == 0) {
- NotifyDone(net::URLRequestStatus());
AppCacheHistograms::CountResponseRetrieval(
true, is_main_resource_, manifest_url_.GetOrigin());
} else if (result < 0) {
@@ -349,13 +348,10 @@ void AppCacheURLRequestJob::OnReadComplete(int result) {
storage_->service()->CheckAppCacheResponse(manifest_url_, cache_id_,
entry_.response_id());
}
- NotifyDone(net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
AppCacheHistograms::CountResponseRetrieval(
false, is_main_resource_, manifest_url_.GetOrigin());
- } else {
- SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status
}
- NotifyReadComplete(result);
+ ReadRawDataComplete(result);
}
// net::URLRequestJob overrides ------------------------------------------------
@@ -424,18 +420,14 @@ int AppCacheURLRequestJob::GetResponseCode() const {
return http_info()->headers->response_code();
}
-bool AppCacheURLRequestJob::ReadRawData(net::IOBuffer* buf,
- int buf_size,
- int* bytes_read) {
+int AppCacheURLRequestJob::ReadRawData(net::IOBuffer* buf, int buf_size) {
DCHECK(is_delivering_appcache_response());
DCHECK_NE(buf_size, 0);
- DCHECK(bytes_read);
DCHECK(!reader_->IsReadPending());
reader_->ReadData(buf, buf_size,
base::Bind(&AppCacheURLRequestJob::OnReadComplete,
base::Unretained(this)));
- SetStatus(net::URLRequestStatus(net::URLRequestStatus::IO_PENDING, 0));
- return false;
+ return net::ERR_IO_PENDING;
}
void AppCacheURLRequestJob::SetExtraRequestHeaders(
diff --git a/content/browser/appcache/appcache_url_request_job.h b/content/browser/appcache/appcache_url_request_job.h
index 95a3e18..8f51e7b 100644
--- a/content/browser/appcache/appcache_url_request_job.h
+++ b/content/browser/appcache/appcache_url_request_job.h
@@ -148,7 +148,7 @@ class CONTENT_EXPORT AppCacheURLRequestJob
net::LoadState GetLoadState() const override;
bool GetCharset(std::string* charset) override;
void GetResponseInfo(net::HttpResponseInfo* info) override;
- bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override;
+ int ReadRawData(net::IOBuffer* buf, int buf_size) override;
// Sets extra request headers for Job types that support request headers.
// This is how we get informed of range-requests.