| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 net::URLRequest* request, | 42 net::URLRequest* request, |
| 43 net::NetworkDelegate* network_delegate, | 43 net::NetworkDelegate* network_delegate, |
| 44 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 44 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
| 45 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 45 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
| 46 const ResourceContext* resource_context, | 46 const ResourceContext* resource_context, |
| 47 FetchRequestMode request_mode, | 47 FetchRequestMode request_mode, |
| 48 FetchCredentialsMode credentials_mode, | 48 FetchCredentialsMode credentials_mode, |
| 49 bool is_main_resource_load, | 49 bool is_main_resource_load, |
| 50 RequestContextType request_context_type, | 50 RequestContextType request_context_type, |
| 51 RequestContextFrameType frame_type, | 51 RequestContextFrameType frame_type, |
| 52 const ServiceWorkerClientInfo& client_info, |
| 52 scoped_refptr<ResourceRequestBody> body) | 53 scoped_refptr<ResourceRequestBody> body) |
| 53 : net::URLRequestJob(request, network_delegate), | 54 : net::URLRequestJob(request, network_delegate), |
| 54 provider_host_(provider_host), | 55 provider_host_(provider_host), |
| 55 response_type_(NOT_DETERMINED), | 56 response_type_(NOT_DETERMINED), |
| 56 is_started_(false), | 57 is_started_(false), |
| 57 service_worker_response_type_(blink::WebServiceWorkerResponseTypeDefault), | 58 service_worker_response_type_(blink::WebServiceWorkerResponseTypeDefault), |
| 58 blob_storage_context_(blob_storage_context), | 59 blob_storage_context_(blob_storage_context), |
| 59 resource_context_(resource_context), | 60 resource_context_(resource_context), |
| 60 stream_pending_buffer_size_(0), | 61 stream_pending_buffer_size_(0), |
| 61 request_mode_(request_mode), | 62 request_mode_(request_mode), |
| 62 credentials_mode_(credentials_mode), | 63 credentials_mode_(credentials_mode), |
| 63 is_main_resource_load_(is_main_resource_load), | 64 is_main_resource_load_(is_main_resource_load), |
| 64 request_context_type_(request_context_type), | 65 request_context_type_(request_context_type), |
| 65 frame_type_(frame_type), | 66 frame_type_(frame_type), |
| 67 client_info_(client_info), |
| 66 fall_back_required_(false), | 68 fall_back_required_(false), |
| 67 body_(body), | 69 body_(body), |
| 68 weak_factory_(this) { | 70 weak_factory_(this) { |
| 69 } | 71 } |
| 70 | 72 |
| 71 void ServiceWorkerURLRequestJob::FallbackToNetwork() { | 73 void ServiceWorkerURLRequestJob::FallbackToNetwork() { |
| 72 DCHECK_EQ(NOT_DETERMINED, response_type_); | 74 DCHECK_EQ(NOT_DETERMINED, response_type_); |
| 73 response_type_ = FALLBACK_TO_NETWORK; | 75 response_type_ = FALLBACK_TO_NETWORK; |
| 74 MaybeStartRequest(); | 76 MaybeStartRequest(); |
| 75 } | 77 } |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 std::string blob_uuid; | 372 std::string blob_uuid; |
| 371 uint64 blob_size = 0; | 373 uint64 blob_size = 0; |
| 372 CreateRequestBodyBlob(&blob_uuid, &blob_size); | 374 CreateRequestBodyBlob(&blob_uuid, &blob_size); |
| 373 scoped_ptr<ServiceWorkerFetchRequest> request( | 375 scoped_ptr<ServiceWorkerFetchRequest> request( |
| 374 new ServiceWorkerFetchRequest()); | 376 new ServiceWorkerFetchRequest()); |
| 375 request->mode = request_mode_; | 377 request->mode = request_mode_; |
| 376 request->request_context_type = request_context_type_; | 378 request->request_context_type = request_context_type_; |
| 377 request->frame_type = frame_type_; | 379 request->frame_type = frame_type_; |
| 378 request->url = request_->url(); | 380 request->url = request_->url(); |
| 379 request->method = request_->method(); | 381 request->method = request_->method(); |
| 382 request->client = client_info_; |
| 380 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); | 383 const net::HttpRequestHeaders& headers = request_->extra_request_headers(); |
| 381 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { | 384 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) { |
| 382 if (ServiceWorkerContext::IsExcludedHeaderNameForFetchEvent(it.name())) | 385 if (ServiceWorkerContext::IsExcludedHeaderNameForFetchEvent(it.name())) |
| 383 continue; | 386 continue; |
| 384 request->headers[it.name()] = it.value(); | 387 request->headers[it.name()] = it.value(); |
| 385 } | 388 } |
| 386 request->blob_uuid = blob_uuid; | 389 request->blob_uuid = blob_uuid; |
| 387 request->blob_size = blob_size; | 390 request->blob_size = blob_size; |
| 388 request->credentials_mode = credentials_mode_; | 391 request->credentials_mode = credentials_mode_; |
| 389 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); | 392 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 650 } |
| 648 if (!waiting_stream_url_.is_empty()) { | 651 if (!waiting_stream_url_.is_empty()) { |
| 649 StreamRegistry* stream_registry = | 652 StreamRegistry* stream_registry = |
| 650 GetStreamContextForResourceContext(resource_context_)->registry(); | 653 GetStreamContextForResourceContext(resource_context_)->registry(); |
| 651 stream_registry->RemoveRegisterObserver(waiting_stream_url_); | 654 stream_registry->RemoveRegisterObserver(waiting_stream_url_); |
| 652 stream_registry->AbortPendingStream(waiting_stream_url_); | 655 stream_registry->AbortPendingStream(waiting_stream_url_); |
| 653 } | 656 } |
| 654 } | 657 } |
| 655 | 658 |
| 656 } // namespace content | 659 } // namespace content |
| OLD | NEW |