blob: 14b56e4e7c36080dd1809546f217997eea24f43c [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module content.mojom;
import "content/common/service_worker/service_worker_container.mojom";
import "services/network/public/mojom/url_loader_factory.mojom";
import "services/service_manager/public/mojom/interface_provider.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_object.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_provider_type.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom";
import "third_party/blink/public/platform/modules/cache_storage/cache_storage.mojom";
// The name of the InterfaceProviderSpec in service manifests used by the
// frame tree to expose service-worker-specific interfaces between renderer
// and browser.
const string kNavigation_ServiceWorkerSpec = "navigation:service_worker";
// S13nServiceWorker:
// Sent from the browser process to the renderer. Contains parameteres for the
// constructor of ServiceWorkerNetworkProvider used for starting a shared
// worker.
struct ServiceWorkerProviderInfoForSharedWorker {
int32 provider_id;
associated ServiceWorkerContainerHost host_ptr_info;
associated ServiceWorkerContainer& client_request;
};
// Sent from the browser process to the renderer. Contains parameters for the
// constructor of ServiceWorkerNetworkProvider used for starting a service
// worker.
struct ServiceWorkerProviderInfoForStartWorker {
int32 provider_id;
associated ServiceWorkerContainerHost host_ptr_info;
associated ServiceWorkerContainer& client_request;
// S13nServiceWorker:
// The loader to use for loading the worker's main script and
// importScripts().
associated network.mojom.URLLoaderFactory? script_loader_factory_ptr_info;
// |cache_storage| is an optional optimization so the service worker can use
// the Cache Storage API immediately without using InterfaceProvider. May be
// null for service workers created for update checks, as the optimization
// would be wasteful because these workers usually are aborted after the
// byte-to-byte update check before running.
blink.mojom.CacheStorage? cache_storage;
service_manager.mojom.InterfaceProvider interface_provider;
};
// Sent from the renderer to the browser process. Contains parameters that
// describe a browser-side provider host.
// See also comments in
// content/common/service_worker/service_worker_provider_host_info.h.
struct ServiceWorkerProviderHostInfo {
int32 provider_id;
int32 route_id;
blink.mojom.ServiceWorkerProviderType type;
bool is_parent_frame_secure;
associated ServiceWorkerContainerHost& host_request;
associated ServiceWorkerContainer client_ptr_info;
};
// ServiceWorkerWorkerClient represents a service worker client that is a worker
// (i.e., a shared worker or dedicated worker). We use this interface to let the
// WebWorkerFetchContextImpl in the worker thread know about the change of
// controlling service worker by calling OnControllerChanged() from the
// ServiceWorkerProviderContext in the main thread of the renderer process.
//
// TODO(horo): We should implement ServiceWorkerProvider in the worker thread
// instead of using this interface to support WorkerNavigator.serviceWorker.
interface ServiceWorkerWorkerClient {
// Called when the worker is controlled by a new service worker. This is only
// used to let the worker know that we now have a service worker (while there
// may or may not have been one previously), but not the other way around.
OnControllerChanged(blink.mojom.ControllerServiceWorkerMode mode);
};
// ServiceWorkerWorkerClientRegistry is a mojo interface for hosting and
// registering ServiceWorkerWorkerClients. An instance of this interface is
// implemented by ServiceWorkerProviderContext and lives in the same renderer
// process as the worker clients.
// This interface is useful when one needs to register a new worker client
// for an existing ServiceWorkerProviderContext on non-main thread, i.e. for
// nested workers.
interface ServiceWorkerWorkerClientRegistry {
// Adds a new ServiceWorkerWorkerClient.
RegisterWorkerClient(ServiceWorkerWorkerClient client);
// Clones this host.
CloneWorkerClientRegistry(ServiceWorkerWorkerClientRegistry& host);
};