// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTAINER_HOST_H_ #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTAINER_HOST_H_ #include <map> #include <memory> #include <vector> #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/types/pass_key.h" #include "content/browser/renderer_host/policy_container_host.h" #include "content/common/content_export.h" #include "mojo/public/cpp/bindings/associated_remote.h" #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/metrics/public/cpp/ukm_source_id.h" #include "third_party/blink/public/common/service_worker/service_worker_status_code.h" #include "third_party/blink/public/common/storage_key/storage_key.h" #include "third_party/blink/public/mojom/service_worker/service_worker_container.mojom.h" #include "third_party/blink/public/mojom/service_worker/service_worker_object.mojom-forward.h" #include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h" namespace content { namespace service_worker_object_host_unittest { class ServiceWorkerObjectHostTest; } class ServiceWorkerClient; class ServiceWorkerContainerHost; class ServiceWorkerContextCore; class ServiceWorkerHost; class ServiceWorkerObjectHost; class ServiceWorkerRegistration; class ServiceWorkerRegistrationObjectHost; class ServiceWorkerVersion; // Manager classes that manages *Host objects associated with a // `ServiceWorkerContainerHost`. These objects are owned by, corresponds 1:1 to, // and have the same lifetime as the `ServiceWorkerContainerHost` object and // thus the `container_host_` pointers are always valid. class CONTENT_EXPORT ServiceWorkerRegistrationObjectManager final { … }; class CONTENT_EXPORT ServiceWorkerObjectManager final { … }; // `ServiceWorkerContainerHost` is the host of a ServiceWorkerContainer in the // renderer process: https://w3c.github.io/ServiceWorker/#serviceworkercontainer // - `ServiceWorkerContainerHostForClient` for a window, dedicated worker, or // shared worker. // - `ServiceWorkerContainerHostForServiceWorker` for a service worker execution // context. // // Most of its functionality helps implement the web-exposed // ServiceWorkerContainer interface (navigator.serviceWorker). The long-term // goal is for it to be the host of ServiceWorkerContainer in the renderer, // although currently only windows support ServiceWorkerContainers (see // https://crbug.com/371690). // // ServiceWorkerContainerHost is also responsible for handling service worker // related things in the execution context where the container lives. For // example, the container host manages service worker (registration) JavaScript // object hosts, delivers messages to/from the service worker, and dispatches // events on the container. class CONTENT_EXPORT ServiceWorkerContainerHost : public blink::mojom::ServiceWorkerContainerHost { … }; // `ServiceWorkerContainerHostForClient` is owned by and corresponds 1:1 to a // `ServiceWorkerClient`. // // `ServiceWorkerContainerHostForClient` is created at the same time as the // corresponding `ServiceWorkerClient` construction. // TODO(https://crbug.com/336154571): Create // `ServiceWorkerContainerHostForClient` once the global scope in the renderer // process is created and ready to receive mojo calls. // // The container host has a Mojo connection to the container in the renderer, // and destruction of the container host happens upon disconnection of the Mojo // pipe. class CONTENT_EXPORT ServiceWorkerContainerHostForClient final : public ServiceWorkerContainerHost { … }; // ServiceWorkerContainerHostForServiceWorker is owned by ServiceWorkerHost, // which in turn is owned by ServiceWorkerVersion. The container host and worker // host are destructed when the service worker is stopped. class CONTENT_EXPORT ServiceWorkerContainerHostForServiceWorker final : public ServiceWorkerContainerHost { … }; } // namespace content #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_CONTAINER_HOST_H_