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 <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/optional.h" | 18 #include "base/optional.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "content/browser/service_worker/embedded_worker_status.h" | 20 #include "content/browser/service_worker/embedded_worker_status.h" |
21 #include "content/browser/service_worker/service_worker_metrics.h" | 21 #include "content/browser/service_worker/service_worker_metrics.h" |
22 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
23 #include "content/common/service_worker/service_worker_status_code.h" | 23 #include "content/common/service_worker/service_worker_status_code.h" |
24 #include "content/common/service_worker/service_worker_types.h" | 24 #include "content/common/service_worker/service_worker_types.h" |
25 #include "content/public/common/request_context_frame_type.h" | 25 #include "content/public/common/request_context_frame_type.h" |
26 #include "content/public/common/request_context_type.h" | 26 #include "content/public/common/request_context_type.h" |
27 #include "content/public/common/resource_type.h" | 27 #include "content/public/common/resource_type.h" |
| 28 #include "mojo/public/cpp/system/data_pipe.h" |
28 #include "net/http/http_byte_range.h" | 29 #include "net/http/http_byte_range.h" |
29 #include "net/url_request/url_request.h" | 30 #include "net/url_request/url_request.h" |
30 #include "net/url_request/url_request_job.h" | 31 #include "net/url_request/url_request_job.h" |
31 #include "net/url_request/url_request_status.h" | 32 #include "net/url_request/url_request_status.h" |
32 #include "storage/common/blob_storage/blob_storage_constants.h" | 33 #include "storage/common/blob_storage/blob_storage_constants.h" |
33 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" | 34 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" |
34 #include "url/gurl.h" | 35 #include "url/gurl.h" |
35 | 36 |
36 namespace net { | 37 namespace net { |
37 class IOBuffer; | 38 class IOBuffer; |
38 } // namespace net | 39 } // namespace net |
39 | 40 |
40 namespace storage { | 41 namespace storage { |
41 class BlobDataHandle; | 42 class BlobDataHandle; |
42 class BlobStorageContext; | 43 class BlobStorageContext; |
43 } // namespace storage | 44 } // namespace storage |
44 | 45 |
45 namespace content { | 46 namespace content { |
46 | 47 |
47 class ResourceContext; | 48 class ResourceContext; |
48 class ResourceRequestBodyImpl; | 49 class ResourceRequestBodyImpl; |
49 class ServiceWorkerBlobReader; | 50 class ServiceWorkerBlobReader; |
| 51 class ServiceWorkerDataPipeReader; |
50 class ServiceWorkerStreamReader; | 52 class ServiceWorkerStreamReader; |
51 class ServiceWorkerFetchDispatcher; | 53 class ServiceWorkerFetchDispatcher; |
52 class ServiceWorkerVersion; | 54 class ServiceWorkerVersion; |
53 class Stream; | 55 class Stream; |
54 | 56 |
55 class CONTENT_EXPORT ServiceWorkerURLRequestJob : public net::URLRequestJob { | 57 class CONTENT_EXPORT ServiceWorkerURLRequestJob : public net::URLRequestJob { |
56 public: | 58 public: |
57 class CONTENT_EXPORT Delegate { | 59 class CONTENT_EXPORT Delegate { |
58 public: | 60 public: |
59 virtual ~Delegate() {} | 61 virtual ~Delegate() {} |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // This must not be called until all files in |body_| with unknown size have | 182 // This must not be called until all files in |body_| with unknown size have |
181 // their sizes populated. | 183 // their sizes populated. |
182 void CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size); | 184 void CreateRequestBodyBlob(std::string* blob_uuid, uint64_t* blob_size); |
183 | 185 |
184 // For FORWARD_TO_SERVICE_WORKER case. | 186 // For FORWARD_TO_SERVICE_WORKER case. |
185 void DidPrepareFetchEvent(scoped_refptr<ServiceWorkerVersion> version); | 187 void DidPrepareFetchEvent(scoped_refptr<ServiceWorkerVersion> version); |
186 void DidDispatchFetchEvent( | 188 void DidDispatchFetchEvent( |
187 ServiceWorkerStatusCode status, | 189 ServiceWorkerStatusCode status, |
188 ServiceWorkerFetchEventResult fetch_result, | 190 ServiceWorkerFetchEventResult fetch_result, |
189 const ServiceWorkerResponse& response, | 191 const ServiceWorkerResponse& response, |
| 192 mojo::ScopedDataPipeConsumerHandle stream, |
190 const scoped_refptr<ServiceWorkerVersion>& version); | 193 const scoped_refptr<ServiceWorkerVersion>& version); |
191 void SetResponse(const ServiceWorkerResponse& response); | 194 void SetResponse(const ServiceWorkerResponse& response); |
192 | 195 |
193 // Populates |http_response_headers_|. | 196 // Populates |http_response_headers_|. |
194 void CreateResponseHeader(int status_code, | 197 void CreateResponseHeader(int status_code, |
195 const std::string& status_text, | 198 const std::string& status_text, |
196 const ServiceWorkerHeaderMap& headers); | 199 const ServiceWorkerHeaderMap& headers); |
197 | 200 |
198 // Creates |http_response_info_| using |http_response_headers_| and calls | 201 // Creates |http_response_info_| using |http_response_headers_| and calls |
199 // NotifyHeadersComplete. | 202 // NotifyHeadersComplete. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 blink::WebServiceWorkerResponseType service_worker_response_type_; | 301 blink::WebServiceWorkerResponseType service_worker_response_type_; |
299 | 302 |
300 // Used when response type is FORWARD_TO_SERVICE_WORKER. | 303 // Used when response type is FORWARD_TO_SERVICE_WORKER. |
301 std::unique_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; | 304 std::unique_ptr<ServiceWorkerFetchDispatcher> fetch_dispatcher_; |
302 std::string client_id_; | 305 std::string client_id_; |
303 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; | 306 base::WeakPtr<storage::BlobStorageContext> blob_storage_context_; |
304 const ResourceContext* resource_context_; | 307 const ResourceContext* resource_context_; |
305 // Only one of |blob_reader_| and |stream_reader_| can be non-null. | 308 // Only one of |blob_reader_| and |stream_reader_| can be non-null. |
306 std::unique_ptr<ServiceWorkerBlobReader> blob_reader_; | 309 std::unique_ptr<ServiceWorkerBlobReader> blob_reader_; |
307 std::unique_ptr<ServiceWorkerStreamReader> stream_reader_; | 310 std::unique_ptr<ServiceWorkerStreamReader> stream_reader_; |
| 311 std::unique_ptr<ServiceWorkerDataPipeReader> data_pipe_reader_; |
308 | 312 |
309 FetchRequestMode request_mode_; | 313 FetchRequestMode request_mode_; |
310 FetchCredentialsMode credentials_mode_; | 314 FetchCredentialsMode credentials_mode_; |
311 FetchRedirectMode redirect_mode_; | 315 FetchRedirectMode redirect_mode_; |
312 const ResourceType resource_type_; | 316 const ResourceType resource_type_; |
313 RequestContextType request_context_type_; | 317 RequestContextType request_context_type_; |
314 RequestContextFrameType frame_type_; | 318 RequestContextFrameType frame_type_; |
315 bool fall_back_required_; | 319 bool fall_back_required_; |
316 // ResourceRequestBody has a collection of BlobDataHandles attached to it | 320 // ResourceRequestBody has a collection of BlobDataHandles attached to it |
317 // using the userdata mechanism. So we have to keep it not to free the blobs. | 321 // using the userdata mechanism. So we have to keep it not to free the blobs. |
(...skipping 13 matching lines...) Expand all Loading... |
331 std::unique_ptr<FileSizeResolver> file_size_resolver_; | 335 std::unique_ptr<FileSizeResolver> file_size_resolver_; |
332 | 336 |
333 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; | 337 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; |
334 | 338 |
335 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); | 339 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); |
336 }; | 340 }; |
337 | 341 |
338 } // namespace content | 342 } // namespace content |
339 | 343 |
340 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 344 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
OLD | NEW |