File: on_device_internals_page.mojom

package info (click to toggle)
chromium 140.0.7339.185-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,193,740 kB
  • sloc: cpp: 35,093,945; ansic: 7,161,670; javascript: 4,199,694; python: 1,441,797; asm: 949,904; xml: 747,515; pascal: 187,748; perl: 88,691; sh: 88,248; objc: 79,953; sql: 52,714; cs: 44,599; fortran: 24,137; makefile: 22,114; tcl: 15,277; php: 13,980; yacc: 9,000; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (132 lines) | stat: -rw-r--r-- 4,864 bytes parent folder | download | duplicates (4)
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
124
125
126
127
128
129
130
131
132
// 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);

  // Binds a new OnDeviceModel interface via the ChromeOS platform service
  // using model assets loaded from within `model_path`.
  LoadPlatformModel(mojo_base.mojom.FilePath model_path,
                    pending_receiver<on_device_model.mojom.OnDeviceModel> model) =>
      (on_device_model.mojom.LoadModelResult result);

  // Returns the performance class based on benchmarks run on the device.
  GetDevicePerformanceInfo() =>
      (on_device_model.mojom.DevicePerformanceInfo performance_info);

  // Returns the path of the default model.
  GetDefaultModelPath() => (mojo_base.mojom.FilePath? model_path);

  // 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);
};