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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "content/common/service_worker/service_worker_status_code.h" | 13 #include "content/common/service_worker/service_worker_status_code.h" |
14 #include "content/common/service_worker/service_worker_types.h" | 14 #include "content/common/service_worker/service_worker_types.h" |
15 #include "net/http/http_byte_range.h" | 15 #include "net/http/http_byte_range.h" |
16 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
17 #include "net/url_request/url_request_job.h" | 17 #include "net/url_request/url_request_job.h" |
18 | 18 |
19 namespace webkit_blob { | 19 namespace storage { |
20 class BlobDataHandle; | 20 class BlobDataHandle; |
21 class BlobStorageContext; | 21 class BlobStorageContext; |
22 } | 22 } |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 | 25 |
26 class ResourceRequestBody; | 26 class ResourceRequestBody; |
27 class ServiceWorkerContextCore; | 27 class ServiceWorkerContextCore; |
28 class ServiceWorkerFetchDispatcher; | 28 class ServiceWorkerFetchDispatcher; |
29 class ServiceWorkerProviderHost; | 29 class ServiceWorkerProviderHost; |
30 | 30 |
31 class CONTENT_EXPORT ServiceWorkerURLRequestJob | 31 class CONTENT_EXPORT ServiceWorkerURLRequestJob |
32 : public net::URLRequestJob, | 32 : public net::URLRequestJob, |
33 public net::URLRequest::Delegate { | 33 public net::URLRequest::Delegate { |
34 public: | 34 public: |
35 ServiceWorkerURLRequestJob( | 35 ServiceWorkerURLRequestJob( |
36 net::URLRequest* request, | 36 net::URLRequest* request, |
37 net::NetworkDelegate* network_delegate, | 37 net::NetworkDelegate* network_delegate, |
38 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 38 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
39 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context, | 39 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
40 scoped_refptr<ResourceRequestBody> body); | 40 scoped_refptr<ResourceRequestBody> body); |
41 | 41 |
42 // Sets the response type. | 42 // Sets the response type. |
43 void FallbackToNetwork(); | 43 void FallbackToNetwork(); |
44 void ForwardToServiceWorker(); | 44 void ForwardToServiceWorker(); |
45 | 45 |
46 bool ShouldFallbackToNetwork() const { | 46 bool ShouldFallbackToNetwork() const { |
47 return response_type_ == FALLBACK_TO_NETWORK; | 47 return response_type_ == FALLBACK_TO_NETWORK; |
48 } | 48 } |
49 bool ShouldForwardToServiceWorker() const { | 49 bool ShouldForwardToServiceWorker() const { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 net::HttpByteRange byte_range_; | 136 net::HttpByteRange byte_range_; |
137 scoped_ptr<net::HttpResponseInfo> range_response_info_; | 137 scoped_ptr<net::HttpResponseInfo> range_response_info_; |
138 scoped_ptr<net::HttpResponseInfo> http_response_info_; | 138 scoped_ptr<net::HttpResponseInfo> http_response_info_; |
139 // Headers that have not yet been committed to |http_response_info_|. | 139 // Headers that have not yet been committed to |http_response_info_|. |
140 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; | 140 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; |
141 GURL response_url_; | 141 GURL response_url_; |
142 | 142 |
143 // Used when response type is FORWARD_TO_SERVICE_WORKER. | 143 // Used when response type is FORWARD_TO_SERVICE_WORKER. |
144 scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; | 144 scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; |
145 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context_; | 145 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
146 scoped_ptr<net::URLRequest> blob_request_; | 146 scoped_ptr<net::URLRequest> blob_request_; |
147 // ResourceRequestBody has a collection of BlobDataHandles attached to it | 147 // ResourceRequestBody has a collection of BlobDataHandles attached to it |
148 // using the userdata mechanism. So we have to keep it not to free the blobs. | 148 // using the userdata mechanism. So we have to keep it not to free the blobs. |
149 scoped_refptr<ResourceRequestBody> body_; | 149 scoped_refptr<ResourceRequestBody> body_; |
150 scoped_ptr<webkit_blob::BlobDataHandle> request_body_blob_data_handle_; | 150 scoped_ptr<storage::BlobDataHandle> request_body_blob_data_handle_; |
151 | 151 |
152 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; | 152 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; |
153 | 153 |
154 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); | 154 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); |
155 }; | 155 }; |
156 | 156 |
157 } // namespace content | 157 } // namespace content |
158 | 158 |
159 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 159 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
OLD | NEW |