chromium/chromeos/crosapi/mojom/debug_interface.mojom

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module crosapi.mojom;

[Stable, Extensible]
enum PrintTarget {
  [Default] kUnknown = 0,
  kLayer = 1, // ui::Layer
  kView = 2, // views::View
  kWindow = 3, // aura::Window
};

// Implemented by lacros-chrome and called by ash-chrome.
//
// Things to consider when adding features to the interface.
// Consider this a thin wrapper to expose to crosapi what Chrome already
// offers as a debug feature. For example,
// `PrintUiHierarchy(PrintTarget::kLayer)` provides easy access to
// `ui::PrintLayerHierarchy()` which pre-existed this interface.
// As a counter example, a feature which fetches a CompositorFrame in Lacros
// viz process which contributes to some CompositorFrame in Ash, will
// inevitably require lots of additional custom code, which if not maintained
// well, can easily become a technical debt.
// It is not to say that its not forbidden to add such a feature but please
// weight the future cost carefully.
[Stable, Uuid="c559b216-17d8-4b5d-ac06-bc7c10c7a83f"]
interface DebugInterface{
  // Tells lacros-chrome to print `target` hierarches of its windows.
  PrintUiHierarchy@0(PrintTarget target);
};

// Implemented by ash-chrome to register `DebugInterface`.
[Stable, Uuid="1accb814-297f-4087-96a8-268226b59643"]
interface DebugInterfaceRegisterer {
    // A crosapi client can register itself as a debug interface to
    // handle debug related actions.
    RegisterDebugInterface@0(
        pending_remote<DebugInterface> remote);
};