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 | 13 |
| 14 #include "base/callback.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "content/browser/service_worker/embedded_worker_status.h" | 19 #include "content/browser/service_worker/embedded_worker_status.h" |
19 #include "content/browser/service_worker/service_worker_metrics.h" | 20 #include "content/browser/service_worker/service_worker_metrics.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" |
| 27 #include "mojo/public/cpp/bindings/interface_request.h" |
26 #include "net/http/http_byte_range.h" | 28 #include "net/http/http_byte_range.h" |
27 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
28 #include "net/url_request/url_request_job.h" | 30 #include "net/url_request/url_request_job.h" |
29 #include "net/url_request/url_request_status.h" | 31 #include "net/url_request/url_request_status.h" |
30 #include "storage/common/blob_storage/blob_storage_constants.h" | 32 #include "storage/common/blob_storage/blob_storage_constants.h" |
31 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" | 33 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" |
32 #include "url/gurl.h" | 34 #include "url/gurl.h" |
33 | 35 |
34 namespace net { | 36 namespace net { |
35 class IOBuffer; | 37 class IOBuffer; |
36 } | 38 } // namespace net |
37 | 39 |
38 namespace storage { | 40 namespace storage { |
39 class BlobDataHandle; | 41 class BlobDataHandle; |
40 class BlobStorageContext; | 42 class BlobStorageContext; |
41 } | 43 } // namespace storage |
42 | 44 |
43 namespace content { | 45 namespace content { |
44 | 46 |
| 47 namespace mojom { |
| 48 class URLLoaderFactory; |
| 49 } // namespace mojom |
| 50 |
45 class ResourceContext; | 51 class ResourceContext; |
46 class ResourceRequestBodyImpl; | 52 class ResourceRequestBodyImpl; |
47 class ServiceWorkerBlobReader; | 53 class ServiceWorkerBlobReader; |
48 class ServiceWorkerStreamReader; | 54 class ServiceWorkerStreamReader; |
49 class ServiceWorkerContextCore; | 55 class ServiceWorkerContextCore; |
50 class ServiceWorkerFetchDispatcher; | 56 class ServiceWorkerFetchDispatcher; |
51 class ServiceWorkerProviderHost; | 57 class ServiceWorkerProviderHost; |
52 class ServiceWorkerVersion; | 58 class ServiceWorkerVersion; |
53 class Stream; | 59 class Stream; |
54 | 60 |
55 class CONTENT_EXPORT ServiceWorkerURLRequestJob : public net::URLRequestJob { | 61 class CONTENT_EXPORT ServiceWorkerURLRequestJob : public net::URLRequestJob { |
56 public: | 62 public: |
| 63 using URLLoaderFactoryCallback = |
| 64 base::Callback<bool(mojo::InterfaceRequest<mojom::URLLoaderFactory>)>; |
| 65 |
57 class CONTENT_EXPORT Delegate { | 66 class CONTENT_EXPORT Delegate { |
58 public: | 67 public: |
59 virtual ~Delegate() {} | 68 virtual ~Delegate() {} |
60 | 69 |
61 // Will be invoked before the request is restarted. The caller | 70 // Will be invoked before the request is restarted. The caller |
62 // can use this opportunity to grab state from the | 71 // can use this opportunity to grab state from the |
63 // ServiceWorkerURLRequestJob to determine how it should behave when the | 72 // ServiceWorkerURLRequestJob to determine how it should behave when the |
64 // request is restarted. | 73 // request is restarted. |
65 virtual void OnPrepareToRestart() = 0; | 74 virtual void OnPrepareToRestart() = 0; |
66 | 75 |
(...skipping 21 matching lines...) Expand all Loading... |
88 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 97 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
89 const ResourceContext* resource_context, | 98 const ResourceContext* resource_context, |
90 FetchRequestMode request_mode, | 99 FetchRequestMode request_mode, |
91 FetchCredentialsMode credentials_mode, | 100 FetchCredentialsMode credentials_mode, |
92 FetchRedirectMode redirect_mode, | 101 FetchRedirectMode redirect_mode, |
93 ResourceType resource_type, | 102 ResourceType resource_type, |
94 RequestContextType request_context_type, | 103 RequestContextType request_context_type, |
95 RequestContextFrameType frame_type, | 104 RequestContextFrameType frame_type, |
96 scoped_refptr<ResourceRequestBodyImpl> body, | 105 scoped_refptr<ResourceRequestBodyImpl> body, |
97 ServiceWorkerFetchType fetch_type, | 106 ServiceWorkerFetchType fetch_type, |
| 107 const URLLoaderFactoryCallback& url_loader_factory_callback, |
98 Delegate* delegate); | 108 Delegate* delegate); |
99 | 109 |
100 ~ServiceWorkerURLRequestJob() override; | 110 ~ServiceWorkerURLRequestJob() override; |
101 | 111 |
102 const ResourceContext* resource_context() const { return resource_context_; } | 112 const ResourceContext* resource_context() const { return resource_context_; } |
103 | 113 |
104 // Sets the response type. | 114 // Sets the response type. |
105 // When an in-flight request possibly needs CORS check, use | 115 // When an in-flight request possibly needs CORS check, use |
106 // FallbackToNetworkOrRenderer. This method will decide whether the request | 116 // FallbackToNetworkOrRenderer. This method will decide whether the request |
107 // can directly go to the network or should fallback to a renderer to send | 117 // can directly go to the network or should fallback to a renderer to send |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 bool response_is_in_cache_storage_ = false; | 287 bool response_is_in_cache_storage_ = false; |
278 std::string response_cache_storage_cache_name_; | 288 std::string response_cache_storage_cache_name_; |
279 | 289 |
280 ServiceWorkerHeaderList cors_exposed_header_names_; | 290 ServiceWorkerHeaderList cors_exposed_header_names_; |
281 | 291 |
282 std::unique_ptr<BlobConstructionWaiter> blob_construction_waiter_; | 292 std::unique_ptr<BlobConstructionWaiter> blob_construction_waiter_; |
283 | 293 |
284 bool worker_already_activated_ = false; | 294 bool worker_already_activated_ = false; |
285 EmbeddedWorkerStatus initial_worker_status_ = EmbeddedWorkerStatus::STOPPED; | 295 EmbeddedWorkerStatus initial_worker_status_ = EmbeddedWorkerStatus::STOPPED; |
286 | 296 |
| 297 const URLLoaderFactoryCallback url_loader_factory_callback_; |
287 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; | 298 base::WeakPtrFactory<ServiceWorkerURLRequestJob> weak_factory_; |
288 | 299 |
289 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); | 300 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerURLRequestJob); |
290 }; | 301 }; |
291 | 302 |
292 } // namespace content | 303 } // namespace content |
293 | 304 |
294 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ | 305 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_URL_REQUEST_JOB_H_ |
OLD | NEW |