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