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

Unified Diff: content/browser/service_worker/service_worker_write_to_cache_job.cc

Issue 640923003: [ServiceWorker] Handle bytes_read=0 async result correctly in ServiceWorkerWriteToCacheJob. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add DCHECK and remove retrurn Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_write_to_cache_job.cc
diff --git a/content/browser/service_worker/service_worker_write_to_cache_job.cc b/content/browser/service_worker/service_worker_write_to_cache_job.cc
index fea86a4b91692010ee6b80cb46e441c2e5b67203..4e2c24fd49051f23ed7503186f8882f8e018b1af 100644
--- a/content/browser/service_worker/service_worker_write_to_cache_job.cc
+++ b/content/browser/service_worker/service_worker_write_to_cache_job.cc
@@ -360,7 +360,8 @@ void ServiceWorkerWriteToCacheJob::OnReadCompleted(
net::URLRequest* request,
int bytes_read) {
DCHECK_EQ(net_request_, request);
- if (!request->status().is_success()) {
+ if (bytes_read < 0) {
+ DCHECK(!request->status().is_success());
AsyncNotifyDoneHelper(request->status());
return;
}
@@ -368,18 +369,20 @@ void ServiceWorkerWriteToCacheJob::OnReadCompleted(
WriteDataToCache(bytes_read);
return;
}
- TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker",
- "ServiceWorkerWriteToCacheJob::ExecutingJob",
- this,
- "WriteHeadersToCache");
- // We're done with all.
- AsyncNotifyDoneHelper(request->status());
- return;
+ // No more data to process, the job is complete.
+ DCHECK(request->status().is_success());
+ io_buffer_ = NULL;
+ version_->script_cache_map()->NotifyFinishedCaching(
+ url_, net::URLRequestStatus());
+ did_notify_finished_ = true;
+ SetStatus(net::URLRequestStatus()); // Clear the IO_PENDING status
+ NotifyReadComplete(0);
}
void ServiceWorkerWriteToCacheJob::AsyncNotifyDoneHelper(
const net::URLRequestStatus& status) {
DCHECK(!status.is_io_pending());
+ DCHECK(!did_notify_finished_);
version_->script_cache_map()->NotifyFinishedCaching(url_, status);
did_notify_finished_ = true;
SetStatus(status);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698