chromium/content/browser/indexed_db/indexed_db_internals.mojom

// Copyright 2022 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/privileged/mojom/bucket_client_info.mojom";
import "components/services/storage/privileged/mojom/indexed_db_internals_types.mojom";
import "components/services/storage/public/mojom/buckets/bucket_id.mojom";
import "mojo/public/mojom/base/file_path.mojom";

// IndexedDB metadata for a single partition.
struct IdbPartitionMetadata {
  mojo_base.mojom.FilePath partition_path;
  array<IdbOriginMetadata> origin_list;
};

// This interface defines "chrome://indexeddb-internals" access to the IDB
// backend. Implemented by IndexedDBInternalsUI.
interface IdbInternalsHandler {
  // Returns an array of 'IdbPartitionMetadata's or an error message. Each
  // partition contains an array of 'IdbOriginMetadata's which contain a
  // representation of an IDB database.
  GetAllBucketsAcrossAllStorageKeys()
      => (string? error, array<IdbPartitionMetadata> partitions);

  // Downloads the IDB in a zip file and closes it for the given bucket.
  DownloadBucketData(BucketId bucketId) => (string? error);

  // Closes the IDB for the given bucket.
  ForceClose(BucketId bucketId) => (string? error);

  // Starts a metadata recording session for a given bucket ID.
  // Records metadata over time for all databases on the specified bucket.
  StartMetadataRecording(BucketId bucket_id) => (string? error);

  // Stops metadata recording session. Returns an list of metadata structs for
  // each snapshot taken during the recording session.
  StopMetadataRecording(BucketId bucket_id)
      => (string? error, array<IdbBucketMetadata> metadata);

  // Opens the DevTools window for the client represented by `client_info`.
  // Returns an error if the client is not found.
  InspectClient(BucketClientInfo client_info) => (string? error);
};