// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_PERFORMANCE_MANAGER_SERVICE_WORKER_CONTEXT_ADAPTER_H_ #define COMPONENTS_PERFORMANCE_MANAGER_SERVICE_WORKER_CONTEXT_ADAPTER_H_ #include <memory> #include <string> #include "base/check_op.h" #include "base/containers/flat_map.h" #include "base/containers/flat_set.h" #include "base/observer_list.h" #include "base/scoped_observation.h" #include "content/public/browser/service_worker_context.h" #include "content/public/browser/service_worker_context_observer.h" namespace content { class RenderProcessHost; } namespace performance_manager { // Interface that makes testing easier. The only practical implementaion is the // class below. class ServiceWorkerContextAdapter { … }; // This class adapts an existing ServiceWorkerContext to ensure that the // OnVersionStoppedRunning() notifications are sent as soon as the render // process of a running service worker exits. // // It observes the underlying context so that it can receive the original // notifications and control when they are sent to the observers. // // Lives on the UI thread. Must outlive |underlying_context|. // // Note: This is a temporary class that can be removed when the representation // of a worker in the content/ layer (ServiceWorkerVersion) is moved to // the UI thread. At that point, it'll be able to observe its associated // RenderProcessHost itself. See https://crbug.com/824858. class ServiceWorkerContextAdapterImpl : public ServiceWorkerContextAdapter, public content::ServiceWorkerContextObserver { … }; } // namespace performance_manager #endif // COMPONENTS_PERFORMANCE_MANAGER_SERVICE_WORKER_CONTEXT_ADAPTER_H_