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