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