// 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/privileged/mojom/bucket_client_info.mojom";
import "components/services/storage/privileged/mojom/indexed_db_client_state_checker.mojom";
import "components/services/storage/privileged/mojom/indexed_db_control_test.mojom";
import "components/services/storage/privileged/mojom/indexed_db_internals_types.mojom";
import "components/services/storage/public/mojom/buckets/bucket_id.mojom";
import "components/services/storage/public/mojom/buckets/bucket_locator.mojom";
import "components/services/storage/public/mojom/storage_policy_update.mojom";
import "components/services/storage/public/mojom/storage_usage_info.mojom";
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/values.mojom";
import "third_party/blink/public/mojom/indexeddb/indexeddb.mojom";
import "third_party/blink/public/mojom/storage_key/storage_key.mojom";
// Recorded in histograms, so append only.
enum ForceCloseReason {
FORCE_CLOSE_DELETE_ORIGIN = 0,
FORCE_CLOSE_BACKING_STORE_FAILURE = 1,
FORCE_CLOSE_INTERNALS_PAGE = 2,
FORCE_CLOSE_COPY_ORIGIN = 3,
// Deprecated: FORCE_SCHEMA_DOWNGRADE_INTERNALS_PAGE = 4,
// Append new values here and update IDBContextForcedCloseReason in
// enums.xml.
};
// Communicates with IndexedDB clients about changes in IndexedDB. These clients
// should live in the browser process as the notifications are dispatched by the
// storage service without filtering by frame.
interface IndexedDBObserver {
// This function is called when the size of the usage for a particular
// `bucket_locator` changes (both in memory and on disk).
OnIndexedDBListChanged(storage.mojom.BucketLocator bucket_locator);
// This function is called when the content of a particular object store
// for a particular `bucket_locator` has been modified.
OnIndexedDBContentChanged(storage.mojom.BucketLocator bucket_locator,
mojo_base.mojom.String16 database_name,
mojo_base.mojom.String16 object_store_name);
};
// Controls the state of IndexedDB 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 IndexedDBControl {
// Binds an IDBFactory for the given bucket. If the bucket locator refers to
// the default bucket, its ID may be invalid.
BindIndexedDB(
storage.mojom.BucketLocator bucket_locator,
storage.mojom.BucketClientInfo client_info,
pending_remote<storage.mojom.IndexedDBClientStateChecker>
client_state_checker_remote,
pending_receiver<blink.mojom.IDBFactory> receiver);
// Forcibly closes all connections to all databases within the bucket.
ForceClose(storage.mojom.BucketId bucket_id, ForceCloseReason reason) => ();
// Called by chrome://indexeddb-internals to download all of the indexeddb
// data for a particular bucket. This creates a zip file at
// `zip_path` using the temporary directory `temp_path` which needs to be
// cleaned up after the user downloads the file.
DownloadBucketData(storage.mojom.BucketId bucket_id)
=> (bool success,
mojo_base.mojom.FilePath temp_path,
mojo_base.mojom.FilePath zip_path);
// Called by chrome://indexeddb-internals to populate its page details. Gets
// all buckets across all origins.
GetAllBucketsDetails()
=> (bool incognito, array<IdbOriginMetadata> details);
// Starts a metadata recording session for a given bucket ID.
// Records metadata over time for all databases on the specified bucket until
// StopMetadataRecording is called.
StartMetadataRecording(storage.mojom.BucketId bucket_id) => ();
// Stops metadata recording session. Returns a list of metadata structs for
// each snapshot taken during the recording session.
StopMetadataRecording(storage.mojom.BucketId bucket_id)
=> (array<IdbBucketMetadata> metadata);
// Disables the exit-time deletion of session-only data, so that internal
// restarts can preserve that data.
SetForceKeepSessionState();
// Adds an observer to be notified about modifications to IndexedDB.
AddObserver(pending_remote<IndexedDBObserver> observer);
// Applies changes to data retention policy which are relevant at shutdown.
// See StoragePolicyUpdate.
ApplyPolicyUpdates(array<StoragePolicyUpdate> policy_updates);
// Binds the testing interface for extra functionality only available in
// tests.
BindTestInterface(pending_receiver<IndexedDBControlTest> receiver);
};