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 // Describes the type of a change made to a document. |
| 33 [Extensible] | |
| 34 enum ChangeType { | |
| 35 // Indicates that the child document list of the watched directory was | |
| 36 // changed. Note that a watcher can be installed only on directory for now. | |
| 37 CHANGED = 0, | |
| 38 | |
| 39 // Indicates that the watched document itself was deleted. | |
| 40 // When OnDocumentChanged() is called with this change type, the corresponding | |
| 41 // watcher has been already uninstalled and the host should not call | |
| 42 // RemoveWatcher(). | |
| 43 DELETED = 1, | |
| 44 }; | |
| 45 | |
| 46 | |
| 47 // Next method ID: 1 | |
| 48 interface FileSystemHost { | |
| 49 // Called when a watched document was changed. | |
| 50 // |type| describes the type of change made to the document. If |type| is | |
| 51 // DELETED, the watcher has been already removed and the host should not call | |
| 52 // RemoveWatcher(). | |
| 53 [MinVersion=3] OnDocumentChanged@0(int64 watcher_id, ChangeType type); | |
| 54 }; | |
| 55 | |
| 56 // Next method ID: 8 | |
| 33 interface FileSystemInstance { | 57 interface FileSystemInstance { |
| 34 // Notes about Android Documents Provider: | 58 // Notes about Android Documents Provider: |
| 35 // | 59 // |
| 36 // In Android Storage Access Framework, a document is uniquely identified by | 60 // In Android Storage Access Framework, a document is uniquely identified by |
| 37 // a pair of "authority" and "document ID". | 61 // a pair of "authority" and "document ID". |
| 38 // | 62 // |
| 39 // - An authority specifies a Documents Provider that serves a document. | 63 // - 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 | 64 // It is the origin part of a content:// URI used to access the Documents |
| 41 // Provider via Content Resolver protocol. | 65 // Provider via Content Resolver protocol. |
| 42 // Example: "com.android.providers.media.documents" | 66 // Example: "com.android.providers.media.documents" |
| 43 // - A document ID is an opaque string that specifies a particular document | 67 // - A document ID is an opaque string that specifies a particular document |
| 44 // in a documents provider. Its format varies by providers. | 68 // in a documents provider. Its format varies by providers. |
| 45 // | 69 // |
| 46 // See the following documents for details about Documents Provider: | 70 // See the following documents for details about Documents Provider: |
| 47 // https://developer.android.com/guide/topics/providers/document-provider.html | 71 // https://developer.android.com/guide/topics/providers/document-provider.html |
| 48 // https://developer.android.com/reference/android/provider/DocumentsContract. html | 72 // https://developer.android.com/reference/android/provider/DocumentsContract. html |
| 49 | 73 |
| 74 // Installs a document watcher to watch updates of a document. | |
| 75 // | |
| 76 // Note: Currently, watchers can be installed only on directories, and only | |
| 77 // directory content changes are notified. | |
| 78 // | |
| 79 // On success, a positive unique integer is returned as a watcher ID. | |
| 80 // FileSystemHost.OnDocumentChanged() will be called with the watcher ID | |
| 81 // on directory content changes. | |
| 82 // On failure, -1 is returned. | |
| 83 // | |
| 84 // It is allowed to install multiple watchers to the same directory. In that | |
| 85 // case, different watcher IDs are returned. | |
| 86 [MinVersion=3] AddWatcher@6(string authority, string document_id) => | |
| 87 (int64 watcher_id); | |
| 88 | |
| 50 // Queries child documents of the directory specified by |authority| and | 89 // Queries child documents of the directory specified by |authority| and |
| 51 // |parent_document_id| in Documents Provider. | 90 // |parent_document_id| in Documents Provider. |
| 52 // If such a directory does not exist, null is returned. | 91 // If such a directory does not exist, null is returned. |
| 53 [MinVersion=2] GetChildDocuments@4(string authority, | 92 [MinVersion=2] GetChildDocuments@4(string authority, |
| 54 string parent_document_id) => | 93 string parent_document_id) => |
| 55 (array<Document>? documents); | 94 (array<Document>? documents); |
| 56 | 95 |
| 57 // Queries the document specified by |authority| and |document_id| in | 96 // Queries the document specified by |authority| and |document_id| in |
| 58 // Documents Provider. | 97 // Documents Provider. |
| 59 // If such a document does not exist, null is returned. | 98 // If such a document does not exist, null is returned. |
| 60 [MinVersion=2] GetDocument@3(string authority, string document_id) => | 99 [MinVersion=2] GetDocument@3(string authority, string document_id) => |
| 61 (Document? document); | 100 (Document? document); |
| 62 | 101 |
| 63 // Asks the ContentResolver for the size of the file specified by the URL. | 102 // 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 | 103 // If the file does not exist or the size is unknown (e.g. directories and |
| 65 // streams), -1 is returned. | 104 // streams), -1 is returned. |
| 66 [MinVersion=1] GetFileSize@1(string url) => (int64 size); | 105 [MinVersion=1] GetFileSize@1(string url) => (int64 size); |
| 67 | 106 |
| 107 // Establishes full-duplex communication with the host. | |
| 108 [MinVersion=3] Init@5(FileSystemHost host_ptr); | |
|
dcheng
2017/02/23 19:07:07
Btw, I know this is the pattern in ARC++, but for
| |
| 109 | |
| 68 // Asks the ContentResolver to get a FD to read the file specified by the | 110 // Asks the ContentResolver to get a FD to read the file specified by the |
| 69 // URL. | 111 // URL. |
| 70 [MinVersion=1] OpenFileToRead@2(string url) => (handle? fd); | 112 [MinVersion=1] OpenFileToRead@2(string url) => (handle? fd); |
| 71 | 113 |
| 114 // Uninstalls a document watcher. | |
| 115 // | |
| 116 // It fails if the specified watcher does not exist. Note that a watcher | |
| 117 // can be automatically uninstalled when a watched document is deleted | |
| 118 // (notified by OnDocumentChanged() with |type| = DELETED). | |
| 119 [MinVersion=3] RemoveWatcher@7(int64 watcher_id) => (bool success); | |
| 120 | |
| 72 // Requests MediaProvider to scan specified files. | 121 // Requests MediaProvider to scan specified files. |
| 73 // When the specified file does not exist, the corresponding entry in | 122 // When the specified file does not exist, the corresponding entry in |
| 74 // MediaProvider is removed. | 123 // MediaProvider is removed. |
| 75 RequestMediaScan@0(array<string> paths); | 124 RequestMediaScan@0(array<string> paths); |
| 76 }; | 125 }; |
| OLD | NEW |