blob: 79c33930d67a72635c72414dd298ef8f1b98c023 [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 blink.mojom;
import "third_party/blink/public/mojom/message_port/message_port.mojom";
import "third_party/blink/public/mojom/service_worker/service_worker_state.mojom";
import "url/mojom/url.mojom";
const int64 kInvalidServiceWorkerVersionId = -1;
// Describes whether a controller service worker exists and if it has a fetch
// handler.
//
// BEWARE: In non-NetS13nServiceWorker, the renderer often does not know which
// controller service worker a request will go to, as skipWaiting() may occur
// in the browser process at the same time the renderer makes a request.
// Therefore, non-NetS13nServiceWorker should usually treat
// kNoFetchEventHandler and kControlled as the same.
//
// TODO(falken): This should be moved to controller_service_worker.mojom once
// it moves to Blink.
enum ControllerServiceWorkerMode {
// No controller exists.
kNoController,
// The controller exists, but it has no fetch event handler.
kNoFetchEventHandler,
// The controller exists and it has a fetch event handler.
kControlled
};
// Describes a ServiceWorker object:
// https://w3c.github.io/ServiceWorker/#serviceworker-interface
struct ServiceWorkerObjectInfo {
// |version_id| identifies the service worker. It is internal state not
// exposed to the web.
int64 version_id = kInvalidServiceWorkerVersionId;
// ServiceWorker#state
ServiceWorkerState state = ServiceWorkerState.kUnknown;
// ServiceWorker#scriptURL
url.mojom.Url url;
// This object's host in the browser process.
associated ServiceWorkerObjectHost host_ptr_info;
// This object in the renderer process.
associated ServiceWorkerObject& request;
};
// The browser-side host of one ServiceWorker JavaScript object. The renderer
// uses this interface to ask the browser process to do operations needed to
// implement ServiceWorker methods.
interface ServiceWorkerObjectHost {
// Corresponds to ServiceWorker#postMessage().
PostMessageToServiceWorker(TransferableMessage message);
// Tells the browser process to terminate the service worker. Used in layout
// tests to verify behavior when a service worker isn't running. The callback
// is called when the browser process actually observes the termination.
TerminateForTesting() => ();
};
// The renderer-side endpoint for one ServiceWorker JavaScript object. The
// browser uses this interface to talk with the corresponding service worker
// object in the renderer process.
interface ServiceWorkerObject {
// Corresponds to ServiceWorker#state.
StateChanged(ServiceWorkerState state);
};