OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/service_worker/service_worker_url_request_job.h" | 5 #include "content/browser/service_worker/service_worker_url_request_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" | 9 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" |
10 #include "content/browser/service_worker/service_worker_provider_host.h" | 10 #include "content/browser/service_worker/service_worker_provider_host.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 | 145 |
146 void ServiceWorkerURLRequestJob::OnResponseStarted(net::URLRequest* request) { | 146 void ServiceWorkerURLRequestJob::OnResponseStarted(net::URLRequest* request) { |
147 // TODO(falken): Add Content-Length, Content-Type if they were not provided in | 147 // TODO(falken): Add Content-Length, Content-Type if they were not provided in |
148 // the ServiceWorkerResponse. | 148 // the ServiceWorkerResponse. |
149 CommitResponseHeader(); | 149 CommitResponseHeader(); |
150 } | 150 } |
151 | 151 |
152 void ServiceWorkerURLRequestJob::OnReadCompleted(net::URLRequest* request, | 152 void ServiceWorkerURLRequestJob::OnReadCompleted(net::URLRequest* request, |
153 int bytes_read) { | 153 int bytes_read) { |
| 154 SetStatus(request->status()); |
154 if (!request->status().is_success()) { | 155 if (!request->status().is_success()) { |
155 NotifyDone(request->status()); | 156 NotifyDone(request->status()); |
156 return; | 157 return; |
157 } | 158 } |
158 NotifyReadComplete(bytes_read); | 159 NotifyReadComplete(bytes_read); |
159 if (bytes_read == 0) | 160 if (bytes_read == 0) |
160 NotifyDone(request->status()); | 161 NotifyDone(request->status()); |
161 } | 162 } |
162 | 163 |
163 const net::HttpResponseInfo* ServiceWorkerURLRequestJob::http_info() const { | 164 const net::HttpResponseInfo* ServiceWorkerURLRequestJob::http_info() const { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 295 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
295 // TODO(falken): Print an error to the console of the ServiceWorker and of | 296 // TODO(falken): Print an error to the console of the ServiceWorker and of |
296 // the requesting page. | 297 // the requesting page. |
297 CreateResponseHeader(500, | 298 CreateResponseHeader(500, |
298 "Service Worker Response Error", | 299 "Service Worker Response Error", |
299 std::map<std::string, std::string>()); | 300 std::map<std::string, std::string>()); |
300 CommitResponseHeader(); | 301 CommitResponseHeader(); |
301 } | 302 } |
302 | 303 |
303 } // namespace content | 304 } // namespace content |
OLD | NEW |