blob: 9e6e6e950b5e47afa15d0ac139c2fddebf8d7b94 [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/WebKit/public/platform/modules/serviceworker/navigation_preload_state.mojom";
import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_error_type.mojom";
import "third_party/WebKit/public/platform/modules/serviceworker/service_worker_object.mojom";
import "url/mojo/url.mojom";
const int32 kInvalidServiceWorkerRegistrationHandleId = -1;
const int64 kInvalidServiceWorkerRegistrationId = -1;
// Represents ServiceWorkerUpdateViaCache enum for ServiceWorkerRegistrationOptions:
// https://w3c.github.io/ServiceWorker/#enumdef-serviceworkerupdateviacache
enum ServiceWorkerUpdateViaCache {
kImports,
kAll,
kNone,
};
// Represents options for register():
// https://w3c.github.io/ServiceWorker/#dictdef-registrationoptions
struct ServiceWorkerRegistrationOptions {
url.mojom.Url scope;
// TODO(yuryu): Other values will be added as they are supported later.
};
// Describes a ServiceWorkerRegistration:
// https://w3c.github.io/ServiceWorker/#serviceworkerregistration-interface
struct ServiceWorkerRegistrationObjectInfo {
// The globally unique identifier of a service worker registration entity.
int64 registration_id = kInvalidServiceWorkerRegistrationId;
// The id to differentiate a service worker registration entity against
// multiple JavaScript execution contexts for service worker clients or
// service worker itself, it is also unique globally.
// Blink either mints a new ServiceWorkerRegistration object or reuses an
// existing one based on |handle_id|. This allows ServiceWorkerRegistration
// objects in different execution contexts to be different, even if they
// represent the same registration entity (registration_id is equal). They
// must be different since they should have different prototypes.
int32 handle_id = kInvalidServiceWorkerRegistrationHandleId;
// The registration options attached with this registration object, including
// some information such as scope of this registration.
ServiceWorkerRegistrationOptions options;
// Holds one mojo connection to browser process, acts as a reference count to
// control lifetime of ServiceWorkerRegistration in the browser process.
associated ServiceWorkerRegistrationObjectHost host_ptr_info;
// |request| is expected to be bound on the implementation of interface
// ServiceWorkerRegistrationObject in the renderer process. The other end
// point of this Mojo connection is held by the browser process.
associated ServiceWorkerRegistrationObject&? request;
// Corresponds to ServiceWorkerRegistration#{installing,waiting,active}.
ServiceWorkerObjectInfo installing;
ServiceWorkerObjectInfo waiting;
ServiceWorkerObjectInfo active;
};
// This interface lives in the browser process, it corresponds to one
// ServiceWorkerRegistration JavaScript object. The renderer uses it to ask the
// browser to do operations needed to implement ServiceWorkerRegistration
// methods.
interface ServiceWorkerRegistrationObjectHost {
// Corresponds to ServiceWorkerRegistration#update().
// On success, |error| is kNone without |error_msg| set.
// Otherwise, |error| and |error_msg| describe the failure.
Update() => (ServiceWorkerErrorType error, string? error_msg);
// Corresponds to ServiceWorkerRegistration#unregister().
// On success, |error| is kNone without |error_msg| set.
// Otherwise, |error| and |error_msg| describe the failure.
Unregister() => (ServiceWorkerErrorType error, string? error_msg);
// Corresponds to NavigationPreloadManager#enable()/disable().
// On success, |error| is kNone without |error_msg| set.
// Otherwise, |error| and |error_msg| describe the failure.
EnableNavigationPreload(bool enable)
=> (ServiceWorkerErrorType error, string? error_msg);
// Corresponds to NavigationPreloadManager#getState().
// On success, |error| is kNone with |state| set.
// Otherwise, |error| and |error_msg| describe the failure.
GetNavigationPreloadState()
=> (ServiceWorkerErrorType error,
string? error_msg,
blink.mojom.NavigationPreloadState? state);
// Corresponds to NavigationPreloadManager#setHeaderValue().
// On success, |error| is kNone without |error_msg| set.
// Otherwise, |error| and |error_msg| describe the failure.
SetNavigationPreloadHeader(string value)
=> (ServiceWorkerErrorType error, string? error_msg);
};
// This interface lives in the renderer process, it corresponds to one
// ServiceWorkerRegistration JavaScript object. The browser uses it to talk with
// the corresponding impl of ServiceWorkerRegistration in the renderer.
interface ServiceWorkerRegistrationObject {
// Sets changed service worker objects for this registration object.
// |changed_mask| indicates which objects of {|installing|,|waiting|,|active|}
// have changed. See ChangedVersionAttributesMask in service_worker_types.h
// for details.
// Changed objects always have non-null value, which may be invalid value
// describing that the object does not exist any more.
// Unchanged ones always have null value.
// TODO(leonhsl): Use mojofied ChangedVersionAttributesMask directly instead
// of an int32 for |changed_mask|.
SetVersionAttributes(int32 changed_mask,
ServiceWorkerObjectInfo? installing,
ServiceWorkerObjectInfo? waiting,
ServiceWorkerObjectInfo? active);
// Corresponds to ServiceWorkerRegistration#onupdatefound.
UpdateFound();
};