| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
| 6 #define CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ | 6 #define CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
| 7 | 7 |
| 8 #include "content/common/service_worker/service_worker_types.h" | 8 #include "content/common/service_worker/service_worker_types.h" |
| 9 #include "content/common/worker_url_loader_factory_provider.mojom.h" | 9 #include "content/common/worker_url_loader_factory_provider.mojom.h" |
| 10 #include "mojo/public/cpp/bindings/associated_binding.h" | 10 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 11 #include "third_party/WebKit/public/platform/WebWorkerFetchContext.h" | 11 #include "third_party/WebKit/public/platform/WebWorkerFetchContext.h" |
| 12 #include "url/gurl.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 class SingleThreadTaskRunner; | 15 class SingleThreadTaskRunner; |
| 15 } // namespace base | 16 } // namespace base |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 | 19 |
| 19 class ResourceDispatcher; | 20 class ResourceDispatcher; |
| 20 | 21 |
| 21 class WorkerFetchContextImpl : public blink::WebWorkerFetchContext, | 22 class WorkerFetchContextImpl : public blink::WebWorkerFetchContext, |
| 22 public mojom::ServiceWorkerWorkerClient { | 23 public mojom::ServiceWorkerWorkerClient { |
| 23 public: | 24 public: |
| 24 explicit WorkerFetchContextImpl( | 25 explicit WorkerFetchContextImpl( |
| 25 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info); | 26 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info); |
| 26 ~WorkerFetchContextImpl() override; | 27 ~WorkerFetchContextImpl() override; |
| 27 | 28 |
| 28 // blink::WebWorkerFetchContext implementation: | 29 // blink::WebWorkerFetchContext implementation: |
| 29 void InitializeOnWorkerThread(base::SingleThreadTaskRunner*) override; | 30 void InitializeOnWorkerThread(base::SingleThreadTaskRunner*) override; |
| 30 std::unique_ptr<blink::WebURLLoader> CreateURLLoader() override; | 31 std::unique_ptr<blink::WebURLLoader> CreateURLLoader() override; |
| 31 void WillSendRequest(blink::WebURLRequest&) override; | 32 void WillSendRequest(blink::WebURLRequest&) override; |
| 32 bool IsControlledByServiceWorker() const override; | 33 bool IsControlledByServiceWorker() const override; |
| 33 void SetDataSaverEnabled(bool) override; | 34 void SetDataSaverEnabled(bool) override; |
| 34 bool IsDataSaverEnabled() const override; | 35 bool IsDataSaverEnabled() const override; |
| 36 blink::WebURL FirstPartyForCookies() const override; |
| 35 | 37 |
| 36 // mojom::ServiceWorkerWorkerClient implementation: | 38 // mojom::ServiceWorkerWorkerClient implementation: |
| 37 void SetControllerServiceWorker(int64_t controller_version_id) override; | 39 void SetControllerServiceWorker(int64_t controller_version_id) override; |
| 38 | 40 |
| 39 // Sets the service worker status of the parent frame. | 41 // Sets the fetch context status of the parent frame. |
| 40 void set_service_worker_provider_id(int id); | 42 void set_service_worker_provider_id(int id); |
| 41 void set_is_controlled_by_service_worker(bool flag); | 43 void set_is_controlled_by_service_worker(bool flag); |
| 44 void set_first_party_for_cookies( |
| 45 const blink::WebURL& first_party_for_cookies); |
| 42 | 46 |
| 43 private: | 47 private: |
| 44 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info_; | 48 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info_; |
| 45 int service_worker_provider_id_ = kInvalidServiceWorkerProviderId; | 49 int service_worker_provider_id_ = kInvalidServiceWorkerProviderId; |
| 46 bool is_controlled_by_service_worker_ = false; | 50 bool is_controlled_by_service_worker_ = false; |
| 47 | 51 |
| 48 // Initialized on the worker thread when InitializeOnWorkerThread() is called. | 52 // Initialized on the worker thread when InitializeOnWorkerThread() is called. |
| 49 std::unique_ptr<ResourceDispatcher> resource_dispatcher_; | 53 std::unique_ptr<ResourceDispatcher> resource_dispatcher_; |
| 50 std::unique_ptr<mojo::AssociatedBinding<mojom::ServiceWorkerWorkerClient>> | 54 std::unique_ptr<mojo::AssociatedBinding<mojom::ServiceWorkerWorkerClient>> |
| 51 binding_; | 55 binding_; |
| 52 mojom::WorkerURLLoaderFactoryProviderPtr provider_; | 56 mojom::WorkerURLLoaderFactoryProviderPtr provider_; |
| 53 mojom::URLLoaderFactoryAssociatedPtr url_loader_factory_; | 57 mojom::URLLoaderFactoryAssociatedPtr url_loader_factory_; |
| 54 | 58 |
| 55 // Updated when mojom::ServiceWorkerWorkerClient::SetControllerServiceWorker() | 59 // Updated when mojom::ServiceWorkerWorkerClient::SetControllerServiceWorker() |
| 56 // is called from the browser process via mojo IPC. | 60 // is called from the browser process via mojo IPC. |
| 57 int controller_version_id_ = kInvalidServiceWorkerVersionId; | 61 int controller_version_id_ = kInvalidServiceWorkerVersionId; |
| 58 | 62 |
| 59 bool is_data_saver_enabled_ = false; | 63 bool is_data_saver_enabled_ = false; |
| 64 GURL first_party_for_cookies_; |
| 60 }; | 65 }; |
| 61 | 66 |
| 62 } // namespace content | 67 } // namespace content |
| 63 | 68 |
| 64 #endif // CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ | 69 #endif // CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
| OLD | NEW |