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