// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module discards.mojom;
struct SiteDataFeature {
// The cumulative observation time for this feature in seconds, set to 0 once
// this feature has been observed.
int64 observation_duration;
// The time at which this feature has been used (set to 0 if it hasn't been
// used), in seconds since epoch.
int64 use_timestamp;
};
struct SiteDataPerformanceMeasurement {
// A decaying average of the CPU usage measurements. Units: microseconds.
float avg_cpu_usage_us;
// A decaying average of the process footprint measurements. Units: kilobytes.
float avg_footprint_kb;
// A decaying average of the wall-clock load time duration of the tab.
// Units: microseconds.
float avg_load_duration_us;
};
struct SiteDataDatabaseSize {
// The total number of rows in the database, or -1 if the value is not
// available.
int64 num_rows;
// The total size of the database on disk in kilobytes, or -1 if the value
// is not available.
int64 on_disk_size_kb;
};
// The data stored for a given origin, this should mirror the
// SiteDataProto structure in
// performance_manager/persistence/site_data/site_data.proto.
struct SiteDataValue {
// The last time this site has been in the loaded state, in seconds since
// epoch.
uint32 last_loaded;
SiteDataFeature updates_favicon_in_background;
SiteDataFeature updates_title_in_background;
SiteDataFeature uses_audio_in_background;
// Load time performance measurement estimates. This maintains a decaying
// average of the resource usage of a page until shortly after it becomes
// idle.
SiteDataPerformanceMeasurement? load_time_estimates;
};
// Provides the key and miscellaneous in-memory only data pertaining to a
// row that potentially exists in a database.
struct SiteDataEntry {
// The origin associated with this row.
string origin;
// This row is pending flush to disk.
bool is_dirty;
// NULL if the database entry doesn't exist on disk or in memory.
SiteDataValue? value;
};
// Contains information about a specific set of SiteData entries.
struct SiteDataArray {
// Contains the entries requested.
array<SiteDataEntry> db_rows;
};
// Interface for providing information about the site data database. Lives in
// the browser process and is invoked in the renderer process via Javascript
// code running in the chrome://discards WebUI.
interface SiteDataProvider {
// Returns the in-memory entries and the entries for the requested origins.
// Note that any entry may take some time to load from disk, and so there may
// not be any data for a given entry until on the second or subsequent
// requests.
GetSiteDataArray(
array<string> explicitly_requested_origins) =>
(SiteDataArray? result);
// Returns the size of the database in number of rows and kilobytes.
// Note that this may be fairly expensive to acquire, and so shouldn't be
// called frequently.
GetSiteDataDatabaseSize() =>
(SiteDataDatabaseSize? db_size);
};