| 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 <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "storage/browser/blob/blob_url_request_job_factory.h" | 28 #include "storage/browser/blob/blob_url_request_job_factory.h" |
| 29 #include "ui/base/page_transition_types.h" | 29 #include "ui/base/page_transition_types.h" |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 | 32 |
| 33 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( | 33 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( |
| 34 net::URLRequest* request, | 34 net::URLRequest* request, |
| 35 net::NetworkDelegate* network_delegate, | 35 net::NetworkDelegate* network_delegate, |
| 36 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 36 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 37 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 37 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| 38 FetchRequestMode request_mode, |
| 38 scoped_refptr<ResourceRequestBody> body) | 39 scoped_refptr<ResourceRequestBody> body) |
| 39 : net::URLRequestJob(request, network_delegate), | 40 : net::URLRequestJob(request, network_delegate), |
| 40 provider_host_(provider_host), | 41 provider_host_(provider_host), |
| 41 response_type_(NOT_DETERMINED), | 42 response_type_(NOT_DETERMINED), |
| 42 is_started_(false), | 43 is_started_(false), |
| 43 blob_storage_context_(blob_storage_context), | 44 blob_storage_context_(blob_storage_context), |
| 45 request_mode_(request_mode), |
| 44 body_(body), | 46 body_(body), |
| 45 weak_factory_(this) { | 47 weak_factory_(this) { |
| 46 } | 48 } |
| 47 | 49 |
| 48 void ServiceWorkerURLRequestJob::FallbackToNetwork() { | 50 void ServiceWorkerURLRequestJob::FallbackToNetwork() { |
| 49 DCHECK_EQ(NOT_DETERMINED, response_type_); | 51 DCHECK_EQ(NOT_DETERMINED, response_type_); |
| 50 response_type_ = FALLBACK_TO_NETWORK; | 52 response_type_ = FALLBACK_TO_NETWORK; |
| 51 MaybeStartRequest(); | 53 MaybeStartRequest(); |
| 52 } | 54 } |
| 53 | 55 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 NOTREACHED(); | 259 NOTREACHED(); |
| 258 } | 260 } |
| 259 | 261 |
| 260 scoped_ptr<ServiceWorkerFetchRequest> | 262 scoped_ptr<ServiceWorkerFetchRequest> |
| 261 ServiceWorkerURLRequestJob::CreateFetchRequest() { | 263 ServiceWorkerURLRequestJob::CreateFetchRequest() { |
| 262 std::string blob_uuid; | 264 std::string blob_uuid; |
| 263 uint64 blob_size = 0; | 265 uint64 blob_size = 0; |
| 264 CreateRequestBodyBlob(&blob_uuid, &blob_size); | 266 CreateRequestBodyBlob(&blob_uuid, &blob_size); |
| 265 scoped_ptr<ServiceWorkerFetchRequest> request( | 267 scoped_ptr<ServiceWorkerFetchRequest> request( |
| 266 new ServiceWorkerFetchRequest()); | 268 new ServiceWorkerFetchRequest()); |
| 267 | 269 request->mode = request_mode_; |
| 268 request->url = request_->url(); | 270 request->url = request_->url(); |
| 269 request->method = request_->method(); | 271 request->method = request_->method(); |
| 270 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); | 272 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); |
| 271 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) | 273 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) |
| 272 request->headers[it.name()] = it.value(); | 274 request->headers[it.name()] = it.value(); |
| 273 request->blob_uuid = blob_uuid; | 275 request->blob_uuid = blob_uuid; |
| 274 request->blob_size = blob_size; | 276 request->blob_size = blob_size; |
| 275 request->referrer = GURL(request_->referrer()); | 277 request->referrer = GURL(request_->referrer()); |
| 276 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); | 278 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); |
| 277 if (info) { | 279 if (info) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 445 |
| 444 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 446 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
| 445 // TODO(falken): Print an error to the console of the ServiceWorker and of | 447 // TODO(falken): Print an error to the console of the ServiceWorker and of |
| 446 // the requesting page. | 448 // the requesting page. |
| 447 CreateResponseHeader( | 449 CreateResponseHeader( |
| 448 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); | 450 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); |
| 449 CommitResponseHeader(); | 451 CommitResponseHeader(); |
| 450 } | 452 } |
| 451 | 453 |
| 452 } // namespace content | 454 } // namespace content |
| OLD | NEW |