Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: services/files/file.mojom

Issue 875643004: Prototype of Files service. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: moar comments Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // TODO(vtl): notes to self:
6 // - file offsets, file positions, and file sizes are int64 (though positions
7 // and sizes must always be non-negative)
8 // - buffer size parameters (for read/write) are uint32
9
10 module mojo.files;
11
12 import "services/files/types.mojom";
13
14 // TODO(vtl): Write comments.
15 interface File {
16 Close() => (Error err);
17
18 // Reads (at most) |num_bytes_to_read| from the location specified by
19 // |offset|/|whence|. On success, |bytes_read| is set to the data read.
20 // TODO(vtl): Define/clarify behavior when less than |num_bytes_to_read| bytes
21 // are read.
22 Read(uint32 num_bytes_to_read, int64 offset, Whence whence)
23 => (Error error, array<uint8>? bytes_read);
24
25 // Writes |bytes_to_write| to the location specified by |offset|/|whence|.
26 // TODO(vtl): Clarify behavior when |num_bytes_written| is less than the size
27 // of |bytes_to_write|.
28 Write(array<uint8> bytes_to_write, int64 offset, Whence whence)
29 => (Error error, uint32 num_bytes_written);
30
31 // TODO(vtl): We definitely want 64 bits for |num_bytes_to_read|; but do we
32 // want it to be signed (this is consistent with |size| values, but
33 // inconsistent with 32-bit |num_bytes_to_read| values)? Do we want to have
34 // separate "read to end" versus "tail" (i.e., keep on reading as more data is
35 // appended) modes, and how would those be signalled?
36 ReadToStream(handle<data_pipe_producer> source,
37 int64 offset,
38 Whence whence,
39 int64 num_bytes_to_read) => (Error error);
40 WriteFromStream(handle<data_pipe_consumer> sink, int64 offset, Whence whence)
41 => (Error error);
42
43 // Gets the current file position. On success, |position| is the current
44 // offset (in bytes) from the beginning of the file).
45 Tell() => (Error error, int64 position);
46
47 // Sets the current file position to that specified by |offset|/|whence|. On
48 // success, |position| is the offset (in bytes) from the beginning of the
49 // file.
50 Seek(int64 offset, Whence whence) => (Error error, int64 position);
51
52 // Gets information about this file. On success, |file_information| is
53 // non-null and will contain this information.
54 Stat() => (Error error, FileInformation? file_information);
55
56 // Truncates this file to the size specified by |size| (in bytes).
57 Truncate(int64 size) => (Error error);
58
59 // Updates this file's atime and/or mtime to the time specified by |atime| (or
60 // |mtime|, respectively), which may also indicate "now". If |atime| or
61 // |mtime| is null, then the corresponding time is not modified.
62 Touch(TimespecOrNow? atime, TimespecOrNow? mtime) => (Error error);
63
64 // Creates a new |File| instance, which shares the same "file description".
65 // I.e., the access mode, etc. (as specified to |Directory::OpenFile()| by the
66 // |open_flags| argument) as well as file position.
67 Dup(File& file) => (Error error);
68
69 // TODO(vtl): What are the rules for reopening (w.r.t. changing mode/flags).
70 // E.g., obviously can go from "read-write" to "read", but reverse? (probably
71 // not), can remove "append"? (probably not?). Do we allow "truncate"?
72 Reopen(File& file, uint32 open_flags) => (Error error);
73
74 // TODO(vtl): probably should have access flags (but also exec?); how do these
75 // relate to access mode?
76 AsBuffer() => (Error error, handle<shared_buffer>? buffer);
77
78 // TODO(vtl): Add a "watch"?
79 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698