chromium/storage/browser/quota/quota_internals.mojom

// Copyright 2021 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 "mojo/public/mojom/base/time.mojom";
import "url/mojom/origin.mojom";
import "third_party/blink/public/mojom/quota/quota_types.mojom";

// Represents a single Storage Bucket entry.
struct BucketTableEntry {
    int64 bucket_id;
    string storage_key;
    blink.mojom.StorageType type;
    string name;
    int64 usage = -1;
    int64 use_count;
    mojo_base.mojom.Time last_accessed;
    mojo_base.mojom.Time last_modified;
};

// Interface for controlling Quota Internals.
// Hosted on "chrome://quota-internals" for WebUI content::QuotaInternalsUI.
interface QuotaInternalsHandler {
    // Returns the total disk space, available disk space,
    // and temporary pool size, which is then converted to bytes
    // and displayed on the Quota Internals UI.
    GetDiskAvailabilityAndTempPoolSize() =>
        (int64 total_space, int64 available_space, int64 temp_pool_size);

    // Returns the following statistics:
    // Errors on Getting Usage and Quota, Evicted Buckets, Evicted Rounds
    // and Skipped Eviction Rounds.
    GetStatistics() => (map<string, string> eviction_statistics);

    // Used by the quota-internals page to test behavior of the storage pressure
    // callback and trigger a storage pressure notification.
    SimulateStoragePressure(url.mojom.Origin origin_url);

    // Returns an array of Storage Bucket entries stored in the QuotaDatabase.
    RetrieveBucketsTable() => (array<BucketTableEntry> entries);

    // Returns the global usage and unlimited usage for a given storage type.
    GetGlobalUsageForInternals(blink.mojom.StorageType storage_type) =>
        (int64 usage, int64 unlimited_usage);

    // Returns whether simulate storage pressure is available.
    IsSimulateStoragePressureAvailable() => (bool available);
};