chromium/components/services/storage/public/mojom/local_storage_control.mojom

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

module storage.mojom;

import "components/services/storage/public/mojom/storage_policy_update.mojom";
import "components/services/storage/public/mojom/storage_usage_info.mojom";
import "third_party/blink/public/mojom/dom_storage/storage_area.mojom";
import "third_party/blink/public/mojom/storage_key/storage_key.mojom";

// Controls the state of Local Storage within a partition. This is a privileged
// interface and must not be brokered to untrusted clients.
//
// Currently this is consumed and implemented in the browser process, but the
// implementation will eventually live in the storage service which may run
// out-of-process.
interface LocalStorageControl {
  // Binds a blink.mojom.StorageArea `receiver` for a specific `storage_key`.
  BindStorageArea(blink.mojom.StorageKey storage_key,
                  pending_receiver<blink.mojom.StorageArea> receiver);

  // Retrieves some basic usage information about the Local Storage state.
  GetUsage() => (array<StorageUsageInfo> info);

  // Deletes all Local State state for the given `storage_key`. Responds when
  // the deletion is complete.
  DeleteStorage(blink.mojom.StorageKey storage_key) => ();

  // Ensures that no traces of deleted Local Storage data are left in the
  // backing storage for this `storage_key`. Responds when the cleanup is
  // complete.
  CleanUpStorage() => ();

  // Tells the service to immediately commit any pending operations to disk.
  Flush();

  // Returns true if there is any storage area that has pending, un-committed
  // writes.
  NeedsFlushForTesting() => (bool commits_pending);

  // Purges any in-memory caches to free up as much memory as possible. The
  // next access to the StorageArea will reload data from the backing database.
  PurgeMemory();

  // Applies changes to data retention policy which are relevant at shutdown.
  // See StoragePolicyUpdate.
  ApplyPolicyUpdates(array<StoragePolicyUpdate> policy_updates);

  // Some StorageKeys may be configured to be purged at the end of a session
  // rather than persisted as in the default Local Storage behavior. If this is
  // called, that behavior is overridden and Local Storage data is persisted
  // for all StorageKeys.
  ForceKeepSessionState();
};