// 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.
module storage.mojom;
import "third_party/blink/public/mojom/file_system_access/file_system_access_transfer_token.mojom";
import "third_party/blink/public/mojom/storage_key/storage_key.mojom";
// This interface is the primary access point to Chrome's File System Access API
// implementation. This interface lives in the browser process and is used by
// IndexedDB in the storage service to serialize and deserialize Native File
// System handles.
//
// This interface has capabilities that should NOT be accessible to a renderer.
// For example, DeserializeHandle can give access to arbitrary paths on disk.
interface FileSystemAccessContext {
// Serializes a handle represented by `token`. If token is not valid this
// returns an empty array, otherwise this returns a serialization that can
// be stored to disk by for example IndexedDB, and then later read back and
// passed to DeserializeHandle to turn it back into a token.
SerializeHandle(
pending_remote<blink.mojom.FileSystemAccessTransferToken> token)
=> (array<uint8> bits);
// Deserializes a handle. `bits` should be what was returned by
// SerializeHandle earlier. The resulting `token` can be used by renderers for
// `storage_key` to get access to the underlying file or directory.
// If deserialization fails, `token` is not bound, and attempts to use it will
// fail.
DeserializeHandle(
blink.mojom.StorageKey storage_key,
array<uint8> bits,
pending_receiver<blink.mojom.FileSystemAccessTransferToken> token);
// Binds another mojo pipe to `this`.
Clone(pending_receiver<FileSystemAccessContext> receiever);
};