OLD | NEW |
(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 |
| 6 /** |
| 7 * This file defines the <code>PPB_FilesystemProvider</code> interface. |
| 8 */ |
| 9 |
| 10 label Chrome { |
| 11 M40 = 0.1 |
| 12 }; |
| 13 enum PP_OperationType_Dev{ |
| 14 PP_OperationType_NONE, |
| 15 PP_OperationType_UNMOUNT, |
| 16 PP_OperationType_GETMETADATA, |
| 17 PP_OperationType_READDIRECTORY, |
| 18 PP_OperationType_OPENFILE, |
| 19 PP_OperationType_CLOSEFILE, |
| 20 PP_OperationType_READFILE, |
| 21 PP_OperationType_CREATEDIRECTORY, |
| 22 PP_OperationType_DELETEENTRY, |
| 23 PP_OperationType_CREATEFILE, |
| 24 PP_OperationType_COPYENTRY, |
| 25 PP_OperationType_MOVEENTRY, |
| 26 PP_OperationType_TRUNCATEENTRY, |
| 27 PP_OperationType_WRITEFILE, |
| 28 PP_OperationType_ABORT, |
| 29 PP_OperationType_ADDWATCHER, |
| 30 PP_OperationType_REMOVEWATCHER |
| 31 }; |
| 32 |
| 33 enum PP_OpenFileMode_Dev { |
| 34 PP_OpenFileMode_READ, |
| 35 PP_OpenFileMode_WRITE, |
| 36 PP_OpenFileMode_NONE |
| 37 }; |
| 38 |
| 39 enum PP_ChangeType_Dev { |
| 40 PP_ChangeType_CHANGED, |
| 41 PP_ChangeType_DELETED |
| 42 }; |
| 43 |
| 44 struct PP_FilesystemRequestUnmount{ |
| 45 }; |
| 46 |
| 47 struct PP_FilesystemRequestMetadata{ |
| 48 cstr_t entry_path; |
| 49 PP_Bool thumbnail; |
| 50 }; |
| 51 |
| 52 struct PP_FilesystemRequestReadDirectory{ |
| 53 cstr_t directory_path; |
| 54 }; |
| 55 |
| 56 struct PP_FilesystemRequestOpenFile{ |
| 57 cstr_t file_path; |
| 58 PP_OpenFileMode_Dev mode; |
| 59 }; |
| 60 |
| 61 struct PP_FilesystemRequestCloseFile{ |
| 62 int32_t open_request_id; |
| 63 }; |
| 64 |
| 65 struct PP_FilesystemRequestReadFile{ |
| 66 int32_t open_request_id; |
| 67 uint64_t offset; |
| 68 uint64_t length; |
| 69 }; |
| 70 |
| 71 struct PP_FilesystemRequestCreateDirectory{ |
| 72 cstr_t directory_path; |
| 73 PP_Bool recursive; |
| 74 }; |
| 75 |
| 76 struct PP_FilesystemRequestDeleteEntry{ |
| 77 cstr_t entry_path; |
| 78 PP_Bool recursive; |
| 79 }; |
| 80 |
| 81 struct PP_FilesystemRequestCreateFile{ |
| 82 cstr_t file_path; |
| 83 }; |
| 84 |
| 85 struct PP_FilesystemRequestCopyEntry{ |
| 86 cstr_t source_path; |
| 87 cstr_t target_path; |
| 88 }; |
| 89 |
| 90 struct PP_FilesystemRequestMoveEntry{ |
| 91 cstr_t source_path; |
| 92 cstr_t target_path; |
| 93 }; |
| 94 |
| 95 struct PP_FilesystemRequestTruncate{ |
| 96 cstr_t file_path; |
| 97 int32_t length; |
| 98 }; |
| 99 |
| 100 struct PP_FilesystemRequestWrite{ |
| 101 int32_t open_request_id; |
| 102 uint64_t offset; |
| 103 uint64_t data_size; |
| 104 mem_t data; |
| 105 }; |
| 106 |
| 107 struct PP_FilesystemRequestAbort{ |
| 108 int32_t operation_request_id; |
| 109 }; |
| 110 |
| 111 struct PP_FilesystemRequestAddWatcher{ |
| 112 cstr_t entry_path; |
| 113 PP_Bool recursive; |
| 114 }; |
| 115 |
| 116 struct PP_FilesystemRequestRemoveWatcher{ |
| 117 cstr_t entry_path; |
| 118 PP_Bool recursive; |
| 119 }; |
| 120 /** |
| 121 * The request format |
| 122 */ |
| 123 [union] struct PP_FilesystemRequestValue { |
| 124 PP_FilesystemRequestUnmount as_unmount; |
| 125 PP_FilesystemRequestMetadata as_metadata; |
| 126 PP_FilesystemRequestReadDirectory as_read_directory; |
| 127 PP_FilesystemRequestOpenFile as_open_file; |
| 128 PP_FilesystemRequestCloseFile as_close_file; |
| 129 PP_FilesystemRequestReadFile as_read_file; |
| 130 PP_FilesystemRequestCreateDirectory as_create_directory; |
| 131 PP_FilesystemRequestDeleteEntry as_delete_entry; |
| 132 PP_FilesystemRequestCreateFile as_create_file; |
| 133 PP_FilesystemRequestCopyEntry as_copy_entry; |
| 134 PP_FilesystemRequestMoveEntry as_move_entry; |
| 135 PP_FilesystemRequestTruncate as_truncate; |
| 136 PP_FilesystemRequestWrite as_write_file; |
| 137 PP_FilesystemRequestAbort as_abort; |
| 138 PP_FilesystemRequestAddWatcher as_add_watcher; |
| 139 PP_FilesystemRequestRemoveWatcher as_remove_watcher; |
| 140 }; |
| 141 |
| 142 struct PP_FilesystemRequest{ |
| 143 PP_OperationType_Dev operation_type; |
| 144 int32_t request_id; |
| 145 PP_FilesystemRequestValue value; |
| 146 }; |
| 147 /** |
| 148 * File system provider interface. |
| 149 * Typical usage: |
| 150 * - Use Create() to create a new <code>PPB_FilesystemProvider_Dev resource |
| 151 * - Call Mount() to register the new filesystem with the browser |
| 152 * This will create an entry in the file manager Chrome OS UI. The user |
| 153 * can select among the listed filesystem and issue file system operations |
| 154 * - Call Unmount() to unregister the filesystem |
| 155 * This will remove the entry from the file manager Chrome OS UI. |
| 156 * - Register callback for the <code>PP_FilesystemRequest</code> messages that |
| 157 * are sent from the browser with <code>GetNextRequest</code> |
| 158 * - When a request is received and the processing results in a succcess: |
| 159 * - call <code>SendSuccessResponse</code> for requests DIFFERENT from |
| 160 * <code>PP_FilesystemRequestMetadata</code>, |
| 161 * <code>PP_FilesystemRequestReadDirectory</code>, |
| 162 * <code>PP_FilesystemRequestReadFile</code> |
| 163 * - call <code>SendMetadataSuccessResponse</code> for |
| 164 * <code>PP_FilesystemRequestMetadata</code> request |
| 165 * - call <code>SendReadFileSuccessResponse</code> for |
| 166 * <code>PP_FilesystemRequestReadFile</code> request |
| 167 * - call <code>SendReadDirectorySuccessResponse</code> for |
| 168 * <code>PP_FilesystemRequestReadDirectory</code> request |
| 169 * - When a request is received and the processing results in an error: |
| 170 * - call <code>SendErrorResponse</code> for ALL requests |
| 171 * - If a PP_FilesystemRequestWrite is received a subsequent call to |
| 172 * <code>FreeWriteRequestBuffer</code> |
| 173 */ |
| 174 |
| 175 interface PPB_FilesystemProvider_Dev { |
| 176 |
| 177 PP_Resource Create( |
| 178 [in] PP_Instance instance ); |
| 179 |
| 180 PP_Bool IsFilesystemProvider( |
| 181 [in] PP_Resource resource ); |
| 182 /** |
| 183 * Mount() registers the file system |
| 184 * @param[in] filesystem_id A <code>PP_VARTYPE_STRING</code> |
| 185 * @param[in] display_name A <code> PP_VARTYPE_STRING</code> |
| 186 * @param[in] writable A <code> PP_VARTYPE_BOOL </code> |
| 187 * @param[in] opened_files_limit A <code>int32_t</code> |
| 188 * @param[out] error A <code>int32_t</code> |
| 189 * @param[in] callback A <code>PP_CompletionCallback</code> called when |
| 190 * the operation completes asynchronously. |
| 191 */ |
| 192 int32_t Mount( |
| 193 [in] PP_Resource filesystem_prov, |
| 194 [in] PP_Var filesystem_id, |
| 195 [in] PP_Var display_name, |
| 196 [in] PP_Bool writable, |
| 197 [in] int32_t opened_files_limit, |
| 198 [in] PP_CompletionCallback callback ); |
| 199 /** |
| 200 * Unmount() unregister the file system |
| 201 * @param[in] filesystem_id A <code>PP_VARTYPE_STRING</code> |
| 202 * @param[out] error A <code>int32_t</code> |
| 203 * @param[in] callback <code>PP_CompletionCallback</code> called when the |
| 204 * operation completes asynchronously. |
| 205 */ |
| 206 int32_t Unmount( |
| 207 [in] PP_Resource filesystem_prov, |
| 208 [in] PP_Var filesystem_id, |
| 209 [in] PP_CompletionCallback callback ); |
| 210 |
| 211 /** |
| 212 * Notify() notify of changes within the watched directories |
| 213 * @param[in] notify_options A <code>PP_VARTYPE_DICTIONARY</code> |
| 214 * @param[in] request_id A <code>int32_t</code> the id of the request |
| 215 * - "observedPath" : <code>PP_VARTYPE_STRING</code> |
| 216 * - "recursive" : <code>PP_VARTYPE_BOOL</code> |
| 217 * - "changeType" : <code> PP_ChangeType_Dev </code> |
| 218 * - "changes" : <code> PP_VARTYPE_ARRAY </code> |
| 219 * - <code> PP_VARTYPE_DICTIONARY </code> |
| 220 * - "entryPath": <code> PP_VARTYPE_STRING </code> |
| 221 * - "changeType": <code> PP_ChangeType_Dev </code> |
| 222 * - "tag" : <code> PP_VARTYPE_STRING </code> |
| 223 */ |
| 224 int32_t Notify( |
| 225 [in] PP_Resource filesystem_prov, |
| 226 [in] PP_Var notify_options); |
| 227 |
| 228 /** |
| 229 * Most of the operation will rely on the bellow 2 function calls to |
| 230 * to report status to the browser. |
| 231 * SendSuccessResponse() acknowledges the successful completion of the |
| 232 * requested file system operation. |
| 233 * @param[in] operation_type A <code>PP_OperationType_Dev</code> |
| 234 * @param[in] request_id A <code>int32_t</code> the id of the request |
| 235 */ |
| 236 int32_t SendSuccessResponse( |
| 237 [in] PP_Resource filesystem_prov, |
| 238 [in] PP_OperationType_Dev operation_type, |
| 239 [in] int32_t request_id ); |
| 240 |
| 241 /** |
| 242 * SendErrorResponse() notifies the browser that the request failed. |
| 243 * @param[in] operation_type A <code>PP_OperationType_Dev</code> |
| 244 * @param[in] errpr A <code>int32_t</code> |
| 245 * @param[in] request_id A <code>int32_t</code> |
| 246 */ |
| 247 int32_t SendErrorResponse( |
| 248 [in] PP_Resource filesystem_prov, |
| 249 [in] PP_OperationType_Dev operation_type, |
| 250 [in] int32_t error, |
| 251 [in] int32_t request_id ); |
| 252 |
| 253 /** |
| 254 * Special functions that don't follow the above template |
| 255 * for browser responses. |
| 256 * SendMetadataSuccessResponse() acknowledges the successful retrieval of the |
| 257 * metadata information |
| 258 * @param[in] metadata A <code>PP_VARTYPE_DICTIONARY</code> |
| 259 * - "isDirectory" : <code>PP_VARTYPE_BOOL</code> |
| 260 * - "name" : <code>PP_VARTYPE_STRING(mandatory)</code> |
| 261 * - "size" : <code>PP_VARTYPE_DOUBLE</code> |
| 262 * - "modificationTime" : <code>PP_VARTYPE_STRING</code> |
| 263 * - "mimeType" : <code>PP_VARTYPE_STRING</code> |
| 264 * - "thumbnail" : <code>PP_VARTYPE_STRING</code> |
| 265 * @param[in] request_id <code>int32_t</code> |
| 266 */ |
| 267 int32_t SendMetadataSuccessResponse( |
| 268 [in] PP_Resource filesystem_prov, |
| 269 [in] PP_Var metadata, |
| 270 [in] int32_t request_id ); |
| 271 |
| 272 /** |
| 273 * SendReadDirectorySuccessResponse acknowledges the successful retrieval of |
| 274 * metadatas information for directories and files |
| 275 * @param[in] array_size A <code>uint32_t</code> |
| 276 * @param[in] entries <code>PP_VARTYPE_ARRAY</code> |
| 277 * - an array of <code>PP_VARTYPE_DICTIONARY</code> |
| 278 * - "isDirectory" : <code>PP_VARTYPE_BOOL</code> |
| 279 * - "name" : <code>PP_VARTYPE_STRING(mandatory)</code> |
| 280 * - "size" : <code>PP_VARTYPE_DOUBLE</code> |
| 281 * - "modificationTime" : <code>PP_VARTYPE_STRING</code> |
| 282 * - "mimeType" : <code>PP_VARTYPE_STRING</code> |
| 283 * - "thumbnail" : <code>PP_VARTYPE_STRING</code> |
| 284 * @param[in] has_more A <code>PP_VARTYPE_BOOL</code> |
| 285 * @param[in] request_id A <code>int32_t</code> |
| 286 */ |
| 287 int32_t SendReadDirectorySuccessResponse( |
| 288 [in] PP_Resource filesystem_prov, |
| 289 [in] PP_Var entries, |
| 290 [in] PP_Bool has_more, |
| 291 [in] int32_t request_id ); |
| 292 /** |
| 293 * SendReadFileSuccessResponse() acknowledges the successful completion of a |
| 294 * read request. |
| 295 * @param[in] data_size A <code>uint32_t</code> |
| 296 * @param[in] data A pointer to the begining of the file chunk read from file |
| 297 * @param[in] has_more A <code>PP_VARTYPE_BOOL</code> |
| 298 * @param[in] request_id A <code>int32_t</code> |
| 299 */ |
| 300 int32_t SendReadFileSuccessResponse( |
| 301 [in] PP_Resource filesystem_prov, |
| 302 [in] uint32_t data_size, |
| 303 [in, size_is(data_size)] mem_t data, |
| 304 [in] PP_Bool has_more, |
| 305 [in] int32_t request_id ); |
| 306 /** |
| 307 * GetNextRequest() registers a callback for any pending requests. |
| 308 * @param[out] request A <code>PP_FilesystemRequest</code> this contains the |
| 309 * request for a file system operation |
| 310 * @param[in] callback A <code>PP_CompletionCallback</code> that is called when |
| 311 * a request becomes available. |
| 312 */ |
| 313 int32_t GetNextRequest( |
| 314 [in] PP_Resource filesystem_prov, |
| 315 [out] PP_FilesystemRequest request, |
| 316 [in] PP_CompletionCallback callback); |
| 317 /** |
| 318 * FreeWriteRequestBuffer frees resource buffer. This MUST be called after the |
| 319 * request is processed |
| 320 * @param[in] buffer A pointer to the start of the file chunk in memory |
| 321 */ |
| 322 int32_t ReleaseRequestBuffer( |
| 323 [in] PP_Resource filesystem_prov, |
| 324 [in] int32_t request_id); |
| 325 }; |
| 326 |
OLD | NEW |