1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module on_device_internals.mojom;
import "mojo/public/mojom/base/big_buffer.mojom";
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/time.mojom";
import "services/on_device_model/public/mojom/on_device_model.mojom";
import "services/on_device_model/public/mojom/on_device_model_service.mojom";
import "skia/public/mojom/bitmap.mojom";
// Struct containing data to be displayed on on-device-internals page.
struct PageData {
// The state of the foundational model.
BaseModelState base_model;
// Whether each supplementary model is downloaded.
array<SupplementaryModelInfo> supp_models;
// The crash count for the on-device model service.
int32 model_crash_count;
// The maximum crash count for the on-device model
// allowed before the service is disabled.
int32 max_model_crash_count;
// List of feature adaptations for use with on-device model.
array<FeatureAdaptationInfo> feature_adaptations;
// Contains information on device performance.
on_device_model.mojom.DevicePerformanceInfo performance_info;
// Low threshold of VRAM in MiB. All devices with less VRAM than this value
// are considered `kVeryLow` as their `PerformanceClass`.
uint64 min_vram_mb;
};
// Whether the base model is downloaded, installable etc.
struct BaseModelState {
// The state (e.g. "Ready", "NotEligible", "Ready (Overridden)".
string state;
// Installer criteria for the model.
map<string, string> registration_criteria;
// Info about the available model, populated when a model is present
// on disk.
BaseModelInfo? info;
};
// Describes a concrete base model that is available.
struct BaseModelInfo {
// The version of the component containing the base model.
string component_version;
// The file path to the base model.
string file_path;
// The name of the base model.
string name;
// The version of the base model.
string version;
};
// Struct containing name of supplementary model and whether they are ready.
struct SupplementaryModelInfo {
string supp_model_name;
bool is_ready;
};
// Contains relevant information about a feature adaptation.
struct FeatureAdaptationInfo {
// Name of the feature.
string feature_name;
// Enum value of the feature.
int32 feature_key;
// Version of this feature adaptation.
int64 version;
// Whether the feature was recently used.
bool is_recently_used;
};
// Lives in the browser process. A renderer uses this to link itself with
// a page handler.
interface PageHandlerFactory {
// Create a page handler and link it to the UI.
CreatePageHandler(pending_remote<Page> page,
pending_receiver<PageHandler> handler);
};
// Primary interface for the chrome://on-device-internals WebUI. Lives in the
// browser process.
interface PageHandler {
// Binds a new OnDeviceModel interface if possible using model assets loaded
// from within `model_path`.
LoadModel(mojo_base.mojom.FilePath model_path,
on_device_model.mojom.ModelPerformanceHint performance_hint,
pending_receiver<on_device_model.mojom.OnDeviceModel> model) =>
(on_device_model.mojom.LoadModelResult result,
on_device_model.mojom.Capabilities capabilities);
// Returns the performance class based on benchmarks run on the device.
GetDevicePerformanceInfo() =>
(on_device_model.mojom.DevicePerformanceInfo performance_info);
// Returns the status of various on-device models.
GetPageData() => (PageData page_data);
// Overrides the recently used prefs state of the given feature, with
// `is_recently_used`.
SetFeatureRecentlyUsedState(int32 feature_key, bool is_recently_used);
// Decodes a bitmap from an image buffer.
DecodeBitmap(mojo_base.mojom.BigBuffer image_buffer) =>
(skia.mojom.BitmapMappedFromTrustedProcess? bitmap);
// Reset the crash count for the on-device model service.
ResetModelCrashCount();
};
// Renderer-side handler for internals WebUI page to process the updates from
// the service.
interface Page {
// Notifies the page of a log event from the OptimizationGuide service.
OnLogMessageAdded(mojo_base.mojom.Time event_time,
string source_file,
int64 source_line,
string message);
};
|