Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Next MinVersion: 3 | 5 // Next MinVersion: 4 |
| 6 | 6 |
| 7 module arc.mojom; | 7 module arc.mojom; |
| 8 | 8 |
| 9 // Represents a document in Android DocumentsProvider. | 9 // Represents a document in Android DocumentsProvider. |
| 10 // See Android docs of DocumentsContract.Document for details. | 10 // See Android docs of DocumentsContract.Document for details. |
| 11 struct Document { | 11 struct Document { |
| 12 // Opaque ID of the document. | 12 // Opaque ID of the document. |
| 13 string document_id; | 13 string document_id; |
| 14 | 14 |
| 15 // Display name of the document. | 15 // Display name of the document. |
| 16 string display_name; | 16 string display_name; |
| 17 | 17 |
| 18 // MIME type of the document. | 18 // MIME type of the document. |
| 19 // A directory is represented by a document having MIME_TYPE_DIR MIME type. | 19 // A directory is represented by a document having MIME_TYPE_DIR MIME type. |
| 20 string mime_type; | 20 string mime_type; |
| 21 | 21 |
| 22 // Size of the document in bytes. If the size is unknown, -1 is set. | 22 // Size of the document in bytes. If the size is unknown, -1 is set. |
| 23 int64 size; | 23 int64 size; |
| 24 | 24 |
| 25 // Timestamp when the document was modified last time, in milliseconds | 25 // Timestamp when the document was modified last time, in milliseconds |
| 26 // since UNIX epoch. | 26 // since UNIX epoch. |
| 27 // TODO(crbug.com/672737): Use mojo.common.mojom.Time once the type is | 27 // TODO(crbug.com/672737): Use mojo.common.mojom.Time once the type is |
| 28 // converted to a non-native type so that it can be used from Java. | 28 // converted to a non-native type so that it can be used from Java. |
| 29 uint64 last_modified; | 29 uint64 last_modified; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 // Next method ID: 5 | 32 // Next method ID: 1 |
| 33 interface FileSystemHost { | |
| 34 // Called when a watched document was changed or deleted. | |
| 35 // If |deleted| is true, the watcher has been already removed and the host | |
| 36 // does not need to explicitly call RemoveWatcher(). | |
| 37 [MinVersion=3] OnDocumentChanged@0(int64 watcher_id, bool deleted); | |
|
Luis Héctor Chávez
2017/02/22 17:29:31
I'd prefer to replace |bool deleted| with an enum
Shuhei Takahashi
2017/02/23 03:37:22
Sure, let's use enum instead.
We are not going to
| |
| 38 }; | |
| 39 | |
| 40 // Next method ID: 8 | |
| 33 interface FileSystemInstance { | 41 interface FileSystemInstance { |
| 34 // Notes about Android Documents Provider: | 42 // Notes about Android Documents Provider: |
| 35 // | 43 // |
| 36 // In Android Storage Access Framework, a document is uniquely identified by | 44 // In Android Storage Access Framework, a document is uniquely identified by |
| 37 // a pair of "authority" and "document ID". | 45 // a pair of "authority" and "document ID". |
| 38 // | 46 // |
| 39 // - An authority specifies a Documents Provider that serves a document. | 47 // - An authority specifies a Documents Provider that serves a document. |
| 40 // It is the origin part of a content:// URI used to access the Documents | 48 // It is the origin part of a content:// URI used to access the Documents |
| 41 // Provider via Content Resolver protocol. | 49 // Provider via Content Resolver protocol. |
| 42 // Example: "com.android.providers.media.documents" | 50 // Example: "com.android.providers.media.documents" |
| 43 // - A document ID is an opaque string that specifies a particular document | 51 // - A document ID is an opaque string that specifies a particular document |
| 44 // in a documents provider. Its format varies by providers. | 52 // in a documents provider. Its format varies by providers. |
| 45 // | 53 // |
| 46 // See the following documents for details about Documents Provider: | 54 // See the following documents for details about Documents Provider: |
| 47 // https://developer.android.com/guide/topics/providers/document-provider.html | 55 // https://developer.android.com/guide/topics/providers/document-provider.html |
| 48 // https://developer.android.com/reference/android/provider/DocumentsContract. html | 56 // https://developer.android.com/reference/android/provider/DocumentsContract. html |
| 49 | 57 |
| 58 // Installs a document watcher to watch updates of a document. | |
| 59 // | |
| 60 // On success, a positive unique integer is returned as a watcher ID and | |
| 61 // FileSystemHost.OnDocumentChanged() will be called with the watcher ID | |
| 62 // on document changes until the watcher is removed by RemoveWatcher(). | |
| 63 // On failure, -1 is returned. | |
| 64 // | |
| 65 // It is allowed to install multiple watchers to the same document. In that | |
| 66 // case, different watcher IDs are returned. | |
| 67 [MinVersion=3] AddWatcher@6(string authority, string document_id) => | |
| 68 (int64 watcher_id); | |
| 69 | |
| 50 // Queries child documents of the directory specified by |authority| and | 70 // Queries child documents of the directory specified by |authority| and |
| 51 // |parent_document_id| in Documents Provider. | 71 // |parent_document_id| in Documents Provider. |
| 52 // If such a directory does not exist, null is returned. | 72 // If such a directory does not exist, null is returned. |
| 53 [MinVersion=2] GetChildDocuments@4(string authority, | 73 [MinVersion=2] GetChildDocuments@4(string authority, |
| 54 string parent_document_id) => | 74 string parent_document_id) => |
| 55 (array<Document>? documents); | 75 (array<Document>? documents); |
| 56 | 76 |
| 57 // Queries the document specified by |authority| and |document_id| in | 77 // Queries the document specified by |authority| and |document_id| in |
| 58 // Documents Provider. | 78 // Documents Provider. |
| 59 // If such a document does not exist, null is returned. | 79 // If such a document does not exist, null is returned. |
| 60 [MinVersion=2] GetDocument@3(string authority, string document_id) => | 80 [MinVersion=2] GetDocument@3(string authority, string document_id) => |
| 61 (Document? document); | 81 (Document? document); |
| 62 | 82 |
| 63 // Asks the ContentResolver for the size of the file specified by the URL. | 83 // Asks the ContentResolver for the size of the file specified by the URL. |
| 64 // If the file does not exist or the size is unknown (e.g. directories and | 84 // If the file does not exist or the size is unknown (e.g. directories and |
| 65 // streams), -1 is returned. | 85 // streams), -1 is returned. |
| 66 [MinVersion=1] GetFileSize@1(string url) => (int64 size); | 86 [MinVersion=1] GetFileSize@1(string url) => (int64 size); |
| 67 | 87 |
| 88 // Establishes full-duplex communication with the host. | |
| 89 [MinVersion=3] Init@5(FileSystemHost host_ptr); | |
| 90 | |
| 68 // Asks the ContentResolver to get a FD to read the file specified by the | 91 // Asks the ContentResolver to get a FD to read the file specified by the |
| 69 // URL. | 92 // URL. |
| 70 [MinVersion=1] OpenFileToRead@2(string url) => (handle? fd); | 93 [MinVersion=1] OpenFileToRead@2(string url) => (handle? fd); |
| 71 | 94 |
| 95 // Uninstalls a document watcher. | |
|
Luis Héctor Chávez
2017/02/22 17:29:31
Please document the semantics of uninstalling a do
Shuhei Takahashi
2017/02/23 03:37:22
I changed the comment of OnDocumentChanged():
B
| |
| 96 [MinVersion=3] RemoveWatcher@7(int64 watcher_id) => (bool success); | |
| 97 | |
| 72 // Requests MediaProvider to scan specified files. | 98 // Requests MediaProvider to scan specified files. |
| 73 // When the specified file does not exist, the corresponding entry in | 99 // When the specified file does not exist, the corresponding entry in |
| 74 // MediaProvider is removed. | 100 // MediaProvider is removed. |
| 75 RequestMediaScan@0(array<string> paths); | 101 RequestMediaScan@0(array<string> paths); |
| 76 }; | 102 }; |
| OLD | NEW |