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