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_CONTROLLEE_REQUEST_HANDLER
_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HANDLER
_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HANDLER
_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HANDLER
_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include "base/callback.h" |
10 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
15 #include "content/browser/service_worker/service_worker_request_handler.h" | 16 #include "content/browser/service_worker/service_worker_request_handler.h" |
16 #include "content/browser/service_worker/service_worker_url_request_job.h" | 17 #include "content/browser/service_worker/service_worker_url_request_job.h" |
17 #include "content/common/service_worker/service_worker_types.h" | 18 #include "content/common/service_worker/service_worker_types.h" |
18 #include "content/public/common/request_context_frame_type.h" | 19 #include "content/public/common/request_context_frame_type.h" |
19 #include "content/public/common/request_context_type.h" | 20 #include "content/public/common/request_context_type.h" |
20 #include "content/public/common/resource_type.h" | 21 #include "content/public/common/resource_type.h" |
21 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" | 22 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" |
22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 class NetworkDelegate; | 26 class NetworkDelegate; |
26 class URLRequest; | 27 class URLRequest; |
27 } | 28 } |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 | 31 |
| 32 namespace mojom { |
| 33 class URLLoaderFactory; |
| 34 } // namespace mojom |
| 35 |
31 class ResourceRequestBodyImpl; | 36 class ResourceRequestBodyImpl; |
32 class ServiceWorkerRegistration; | 37 class ServiceWorkerRegistration; |
33 class ServiceWorkerVersion; | 38 class ServiceWorkerVersion; |
34 | 39 |
35 // A request handler derivative used to handle requests from | 40 // A request handler derivative used to handle requests from |
36 // controlled documents. | 41 // controlled documents. |
37 class CONTENT_EXPORT ServiceWorkerControlleeRequestHandler | 42 class CONTENT_EXPORT ServiceWorkerControlleeRequestHandler |
38 : public ServiceWorkerRequestHandler, | 43 : public ServiceWorkerRequestHandler, |
39 public ServiceWorkerURLRequestJob::Delegate { | 44 public ServiceWorkerURLRequestJob::Delegate { |
40 public: | 45 public: |
| 46 using URLLoaderFactoryCallback = |
| 47 base::Callback<bool(mojo::InterfaceRequest<mojom::URLLoaderFactory>)>; |
| 48 |
41 ServiceWorkerControlleeRequestHandler( | 49 ServiceWorkerControlleeRequestHandler( |
42 base::WeakPtr<ServiceWorkerContextCore> context, | 50 base::WeakPtr<ServiceWorkerContextCore> context, |
43 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 51 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
44 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 52 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
45 FetchRequestMode request_mode, | 53 FetchRequestMode request_mode, |
46 FetchCredentialsMode credentials_mode, | 54 FetchCredentialsMode credentials_mode, |
47 FetchRedirectMode redirect_mode, | 55 FetchRedirectMode redirect_mode, |
48 ResourceType resource_type, | 56 ResourceType resource_type, |
49 RequestContextType request_context_type, | 57 RequestContextType request_context_type, |
50 RequestContextFrameType frame_type, | 58 RequestContextFrameType frame_type, |
51 scoped_refptr<ResourceRequestBodyImpl> body); | 59 scoped_refptr<ResourceRequestBodyImpl> body, |
| 60 const URLLoaderFactoryCallback& url_loader_factory_callback); |
52 ~ServiceWorkerControlleeRequestHandler() override; | 61 ~ServiceWorkerControlleeRequestHandler() override; |
53 | 62 |
54 // Called via custom URLRequestJobFactory. | 63 // Called via custom URLRequestJobFactory. |
55 net::URLRequestJob* MaybeCreateJob( | 64 net::URLRequestJob* MaybeCreateJob( |
56 net::URLRequest* request, | 65 net::URLRequest* request, |
57 net::NetworkDelegate* network_delegate, | 66 net::NetworkDelegate* network_delegate, |
58 ResourceContext* resource_context) override; | 67 ResourceContext* resource_context) override; |
59 | 68 |
60 private: | 69 private: |
61 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, | 70 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 scoped_refptr<ResourceRequestBodyImpl> body_; | 119 scoped_refptr<ResourceRequestBodyImpl> body_; |
111 ResourceContext* resource_context_; | 120 ResourceContext* resource_context_; |
112 GURL stripped_url_; | 121 GURL stripped_url_; |
113 bool force_update_started_; | 122 bool force_update_started_; |
114 | 123 |
115 // True if the next time this request is started, the response should be | 124 // True if the next time this request is started, the response should be |
116 // delivered from the network, bypassing the ServiceWorker. Cleared after the | 125 // delivered from the network, bypassing the ServiceWorker. Cleared after the |
117 // next intercept opportunity, for main frame requests. | 126 // next intercept opportunity, for main frame requests. |
118 bool use_network_; | 127 bool use_network_; |
119 | 128 |
| 129 const URLLoaderFactoryCallback url_loader_factory_callback_; |
| 130 |
120 base::WeakPtrFactory<ServiceWorkerControlleeRequestHandler> weak_factory_; | 131 base::WeakPtrFactory<ServiceWorkerControlleeRequestHandler> weak_factory_; |
121 | 132 |
122 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerControlleeRequestHandler); | 133 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerControlleeRequestHandler); |
123 }; | 134 }; |
124 | 135 |
125 } // namespace content | 136 } // namespace content |
126 | 137 |
127 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HAND
LER_H_ | 138 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HAND
LER_H_ |
OLD | NEW |