chromium/third_party/blink/public/mojom/service_worker/service_worker_event_status.mojom

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module blink.mojom;

// TODO(falken): Rename this file to service_worker_status.mojom.

// The result of dispatching an event to a service worker.
enum ServiceWorkerEventStatus {
  // The event dispatch completed successfully.
  COMPLETED,

  // Only for extendable events. A promise passed to waitUntil() or
  // respondWith() was rejected. It may also mean dispatch failed, but the
  // meaning of that depends on the event type. It could possibly mean
  // JavaScript execution was forcibly terminated or an uncaught runtime
  // script error occurred while dispatching. For FetchEvent, it looks
  // like we set REJECTED when the service worker did not provide a
  // response but defaultPrevented() was called, preventing falling back
  // to network.
  REJECTED,

  // The service worker execution context was destroyed while the event was alive.
  ABORTED,

  // The event failed to finish within the time limit.
  TIMEOUT,

  MAX=TIMEOUT
};

// The result of starting a service worker.
//
// Currently these all mean that start succeeded as this enum is only used in
// EmbeddedWorkerInstanceHost.OnStarted() which indicates startup completed.
// The plan is to expand to include error codes too.
//
// These names are taken from the JavaScript spec as referred to by the HTML
// spec for running a script:
// https://html.spec.whatwg.org/multipage/webappapis.html#calling-scripts
enum ServiceWorkerStartStatus {
  // The service worker thread is running and initial JavaScript
  // evaluation completed normally.
  kNormalCompletion,

  // The service worker thread is running but initial JavaScript
  // evaluation completed abruptly, i.e., an uncaught runtime error
  // occurred.
  kAbruptCompletion
};