// 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://github.com/WICG/async-cookies-api/blob/gh-pages/explainer.md

[
  Exposed=(ServiceWorker,Window),
  RuntimeEnabled=AsyncCookies
] interface CookieStore {
  // https://github.com/WICG/async-cookies-api/blob/gh-pages/explainer.md#reading
  [CallWith=ScriptState, RaisesException] Promise<CookieList?> getAll(
      USVString name, optional CookieStoreGetOptions options);
  [CallWith=ScriptState, RaisesException] Promise<CookieList?> getAll(
      optional CookieStoreGetOptions options);
  [CallWith=ScriptState, RaisesException] Promise<CookieListItem?> get(
      USVString name, optional CookieStoreGetOptions options);
  [CallWith=ScriptState, RaisesException] Promise<CookieListItem?> get(
      optional CookieStoreGetOptions options);
  [CallWith=ScriptState, RaisesException] Promise<boolean> has(
      USVString name, optional CookieStoreGetOptions options);
  [CallWith=ScriptState, RaisesException] Promise<boolean> has(
      optional CookieStoreGetOptions options);

  // https://github.com/WICG/async-cookies-api/blob/gh-pages/explainer.md#writing
  [CallWith=ScriptState, RaisesException] Promise<void> set(
      USVString name, USVString value, optional CookieStoreSetOptions options);
  [CallWith=ScriptState, RaisesException] Promise<void> set(
      CookieStoreSetOptions options);

  [CallWith=ScriptState, ImplementedAs=Delete, RaisesException] Promise<void> delete(
      USVString name, optional CookieStoreSetOptions options);
  [CallWith=ScriptState, ImplementedAs=Delete, RaisesException] Promise<void> delete(
      CookieStoreSetOptions options);
};
