blob: 2a608c1d0732774febf00617595ec15b9f18a062 [file] [log] [blame]
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module extensions.mojom;
import "mojo/public/mojom/base/unguessable_token.mojom";
import "extensions/common/mojom/frame.mojom";
import "url/mojom/url.mojom";
// An interface for an extension service worker context. Implemented in the
// browser process.
interface ServiceWorkerHost {
// Tells the browser that an extension service worker context was initialized,
// but possibly didn't start executing its top-level JavaScript.
DidInitializeServiceWorkerContext(string extension_id,
int64 service_worker_version_id,
int32 worker_thread_id);
// Tells the browser that an extension service worker context has started and
// finished executing its top-level JavaScript.
// Start corresponds to EmbeddedWorkerInstance::OnStarted notification.
//
// TODO(crbug.com/1422440): This is a workaround: ideally this IPC should be
// redundant because it directly corresponds to
// EmbeddedWorkerInstance::OnStarted message. However, because OnStarted
// message is on different mojo IPC pipe, and most extension IPCs are on
// legacy IPC pipe, this IPC is necessary to ensure FIFO ordering of this
// message with rest of the extension IPCs.
// Two possible solutions to this:
// - Associate extension IPCs with Service Worker IPCs. This can be done
// (and will be a requirement) when extension IPCs are moved to mojo, but
// requires resolving or defining ordering dependencies amongst the
// extension messages, and any additional messages in Chrome.
// - Make Service Worker IPCs channel-associated so that there's FIFO
// guarantee between extension IPCs and Service Worker IPCs. This isn't
// straightforward as it changes SW IPC ordering with respect of rest of
// Chrome.
// See https://crbug.com/879015#c4 for details.
DidStartServiceWorkerContext(
string extension_id,
mojo_base.mojom.UnguessableToken activation_token,
url.mojom.Url service_worker_scope,
int64 service_worker_version_id,
int32 worker_thread_id);
// Tells the browser that an extension service worker context has been
// destroyed.
DidStopServiceWorkerContext(
string extension_id,
mojo_base.mojom.UnguessableToken activation_token,
url.mojom.Url service_worker_scope,
int64 service_worker_version_id,
int32 worker_thread_id);
// Asks the browser to increment the pending activity count for
// the worker with version id `service_worker_version_id`.
// Each request to increment must use unique `request_uuid`. If a request with
// `request_uuid` is already in progress (due to race condition or renderer
// compromise), browser process ignores the IPC.
// TODO(crbug.com/1423190): Investigate simpifying this message because the
// browser process should already know that a request is active or not.
IncrementServiceWorkerActivity(int64 service_worker_version_id,
string request_uuid);
// Asks the browser to decrement the pending activity count for
// the worker with version id `service_worker_version_id`.
// `request_uuid` must match the GUID of a previous request, otherwise the
// browser process ignores the IPC.
// TODO(crbug.com/1423190): Investigate simpifying this message because the
// browser process should already know that a request is active or not.
DecrementServiceWorkerActivity(int64 service_worker_version_id,
string request_uuid);
// A service worker thread sends this message when an extension service worker
// starts an API request. We use [UnlimitedSize] here because `params` may be
// large with some extension function (ex. Storage API).
[UnlimitedSize]
RequestWorker(RequestParams params);
// Optional Ack message sent to the browser to notify that the response to a
// function has been processed.
WorkerResponseAck(int32 request_id, int64 service_worker_version_id);
};