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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "content/browser/service_worker/embedded_worker_status.h" |
17 #include "content/browser/service_worker/service_worker_metrics.h" | 18 #include "content/browser/service_worker/service_worker_metrics.h" |
18 #include "content/browser/streams/stream_read_observer.h" | 19 #include "content/browser/streams/stream_read_observer.h" |
19 #include "content/browser/streams/stream_register_observer.h" | 20 #include "content/browser/streams/stream_register_observer.h" |
20 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
21 #include "content/common/service_worker/service_worker_status_code.h" | 22 #include "content/common/service_worker/service_worker_status_code.h" |
22 #include "content/common/service_worker/service_worker_types.h" | 23 #include "content/common/service_worker/service_worker_types.h" |
23 #include "content/public/common/request_context_frame_type.h" | 24 #include "content/public/common/request_context_frame_type.h" |
24 #include "content/public/common/request_context_type.h" | 25 #include "content/public/common/request_context_type.h" |
25 #include "content/public/common/resource_type.h" | 26 #include "content/public/common/resource_type.h" |
26 #include "net/http/http_byte_range.h" | 27 #include "net/http/http_byte_range.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 // Creates ServiceWorkerFetchRequest from |request_| and |body_|. | 173 // Creates ServiceWorkerFetchRequest from |request_| and |body_|. |
173 std::unique_ptr<ServiceWorkerFetchRequest> CreateFetchRequest(); | 174 std::unique_ptr<ServiceWorkerFetchRequest> CreateFetchRequest(); |
174 | 175 |
175 // Creates BlobDataHandle of the request body from |body_|. This handle | 176 // Creates BlobDataHandle of the request body from |body_|. This handle |
176 // |request_body_blob_data_handle_| will be deleted when | 177 // |request_body_blob_data_handle_| will be deleted when |
177 // ServiceWorkerURLRequestJob is deleted. | 178 // ServiceWorkerURLRequestJob is deleted. |
178 // This must not be called until all blobs in |body_| finished construction. | 179 // This must not be called until all blobs in |body_| finished construction. |
179 void CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size); | 180 void CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size); |
180 | 181 |
181 // For FORWARD_TO_SERVICE_WORKER case. | 182 // For FORWARD_TO_SERVICE_WORKER case. |
182 void DidPrepareFetchEvent(); | 183 void DidPrepareFetchEvent(scoped_refptr<ServiceWorkerVersion> version); |
183 void DidDispatchFetchEvent( | 184 void DidDispatchFetchEvent( |
184 ServiceWorkerStatusCode status, | 185 ServiceWorkerStatusCode status, |
185 ServiceWorkerFetchEventResult fetch_result, | 186 ServiceWorkerFetchEventResult fetch_result, |
186 const ServiceWorkerResponse& response, | 187 const ServiceWorkerResponse& response, |
187 const scoped_refptr<ServiceWorkerVersion>& version); | 188 const scoped_refptr<ServiceWorkerVersion>& version); |
188 | 189 |
189 // Populates |http_response_headers_|. | 190 // Populates |http_response_headers_|. |
190 void CreateResponseHeader(int status_code, | 191 void CreateResponseHeader(int status_code, |
191 const std::string& status_text, | 192 const std::string& status_text, |
192 const ServiceWorkerHeaderMap& headers); | 193 const ServiceWorkerHeaderMap& headers); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 ResponseBodyType response_body_type_ = UNKNOWN; | 274 ResponseBodyType response_body_type_ = UNKNOWN; |
274 bool did_record_result_ = false; | 275 bool did_record_result_ = false; |
275 | 276 |
276 bool response_is_in_cache_storage_ = false; | 277 bool response_is_in_cache_storage_ = false; |
277 std::string response_cache_storage_cache_name_; | 278 std::string response_cache_storage_cache_name_; |
278 | 279 |
279 ServiceWorkerHeaderList cors_exposed_header_names_; | 280 ServiceWorkerHeaderList cors_exposed_header_names_; |
280 | 281 |
281 std::unique_ptr<BlobConstructionWaiter> blob_construction_waiter_; | 282 std::unique_ptr<BlobConstructionWaiter> blob_construction_waiter_; |
282 | 283 |
| 284 bool worker_already_activated_ = false; |
| 285 EmbeddedWorkerStatus initial_worker_status_ = EmbeddedWorkerStatus::STOPPED; |
| 286 |
283 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; | 287 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; |
284 | 288 |
285 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); | 289 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); |
286 }; | 290 }; |
287 | 291 |
288 } // namespace content | 292 } // namespace content |
289 | 293 |
290 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 294 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
OLD | NEW |