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 "mojo/public/cpp/bindings/associated_binding.h" |
| 11 #include "third_party/WebKit/public/platform/WebWorkerFetchContext.h" |
| 12 |
| 13 namespace base { |
| 14 class SingleThreadTaskRunner; |
| 15 } // namespace base |
| 16 |
| 17 namespace content { |
| 18 |
| 19 class ResourceDispatcher; |
| 20 |
| 21 class WorkerFetchContextImpl : public blink::WebWorkerFetchContext, |
| 22 public mojom::ServiceWorkerWorkerClient { |
| 23 public: |
| 24 explicit WorkerFetchContextImpl( |
| 25 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info); |
| 26 ~WorkerFetchContextImpl() override; |
| 27 |
| 28 // blink::WebWorkerFetchContext implementation: |
| 29 void InitializeOnWorkerThread(base::SingleThreadTaskRunner*) override; |
| 30 blink::WebURLLoader* CreateURLLoader() override; |
| 31 void WillSendRequest(blink::WebURLRequest&) override; |
| 32 bool IsControlledByServiceWorker() const override; |
| 33 void SetServiceWorkerProviderID(int id) override; |
| 34 void SetIsControlledByServiceWorker(bool flag) override; |
| 35 |
| 36 // mojom::ServiceWorkerWorkerClient implementation: |
| 37 void SetControllerServiceWorker(int64_t controller_version_id) override; |
| 38 |
| 39 private: |
| 40 mojom::WorkerURLLoaderFactoryProviderPtrInfo provider_info_; |
| 41 int service_worker_provider_id_ = kInvalidServiceWorkerProviderId; |
| 42 bool is_controlled_by_service_worker_ = false; |
| 43 |
| 44 // Initialized on the worker thread when InitializeOnWorkerThread() is called. |
| 45 std::unique_ptr<ResourceDispatcher> resource_dispatcher_; |
| 46 std::unique_ptr<mojo::AssociatedBinding<mojom::ServiceWorkerWorkerClient>> |
| 47 binding_; |
| 48 mojom::WorkerURLLoaderFactoryProviderPtr provider_; |
| 49 mojom::URLLoaderFactoryAssociatedPtr url_loader_factory_; |
| 50 |
| 51 // Updated when mojom::ServiceWorkerWorkerClient::SetControllerServiceWorker() |
| 52 // is called from the browser process via mojo IPC. |
| 53 int controller_version_id_ = kInvalidServiceWorkerVersionId; |
| 54 }; |
| 55 |
| 56 } // namespace content |
| 57 |
| 58 #endif // CONTENT_RENDERER_SERVICE_WORKER_WORKER_FETCH_CONTEXT_IMPL_H_ |
OLD | NEW |