chromium/chromeos/components/cdm_factory_daemon/mojom/cdm_storage.mojom

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

// Next MinVersion: 1

module chromeos.cdm.mojom;

// Provides a interface for per-origin/cdm storage handled by Chrome. This is
// meant to translate to the media/mojo/mojom/cdm_storage.mojom interface that
// is in Chrome but is tied more closely to the Widevine CE CDM IStorage
// interface on this end. This one exists for the purpose of being able to do
// version management so we can handle version diffs between Chrome and
// Chrome OS.
// Next Method ID: 5
[Stable, Uuid="aaecebab-df8e-4047-a6ff-87fd251bf8c6"]
interface CdmStorage {
  // Reads the contents of |file_name| and return them in |data|. Returns
  // true and the file contents if successful. Errors reading the file or
  // non-existent files will return false and an empty data array.
  [Sync]
  Read@0(string file_name) => (bool success, array<uint8> data);

  // Creates/overwrites the contents of |file_name| with |data|. If the
  // write operation is successful, then true is returned, otherwise false is
  // returned. The contents of the file are unknown if Write() fails.
  [Sync]
  Write@1(string file_name, array<uint8> data) => (bool success);

  // Determines whether the specified file name exists or not. Returns true
  // if the file exists and false if it does not or an error occurred.
  [Sync]
  Exists@2(string file_name) => (bool success);

  // Gets the file size of the specified file name. Returned size is valid if
  // status is true.
  [Sync]
  GetSize@3(string file_name) => (bool success, uint64 size);

  // Removes the file at the specified path. Returns true if the file does not
  // exist or it exists and was removed; returns false otherwise.
  [Sync]
  Remove@4(string file_name) => (bool success);
};