mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2024-12-01 09:46:09 +03:00
228 lines
9.5 KiB
Plaintext
228 lines
9.5 KiB
Plaintext
// Copyright 2018 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
module blink.mojom;
|
|
|
|
import "components/services/filesystem/public/interfaces/types.mojom";
|
|
import "url/mojom/url.mojom";
|
|
import "mojo/public/mojom/base/file_error.mojom";
|
|
import "mojo/public/mojom/base/file_path.mojom";
|
|
import "mojo/public/mojom/base/file_info.mojom";
|
|
import "mojo/public/mojom/base/time.mojom";
|
|
import "third_party/blink/public/mojom/filesystem/file_writer.mojom";
|
|
|
|
enum FileSystemType {
|
|
kTemporary,
|
|
kPersistent,
|
|
kIsolated,
|
|
kExternal
|
|
};
|
|
|
|
struct FileSystemInfo {
|
|
string name;
|
|
url.mojom.Url root_url;
|
|
FileSystemType mount_type = kTemporary;
|
|
};
|
|
|
|
// Entries as returned by the ChooseEntry method below. Each entry is
|
|
// represented by the ID of the isolated filesystem containing the entry and
|
|
// the name of the file in that filesystem.
|
|
struct FileSystemEntry {
|
|
string file_system_id;
|
|
string base_name;
|
|
};
|
|
|
|
// Interface for renderers to cancel running file system operations. A
|
|
// FileSystemCancellableOperationRequest is passed as a parameter for any
|
|
// operation that can be cancelled.
|
|
interface FileSystemCancellableOperation {
|
|
// Cancels the associated operation. It may not always be possible to cancel
|
|
// an operation, and partial writes are possible. |error_code| indicates if
|
|
// the operation was successfully canceled.
|
|
Cancel() => (mojo_base.mojom.FileError error_code);
|
|
};
|
|
|
|
// Operations that need to repeatedly call a particular callback use this
|
|
// interface. For example, the Write operation needs to call DidWrite
|
|
// repeatedly, and uses a FileSystemOperationListenerPtr passed from the
|
|
// renderer to call it.
|
|
// Note: For operations that only need a callback called once, we can directly
|
|
// use mojo return value callbacks.
|
|
interface FileSystemOperationListener {
|
|
// Called by ReadDirectory when entries have been obtained. |has_more| is
|
|
// false when all the entries are obtained, and indicates that the callback
|
|
// will not be called again.
|
|
ResultsRetrieved(array<filesystem.mojom.DirectoryEntry> entries,
|
|
bool has_more);
|
|
|
|
// Called repeatedly by Write to indicate progress. If |complete| is true,
|
|
// the operation is complete and the callback will not be called again.
|
|
DidWrite(int64 byte_count, bool complete);
|
|
|
|
// Called by all operations that use a listener to indicate an error. No
|
|
// other listener callbacks will be called after this.
|
|
ErrorOccurred(mojo_base.mojom.FileError error_code);
|
|
};
|
|
|
|
// Used by the renderer to notify the browser that it has received a snapshot
|
|
// after calling CreateSnapshotFile. The browser sends an interface ptr along
|
|
// with the result of the CreateSnapshotFile call.
|
|
interface ReceivedSnapshotListener {
|
|
DidReceiveSnapshotFile();
|
|
};
|
|
|
|
// Interface provided by the browser to the renderer to carry out filesystem
|
|
// operations. All [Sync] methods should only be called synchronously on worker
|
|
// threads (and asynchronously otherwise).
|
|
interface FileSystemManager {
|
|
// Opens a new filesystem and returns a name and root path for the requested
|
|
// filesystem and a success error code if the operation succeeds. If the
|
|
// operation fails, |error_code| indicates the reason for failure.
|
|
// TODO(https://crbug.com/873661): Make interface per frame/worker and remove
|
|
// |origin_url|.
|
|
[Sync]
|
|
Open(url.mojom.Url origin_url, blink.mojom.FileSystemType file_system_type) =>
|
|
(string name,
|
|
url.mojom.Url root_url,
|
|
mojo_base.mojom.FileError error_code);
|
|
|
|
// Resolves a filesystem URL and returns the filesystem information and
|
|
// metadata (file path and type) if the operation is successful. |error_code|
|
|
// indicates the reason for failure if the operation fails.
|
|
[Sync]
|
|
ResolveURL(url.mojom.Url filesystem_url) =>
|
|
(FileSystemInfo info,
|
|
mojo_base.mojom.FilePath file_path,
|
|
bool is_directory,
|
|
mojo_base.mojom.FileError error_code);
|
|
|
|
// Moves a file or directory at |src_path| to |dest_path|. Returns
|
|
// |error_code| after completion to indicate if the operation succeeded or
|
|
// failed.
|
|
[Sync]
|
|
Move(url.mojom.Url src_path, url.mojom.Url dest_path) =>
|
|
(mojo_base.mojom.FileError error_code);
|
|
|
|
// Copies a file or directory at |src_path| to |dest_path|. Returns
|
|
// |error_code| after completion to indicate if the operation succeeded or
|
|
// failed.
|
|
[Sync]
|
|
Copy(url.mojom.Url src_path, url.mojom.Url dest_path) =>
|
|
(mojo_base.mojom.FileError error_code);
|
|
|
|
// Deletes a file or directory at the given |path|. To delete recursively, set
|
|
// |recursive| to true. Returns |error_code| after completion to indicate if
|
|
// the operation succeeded or failed.
|
|
[Sync]
|
|
Remove(url.mojom.Url path, bool recursive) =>
|
|
(mojo_base.mojom.FileError error_code);
|
|
|
|
// Retrieves the metadata information of the file or directory at the given
|
|
// |path|. This may not always return the local platform path in remote
|
|
// filesystem cases. Returns valid metadata if the retrieval is successful,
|
|
// and uses |error_code| to indicate if the operation was successful.
|
|
[Sync]
|
|
ReadMetadata(url.mojom.Url path) =>
|
|
(mojo_base.mojom.FileInfo file_info,
|
|
mojo_base.mojom.FileError error_code);
|
|
|
|
// Creates a file or directory at the given |path| (based on |is_directory|).
|
|
// If |exclusive| is true, the operation fails if the |path| already exists.
|
|
// Returns |error_code| after completion to indicate if the operation
|
|
// succeeded or failed.
|
|
[Sync]
|
|
Create(url.mojom.Url path,
|
|
bool exclusive,
|
|
bool is_directory,
|
|
bool recursive) =>
|
|
(mojo_base.mojom.FileError error_code);
|
|
|
|
// Checks if a file exists at the given |path| if |is_directory| is false or
|
|
// checks if a directory exists at the given |path| otherwise. Returns
|
|
// |error_code| to indicate if the file was successfully found or if an error
|
|
// occurred.
|
|
[Sync]
|
|
Exists(url.mojom.Url path, bool is_directory) =>
|
|
(mojo_base.mojom.FileError error_code);
|
|
|
|
// Reads directory entries of a given directory at |path|. Calls
|
|
// ResultsRetrieved on |listener| when results are ready, or ErrorOccurred
|
|
// if the operation fails.
|
|
ReadDirectory(url.mojom.Url path, FileSystemOperationListener listener);
|
|
[Sync]
|
|
ReadDirectorySync(url.mojom.Url path) =>
|
|
(array<filesystem.mojom.DirectoryEntry> entries,
|
|
mojo_base.mojom.FileError error_code);
|
|
|
|
// Write data (indicated by |blob_uuid|) to the given file at |file_path|,
|
|
// at |position|. Calls DidWrite on |listener| to provide progress updates on
|
|
// the write, and |ErrorOccurred| if the operation fails. The operation can
|
|
// also be cancelled using the interface ptr associated with |op_request|.
|
|
Write(url.mojom.Url file_path,
|
|
string blob_uuid,
|
|
int64 position,
|
|
FileSystemCancellableOperation& op_request,
|
|
FileSystemOperationListener listener);
|
|
[Sync]
|
|
WriteSync(url.mojom.Url file_path, string blob_uuid, int64 position) =>
|
|
(int64 byte_count, mojo_base.mojom.FileError error_code);
|
|
|
|
// Changes the file length of the file at |file_path| to the |length|
|
|
// indicated. Returns |error_code| after completion to indicate if the
|
|
// operation succeeded or failed. The operation can also be cancelled using
|
|
// the interface ptr associated with |op_request|.
|
|
Truncate(url.mojom.Url file_path,
|
|
int64 length,
|
|
FileSystemCancellableOperation& op_request) =>
|
|
(mojo_base.mojom.FileError error_code);
|
|
[Sync]
|
|
TruncateSync(url.mojom.Url file_path, int64 length) =>
|
|
(mojo_base.mojom.FileError error_code);
|
|
|
|
TouchFile(url.mojom.Url path,
|
|
mojo_base.mojom.Time last_access_time,
|
|
mojo_base.mojom.Time last_modified_time) =>
|
|
(mojo_base.mojom.FileError error_code);
|
|
|
|
// Creates a snapshot file for a given file specified by |file_path|. Returns
|
|
// the metadata of the created snapshot file, which also includes a local
|
|
// platform path to the snapshot image (|platform_path|).
|
|
//
|
|
// In local filesystem cases the backend may simply return the metadata of the
|
|
// file itself (exactly like ReadMetadata would), while in remote filesystem
|
|
// cases, the backend may download the file into a temporary snapshot file and
|
|
// return the metadata of the temporary file.
|
|
//
|
|
// If |snapshot_listener| is provided, the renderer is expected to call
|
|
// DidReceiveSnapshotFile on the listener (which allows the backend to drop
|
|
// a ref to the temporary snapshot file).
|
|
[Sync]
|
|
CreateSnapshotFile(url.mojom.Url file_path) =>
|
|
(mojo_base.mojom.FileInfo file_info,
|
|
mojo_base.mojom.FilePath platform_path,
|
|
mojo_base.mojom.FileError error_code,
|
|
ReceivedSnapshotListener? snapshot_listener);
|
|
|
|
// Synchronously gets the platform path for the given |file_path|.
|
|
[Sync]
|
|
GetPlatformPath(url.mojom.Url file_path) =>
|
|
(mojo_base.mojom.FilePath platform_path);
|
|
|
|
// Creates a writer for the given file at |file_path|.
|
|
CreateWriter(url.mojom.Url file_path) =>
|
|
(mojo_base.mojom.FileError result,
|
|
blink.mojom.FileWriter? writer);
|
|
|
|
// Prompts the user to select a file from the native filesystem. Returns an
|
|
// error code if something failed, or a list of the selected entries on
|
|
// success.
|
|
// TODO(https://crbug.com/878581): Add more options to this method to support
|
|
// multiple files, directories, "open" vs "save" dialogs, etc.
|
|
// TODO(https://crbug.com/873661): Make interface per frame/worker and remove
|
|
// |render_frame_id|.
|
|
ChooseEntry(int32 render_frame_id) =>
|
|
(mojo_base.mojom.FileError error_code,
|
|
array<FileSystemEntry> entries);
|
|
};
|