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 BlobStorageContext; | 20 class BlobStorageContext; |
21 } | 21 } |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 class ServiceWorkerContextCore; | 25 class ServiceWorkerContextCore; |
26 class ServiceWorkerFetchDispatcher; | 26 class ServiceWorkerFetchDispatcher; |
27 class ServiceWorkerProviderHost; | 27 class ServiceWorkerProviderHost; |
28 | 28 |
29 class CONTENT_EXPORT ServiceWorkerURLRequestJob | 29 class CONTENT_EXPORT ServiceWorkerURLRequestJob |
30 : public net::URLRequestJob, | 30 : public net::URLRequestJob, |
31 public net::URLRequest::Delegate { | 31 public net::URLRequest::Delegate { |
32 public: | 32 public: |
33 ServiceWorkerURLRequestJob( | 33 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<webkit_blob::BlobStorageContext> blob_storage_context); | 37 base::WeakPtr<storage::BlobStorageContext> blob_storage_context); |
38 | 38 |
39 // Sets the response type. | 39 // Sets the response type. |
40 void FallbackToNetwork(); | 40 void FallbackToNetwork(); |
41 void ForwardToServiceWorker(); | 41 void ForwardToServiceWorker(); |
42 | 42 |
43 bool ShouldFallbackToNetwork() const { | 43 bool ShouldFallbackToNetwork() const { |
44 return response_type_ == FALLBACK_TO_NETWORK; | 44 return response_type_ == FALLBACK_TO_NETWORK; |
45 } | 45 } |
46 bool ShouldForwardToServiceWorker() const { | 46 bool ShouldForwardToServiceWorker() const { |
47 return response_type_ == FORWARD_TO_SERVICE_WORKER; | 47 return response_type_ == FORWARD_TO_SERVICE_WORKER; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 124 |
125 net::HttpByteRange byte_range_; | 125 net::HttpByteRange byte_range_; |
126 scoped_ptr<net::HttpResponseInfo> range_response_info_; | 126 scoped_ptr<net::HttpResponseInfo> range_response_info_; |
127 scoped_ptr<net::HttpResponseInfo> http_response_info_; | 127 scoped_ptr<net::HttpResponseInfo> http_response_info_; |
128 // Headers that have not yet been committed to |http_response_info_|. | 128 // Headers that have not yet been committed to |http_response_info_|. |
129 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; | 129 scoped_refptr<net::HttpResponseHeaders> http_response_headers_; |
130 GURL response_url_; | 130 GURL response_url_; |
131 | 131 |
132 // Used when response type is FORWARD_TO_SERVICE_WORKER. | 132 // Used when response type is FORWARD_TO_SERVICE_WORKER. |
133 scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; | 133 scoped_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; |
134 base::WeakPtr<webkit_blob::BlobStorageContext> blob_storage_context_; | 134 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
135 scoped_ptr<net::URLRequest> blob_request_; | 135 scoped_ptr<net::URLRequest> blob_request_; |
136 | 136 |
137 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; | 137 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); | 139 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); |
140 }; | 140 }; |
141 | 141 |
142 } // namespace content | 142 } // namespace content |
143 | 143 |
144 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 144 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
OLD | NEW |