OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
| 6 #define CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
| 7 |
| 8 #include "content/common/service_worker/service_worker_types.h" |
| 9 #include "content/common/worker_url_loader_factory_provider.mojom.h" |
| 10 #include "ipc/ipc_message.h" |
| 11 #include "mojo/public/cpp/bindings/associated_binding.h" |
| 12 #include "third_party/WebKit/public/platform/WebWorkerFetchContext.h" |
| 13 |
| 14 namespace base { |
| 15 class SingleThreadTaskRunner; |
| 16 } // namespace base |
| 17 |
| 18 namespace blink { |
| 19 class WebURL; |
| 20 class WebWorkerFetchContext; |
| 21 } // namespace blink |
| 22 |
| 23 namespace IPC { |
| 24 class Message; |
| 25 } // namespace IPC |
| 26 |
| 27 namespace content { |
| 28 |
| 29 class ResourceDispatcher; |
| 30 class ThreadSafeSender; |
| 31 |
| 32 class WorkerFetchContextImpl : public blink::WebWorkerFetchContext, |
| 33 public mojom::ServiceWorkerWorkerClient { |
| 34 public: |
| 35 explicit WorkerFetchContextImpl( |
| 36 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info); |
| 37 ~WorkerFetchContextImpl() override; |
| 38 |
| 39 // blink::WebWorkerFetchContext implementation: |
| 40 void InitializeOnWorkerThread(base::SingleThreadTaskRunner*) override; |
| 41 blink::WebURLLoader* CreateURLLoader() override; |
| 42 void WillSendRequest(blink::WebURLRequest&) 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; |
| 50 void SetStrictMixedContentCheckingEnabled(bool enabled) override; |
| 51 |
| 52 // Sets the fetch context status of the parent frame. |
| 53 void SetParentFrameID(int id); |
| 54 void SetServiceWorkerProviderID(int id); |
| 55 void SetIsSecureContext(bool flag); |
| 56 void SetIsControlledByServiceWorker(bool flag); |
| 57 |
| 58 // mojom::ServiceWorkerWorkerClient implementation: |
| 59 void SetControllerServiceWorker(int64_t controller_version_id) override; |
| 60 |
| 61 private: |
| 62 bool Send(IPC::Message* message); |
| 63 |
| 64 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info_; |
| 65 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 66 int appcache_host_id_ = 0; |
| 67 int parent_frame_id_ = MSG_ROUTING_NONE; |
| 68 int service_worker_provider_id_ = kInvalidServiceWorkerProviderId; |
| 69 bool is_secure_context_ = false; |
| 70 bool is_controlled_by_service_worker_ = false; |
| 71 bool data_saver_enabled_ = false; |
| 72 bool strict_mixed_content_checking_enabled_ = false; |
| 73 |
| 74 // Initialized on the worker thread when InitializeOnWorkerThread() is called. |
| 75 std::unique_ptr<ResourceDispatcher> resource_dispatcher_; |
| 76 std::unique_ptr<mojo::AssociatedBinding<mojom::ServiceWorkerWorkerClient>> |
| 77 binding_; |
| 78 mojom::WorkerURLLoaderFactoryProviderPtr provider_; |
| 79 mojom::URLLoaderFactoryAssociatedPtr url_loader_factory_; |
| 80 |
| 81 // Updated when mojom::ServiceWorkerWorkerClient::SetControllerServiceWorker() |
| 82 // is called from the browser process via mojo IPC. |
| 83 int controller_version_id_ = kInvalidServiceWorkerVersionId; |
| 84 }; |
| 85 |
| 86 } // namespace content |
| 87 |
| 88 #endif // CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
OLD | NEW |