chromium/services/test/echo/public/mojom/echo.mojom

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

module echo.mojom;

import "components/os_crypt/async/common/encryptor.mojom";
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
import "sandbox/policy/mojom/sandbox.mojom";

// Echos its input.
[ServiceSandbox=sandbox.mojom.Sandbox.kService]
interface EchoService {
  // Echos the passed-in string.
  EchoString(string input) => (string echoed_input);

  // Echos the passed-in string into the provided shared memory buffer.
  EchoStringToSharedMemory(
      string input, mojo_base.mojom.UnsafeSharedMemoryRegion region);

  // Causes the service to disconnect itself.
  Quit();

  // Forcibly crashes the service.
  Crash();

  // Delay Load a DLL.
  [EnableIf=is_win]
  DelayLoad();

  // Helper to validate that the right failure happens in some tests.
  enum LoadStatus {
    kSuccess,
    kFailedLoadLibrary,
    kFailedGetProcAddress,
    kFailedCallingDelayLoad,
  };

  // Attempts to load a library by path - kService should prevent this unless it
  // was preloaded into the utility at service startup.
  // `library` is a library path or module name to attempt to load.
  // `call_sec32_delayload` - if true will attempt to call the function
  // `FnCallsDelayloadFn` in the library, which in turn attempts to call a
  // delayloaded function in secur32.dll.
  // `status` indicates where a failure occurred, or kSuccess.
  // `error_code` is the last error, or 0 on success.
  [EnableIf=is_win]
  LoadNativeLibrary(
      mojo_base.mojom.FilePath library, bool call_sec32_delayload)
      => (LoadStatus status, uint32 error_code);

  // Takes an `encryptor` and uses it to decrypt the `input` data. The plaintext
  // is then re-encrypted with the same `encryptor` and returned in `output`, if
  // both operations succeeded, otherwise no value is returned.
  DecryptEncrypt(
      os_crypt_async.mojom.Encryptor encryptor, array<uint8> input)
      => (array<uint8>? output);
};