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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( | 44 ServiceWorkerURLRequestJob::ServiceWorkerURLRequestJob( |
45 net::URLRequest* request, | 45 net::URLRequest* request, |
46 net::NetworkDelegate* network_delegate, | 46 net::NetworkDelegate* network_delegate, |
47 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 47 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
48 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 48 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
49 FetchRequestMode request_mode, | 49 FetchRequestMode request_mode, |
50 FetchCredentialsMode credentials_mode, | 50 FetchCredentialsMode credentials_mode, |
| 51 RequestContextType request_context_type, |
| 52 RequestContextFrameType frame_type, |
51 scoped_refptr<ResourceRequestBody> body) | 53 scoped_refptr<ResourceRequestBody> body) |
52 : net::URLRequestJob(request, network_delegate), | 54 : net::URLRequestJob(request, network_delegate), |
53 provider_host_(provider_host), | 55 provider_host_(provider_host), |
54 response_type_(NOT_DETERMINED), | 56 response_type_(NOT_DETERMINED), |
55 is_started_(false), | 57 is_started_(false), |
56 blob_storage_context_(blob_storage_context), | 58 blob_storage_context_(blob_storage_context), |
57 request_mode_(request_mode), | 59 request_mode_(request_mode), |
58 credentials_mode_(credentials_mode), | 60 credentials_mode_(credentials_mode), |
| 61 request_context_type_(request_context_type), |
| 62 frame_type_(frame_type), |
59 fall_back_required_(false), | 63 fall_back_required_(false), |
60 body_(body), | 64 body_(body), |
61 weak_factory_(this) { | 65 weak_factory_(this) { |
62 } | 66 } |
63 | 67 |
64 void ServiceWorkerURLRequestJob::FallbackToNetwork() { | 68 void ServiceWorkerURLRequestJob::FallbackToNetwork() { |
65 DCHECK_EQ(NOT_DETERMINED, response_type_); | 69 DCHECK_EQ(NOT_DETERMINED, response_type_); |
66 response_type_ = FALLBACK_TO_NETWORK; | 70 response_type_ = FALLBACK_TO_NETWORK; |
67 MaybeStartRequest(); | 71 MaybeStartRequest(); |
68 } | 72 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 281 } |
278 | 282 |
279 scoped_ptr<ServiceWorkerFetchRequest> | 283 scoped_ptr<ServiceWorkerFetchRequest> |
280 ServiceWorkerURLRequestJob::CreateFetchRequest() { | 284 ServiceWorkerURLRequestJob::CreateFetchRequest() { |
281 std::string blob_uuid; | 285 std::string blob_uuid; |
282 uint64 blob_size = 0; | 286 uint64 blob_size = 0; |
283 CreateRequestBodyBlob(&blob_uuid, &blob_size); | 287 CreateRequestBodyBlob(&blob_uuid, &blob_size); |
284 scoped_ptr<ServiceWorkerFetchRequest> request( | 288 scoped_ptr<ServiceWorkerFetchRequest> request( |
285 new ServiceWorkerFetchRequest()); | 289 new ServiceWorkerFetchRequest()); |
286 request->mode = request_mode_; | 290 request->mode = request_mode_; |
| 291 request->request_context_type = request_context_type_; |
| 292 request->frame_type = frame_type_; |
287 request->url = request_->url(); | 293 request->url = request_->url(); |
288 request->method = request_->method(); | 294 request->method = request_->method(); |
289 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); | 295 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); |
290 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { | 296 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { |
291 if (it.name() == kDevToolsRequestInitiator || | 297 if (it.name() == kDevToolsRequestInitiator || |
292 it.name() == kDevToolsEmulateNetworkConditionsClientId) { | 298 it.name() == kDevToolsEmulateNetworkConditionsClientId) { |
293 continue; | 299 continue; |
294 } | 300 } |
295 request->headers[it.name()] = it.value(); | 301 request->headers[it.name()] = it.value(); |
296 } | 302 } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 486 |
481 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { | 487 void ServiceWorkerURLRequestJob::DeliverErrorResponse() { |
482 // TODO(falken): Print an error to the console of the ServiceWorker and of | 488 // TODO(falken): Print an error to the console of the ServiceWorker and of |
483 // the requesting page. | 489 // the requesting page. |
484 CreateResponseHeader( | 490 CreateResponseHeader( |
485 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); | 491 500, "Service Worker Response Error", ServiceWorkerHeaderMap()); |
486 CommitResponseHeader(); | 492 CommitResponseHeader(); |
487 } | 493 } |
488 | 494 |
489 } // namespace content | 495 } // namespace content |
OLD | NEW |