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/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" | 21 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerResponseType.h" |
22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
23 | 23 |
24 namespace net { | 24 namespace net { |
25 class NetworkDelegate; | 25 class NetworkDelegate; |
26 class URLRequest; | 26 class URLRequest; |
27 } | 27 } |
28 | 28 |
29 namespace content { | 29 namespace content { |
30 | 30 |
| 31 class JobWrapper; |
31 class ResourceRequestBodyImpl; | 32 class ResourceRequestBodyImpl; |
32 class ServiceWorkerRegistration; | 33 class ServiceWorkerRegistration; |
33 class ServiceWorkerVersion; | 34 class ServiceWorkerVersion; |
34 | 35 |
35 // A request handler derivative used to handle requests from | 36 // A request handler derivative used to handle requests from |
36 // controlled documents. | 37 // controlled documents. |
37 class CONTENT_EXPORT ServiceWorkerControlleeRequestHandler | 38 class CONTENT_EXPORT ServiceWorkerControlleeRequestHandler |
38 : public ServiceWorkerRequestHandler, | 39 : public ServiceWorkerRequestHandler, |
39 public ServiceWorkerURLRequestJob::Delegate { | 40 public ServiceWorkerURLRequestJob::Delegate { |
40 public: | 41 public: |
41 ServiceWorkerControlleeRequestHandler( | 42 ServiceWorkerControlleeRequestHandler( |
42 base::WeakPtr<ServiceWorkerContextCore> context, | 43 base::WeakPtr<ServiceWorkerContextCore> context, |
43 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 44 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
44 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 45 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
45 FetchRequestMode request_mode, | 46 FetchRequestMode request_mode, |
46 FetchCredentialsMode credentials_mode, | 47 FetchCredentialsMode credentials_mode, |
47 FetchRedirectMode redirect_mode, | 48 FetchRedirectMode redirect_mode, |
48 ResourceType resource_type, | 49 ResourceType resource_type, |
49 RequestContextType request_context_type, | 50 RequestContextType request_context_type, |
50 RequestContextFrameType frame_type, | 51 RequestContextFrameType frame_type, |
51 scoped_refptr<ResourceRequestBodyImpl> body); | 52 scoped_refptr<ResourceRequestBodyImpl> body); |
52 ~ServiceWorkerControlleeRequestHandler() override; | 53 ~ServiceWorkerControlleeRequestHandler() override; |
53 | 54 |
54 // Called via custom URLRequestJobFactory. | 55 // Called via custom URLRequestJobFactory. |
55 net::URLRequestJob* MaybeCreateJob( | 56 net::URLRequestJob* MaybeCreateJob( |
56 net::URLRequest* request, | 57 net::URLRequest* request, |
57 net::NetworkDelegate* network_delegate, | 58 net::NetworkDelegate* network_delegate, |
58 ResourceContext* resource_context) override; | 59 ResourceContext* resource_context) override; |
59 | 60 |
| 61 mojom::URLLoaderFactoryPtrInfo MaybeCreateURLLoader( |
| 62 const ResourceRequest& resource_request, |
| 63 ResourceContext* resource_context, |
| 64 std::unique_ptr<ServiceWorkerRequestHandler> request_handler) override; |
| 65 |
60 private: | 66 private: |
61 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, | 67 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, |
62 ActivateWaitingVersion); | 68 ActivateWaitingVersion); |
63 typedef ServiceWorkerControlleeRequestHandler self; | 69 typedef ServiceWorkerControlleeRequestHandler self; |
64 | 70 |
65 // For main resource case. | 71 // For main resource case. |
66 void PrepareForMainResource(const net::URLRequest* request); | 72 void PrepareForMainResource(const GURL& url, |
| 73 const GURL& first_party_for_cookies); |
67 void DidLookupRegistrationForMainResource( | 74 void DidLookupRegistrationForMainResource( |
68 ServiceWorkerStatusCode status, | 75 ServiceWorkerStatusCode status, |
69 scoped_refptr<ServiceWorkerRegistration> registration); | 76 scoped_refptr<ServiceWorkerRegistration> registration); |
70 void OnVersionStatusChanged( | 77 void OnVersionStatusChanged( |
71 ServiceWorkerRegistration* registration, | 78 ServiceWorkerRegistration* registration, |
72 ServiceWorkerVersion* version); | 79 ServiceWorkerVersion* version); |
73 | 80 |
74 void DidUpdateRegistration( | 81 void DidUpdateRegistration( |
75 const scoped_refptr<ServiceWorkerRegistration>& original_registration, | 82 const scoped_refptr<ServiceWorkerRegistration>& original_registration, |
76 ServiceWorkerStatusCode status, | 83 ServiceWorkerStatusCode status, |
(...skipping 17 matching lines...) Expand all Loading... |
94 bool RequestStillValid( | 101 bool RequestStillValid( |
95 ServiceWorkerMetrics::URLRequestJobResult* result) override; | 102 ServiceWorkerMetrics::URLRequestJobResult* result) override; |
96 void MainResourceLoadFailed() override; | 103 void MainResourceLoadFailed() override; |
97 | 104 |
98 // Sets |job_| to nullptr, and clears all extra response info associated with | 105 // Sets |job_| to nullptr, and clears all extra response info associated with |
99 // that job, except for timing information. | 106 // that job, except for timing information. |
100 void ClearJob(); | 107 void ClearJob(); |
101 | 108 |
102 const bool is_main_resource_load_; | 109 const bool is_main_resource_load_; |
103 const bool is_main_frame_load_; | 110 const bool is_main_frame_load_; |
104 base::WeakPtr<ServiceWorkerURLRequestJob> job_; | 111 std::unique_ptr<JobWrapper> job_; |
105 FetchRequestMode request_mode_; | 112 FetchRequestMode request_mode_; |
106 FetchCredentialsMode credentials_mode_; | 113 FetchCredentialsMode credentials_mode_; |
107 FetchRedirectMode redirect_mode_; | 114 FetchRedirectMode redirect_mode_; |
108 RequestContextType request_context_type_; | 115 RequestContextType request_context_type_; |
109 RequestContextFrameType frame_type_; | 116 RequestContextFrameType frame_type_; |
110 scoped_refptr<ResourceRequestBodyImpl> body_; | 117 scoped_refptr<ResourceRequestBodyImpl> body_; |
111 ResourceContext* resource_context_; | 118 ResourceContext* resource_context_; |
112 GURL stripped_url_; | 119 GURL stripped_url_; |
113 bool force_update_started_; | 120 bool force_update_started_; |
114 | 121 |
115 // True if the next time this request is started, the response should be | 122 // True if the next time this request is started, the response should be |
116 // delivered from the network, bypassing the ServiceWorker. Cleared after the | 123 // delivered from the network, bypassing the ServiceWorker. Cleared after the |
117 // next intercept opportunity, for main frame requests. | 124 // next intercept opportunity, for main frame requests. |
118 bool use_network_; | 125 bool use_network_; |
119 | 126 |
120 base::WeakPtrFactory<ServiceWorkerControlleeRequestHandler> weak_factory_; | 127 base::WeakPtrFactory<ServiceWorkerControlleeRequestHandler> weak_factory_; |
121 | 128 |
122 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerControlleeRequestHandler); | 129 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerControlleeRequestHandler); |
123 }; | 130 }; |
124 | 131 |
125 } // namespace content | 132 } // namespace content |
126 | 133 |
127 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HAND
LER_H_ | 134 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTROLLEE_REQUEST_HAND
LER_H_ |
OLD | NEW |