File: on_device_internals_page.mojom

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (102 lines) | stat: -rw-r--r-- 3,542 bytes parent folder | download | duplicates (2)
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
// 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;
};

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

// 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.
  GetEstimatedPerformanceClass() =>
      (on_device_model.mojom.PerformanceClass performance_class);

  // Returns the status of various on-device models.
  GetPageData() => (PageData page_data);

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