blob: fa906d70698ba43aa2e38697ece25b5cfdf7df5e [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.
// https://wicg.github.io/background-fetch/#background-fetch-registration
[
Exposed=(Window,Worker),
RuntimeEnabled=BackgroundFetch,
ActiveScriptWrappable
] interface BackgroundFetchRegistration : EventTarget {
readonly attribute DOMString id;
readonly attribute unsigned long long uploadTotal;
readonly attribute unsigned long long uploaded;
readonly attribute unsigned long long downloadTotal;
readonly attribute unsigned long long downloaded;
readonly attribute BackgroundFetchResult result;
readonly attribute BackgroundFetchFailureReason failureReason;
readonly attribute boolean recordsAvailable;
attribute EventHandler onprogress;
[CallWith=ScriptState, MeasureAs=BackgroundFetchRegistrationAbort] Promise<boolean> abort();
[CallWith=ScriptState, RaisesException, MeasureAs=BackgroundFetchRegistrationMatch] Promise<BackgroundFetchRecord> match(RequestInfo request, optional CacheQueryOptions options);
[CallWith=ScriptState, RaisesException, MeasureAs=BackgroundFetchRegistrationMatchAll] Promise<sequence<BackgroundFetchRecord>> matchAll(optional RequestInfo request, optional CacheQueryOptions options);
};
enum BackgroundFetchResult { "", "success", "failure" };
enum BackgroundFetchFailureReason {
// The background fetch has not completed yet, or was successful.
"",
// The operation was aborted by the user, or abort() was called.
"aborted",
// A response had a not-ok-status.
"bad-status",
// A fetch failed for other reasons, e.g. CORS, MIX, an invalid partial response,
// or a general network failure for a fetch that cannot be retried.
"fetch-error",
// Storage quota was reached during the operation.
"quota-exceeded",
// The provided downloadTotal was exceeded.
"download-total-exceeded"
};