Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: ppapi/c/dev/ppb_filesystemprovider_dev.h

Issue 1093383002: [WIP] Provided file system from NACL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Various cleanups Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 Fri May 29 13:16:12 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_ProviderError_NONE,
36 PP_ProviderError_OK,
37 PP_ProviderError_FAILED,
38 PP_ProviderError_IN_USE,
39 PP_ProviderError_EXISTS,
40 PP_ProviderError_NOT_FOUND,
41 PP_ProviderError_ACCESS_DENIED,
42 PP_ProviderError_TOO_MANY_OPENED,
43 PP_ProviderError_NO_MEMORY,
44 PP_ProviderError_NO_SPACE,
45 PP_ProviderError_NOT_A_DIRECTORY,
46 PP_ProviderError_INVALID_OPERATION,
47 PP_ProviderError_SECURITY,
48 PP_ProviderError_ABORT,
49 PP_ProviderError_NOT_A_FILE,
50 PP_ProviderError_NOT_EMPTY,
51 PP_ProviderError_INVALID_URL,
52 PP_ProviderError_IO
53 } PP_ProviderError_Dev;
54
55 typedef enum {
56 PP_OperationType_NONE,
57 PP_OperationType_UNMOUNT,
58 PP_OperationType_GETMETADATA,
59 PP_OperationType_READDIRECTORY,
60 PP_OperationType_OPENFILE,
61 PP_OperationType_CLOSEFILE,
62 PP_OperationType_READFILE,
63 PP_OperationType_CREATEDIRECTORY,
64 PP_OperationType_DELETEENTRY,
65 PP_OperationType_CREATEFILE,
66 PP_OperationType_COPYENTRY,
67 PP_OperationType_MOVEENTRY,
68 PP_OperationType_TRUNCATEENTRY,
69 PP_OperationType_WRITEFILE,
70 PP_OperationType_ABORT
71 } PP_OperationType_Dev;
72
73 typedef enum {
74 PP_OpenFileMode_NONE,
75 PP_OpenFileMode_READ,
76 PP_OpenFileMode_WRITE
77 } PP_OpenFileMode_Dev;
78
79 typedef enum {
80 PP_ChangeType_NONE,
81 PP_ChangeType_CHANGED,
82 PP_ChangeType_DELETED
83 } PP_ChangeType_Dev;
84 /**
85 * @}
86 */
87
88 /**
89 * @addtogroup Structs
90 * @{
91 */
92 /**
93 * Used by SendMetadataSuccessResponse and
94 * SendReadDirectorySuccessResponse to describe an entry/entries.
95 */
96 struct PP_EntryMetadata_Dev {
97 PP_Bool is_directory;
98 char name[128];
99 uint64_t size;
100 char modification_time[64];
101 char mime_type[128];
102 char thumbnail[512];
103 };
104
105 struct PP_FilesystemRequestUnmount {
106
107 };
108
109 struct PP_FilesystemRequestMetadata {
110 char entry_path[256];
111 PP_Bool thumbnail;
112 };
113
114 struct PP_FilesystemRequestReadDirectory {
115 char directory_path[256];
116 };
117
118 struct PP_FilesystemRequestOpenFile {
119 char file_path[256];
120 PP_OpenFileMode_Dev mode;
121 };
122
123 struct PP_FilesystemRequestCloseFile {
124 int32_t open_request_id;
125 };
126
127 struct PP_FilesystemRequestReadFile {
128 int32_t open_request_id;
129 uint64_t offset;
130 uint64_t length;
131 };
132
133 struct PP_FilesystemRequestCreateDirectory {
134 char directory_path[256];
135 PP_Bool recursive;
136 };
137
138 struct PP_FilesystemRequestDeleteEntry {
139 char entry_path[256];
140 PP_Bool recursive;
141 };
142
143 struct PP_FilesystemRequestCreateFile {
144 char file_path[256];
145 };
146
147 struct PP_FilesystemRequestCopyEntry {
148 char source_path[256];
149 char target_path[256];
150 };
151
152 struct PP_FilesystemRequestMoveEntry {
153 char source_path[256];
154 char target_path[256];
155 };
156
157 struct PP_FilesystemRequestTruncate {
158 char file_path[256];
159 int32_t length;
160 };
161
162 struct PP_FilesystemRequestWrite {
163 int32_t open_request_id;
164 uint64_t offset;
165 uint64_t data_size;
166 void* data;
167 };
168
169 struct PP_FilesystemRequestAbort {
170 int32_t operation_request_id;
171 };
172
173 /**
174 * The request format
175 */
176 union PP_FilesystemRequestValue {
177 struct PP_FilesystemRequestUnmount as_unmount;
178 struct PP_FilesystemRequestMetadata as_metadata;
179 struct PP_FilesystemRequestReadDirectory as_read_directory;
180 struct PP_FilesystemRequestOpenFile as_open_file;
181 struct PP_FilesystemRequestCloseFile as_close_file;
182 struct PP_FilesystemRequestReadFile as_read_file;
183 struct PP_FilesystemRequestCreateDirectory as_create_directory;
184 struct PP_FilesystemRequestDeleteEntry as_delete_entry;
185 struct PP_FilesystemRequestCreateFile as_create_file;
186 struct PP_FilesystemRequestCopyEntry as_copy_entry;
187 struct PP_FilesystemRequestMoveEntry as_move_entry;
188 struct PP_FilesystemRequestTruncate as_truncate;
189 struct PP_FilesystemRequestWrite as_write_file;
190 struct PP_FilesystemRequestAbort as_abort;
191 };
192
193 struct PP_FilesystemRequest {
194 PP_OperationType_Dev operation_type;
195 int32_t request_id;
196 union PP_FilesystemRequestValue value;
197 };
198 /**
199 * @}
200 */
201
202 /**
203 * @addtogroup Interfaces
204 * @{
205 */
206 /**
207 * File system provider interface.
208 * Typical usage:
209 * - Use Create() to create a new <code>PPB_FilesystemProvider_Dev resource
210 * - Call Mount() to register the new filesystem with the browser
211 * This will create an entry in the file manager Chrome OS UI. The user
212 * can select among the listed filesystem and issue file system operations
213 * - Call Unmount() to unregister the filesystem
214 * This will remove the entry from the file manager Chrome OS UI.
215 * - Register callback for the <code>PP_FilesystemRequest</code> messages that
216 * are sent from the browser with <code>GetNextRequest</code>
217 * - When a request is received and the processing results in a succcess:
218 * - call <code>SendSuccessResponse</code> for requests DIFFERENT from
219 * <code>PP_FilesystemRequestMetadata</code>,
220 * <code>PP_FilesystemRequestReadDirectory</code>,
221 * <code>PP_FilesystemRequestReadFile</code>
222 * - call <code>SendMetadataSuccessResponse</code> for
223 * <code>PP_FilesystemRequestMetadata</code> request
224 * - call <code>SendReadFileSuccessResponse</code> for
225 * <code>PP_FilesystemRequestReadFile</code> request
226 * - call <code>SendReadDirectorySuccessResponse</code> for
227 * <code>PP_FilesystemRequestReadDirectory</code> request
228 * - When a request is received and the processing results in an error:
229 * - call <code>SendErrorResponse</code> for ALL requests
230 * - If a PP_FilesystemRequestWrite is received a subsequent call to
231 * <code>FreeWriteRequestBuffer</code>
232 */
233 struct PPB_FilesystemProvider_Dev_0_1 {
234 PP_Resource (*Create)(PP_Instance instance);
235 PP_Bool (*IsFilesystemProvider)(PP_Resource resource);
236 /**
237 * Mount() registers the file system
238 * @param[in] filesystem_id A <code>PP_VARTYPE_STRING</code>
239 * @param[in] display_name A <code> PP_VARTYPE_STRING</code>
240 * @param[in] writable A <code> PP_VARTYPE_BOOL </code>
241 * @param[in] opened_files_limit A <code>int32_t</code>
242 * @param[out] error A <PP_ProviderError_Dev</code>
243 * @param[in] callback A <code>PP_CompletionCallback</code> called when
244 * the operation completes asynchronously.
245 */
246 int32_t (*Mount)(PP_Resource filesystem_prov,
247 struct PP_Var filesystem_id,
248 struct PP_Var display_name,
249 PP_Bool writable,
250 int32_t opened_files_limit,
251 PP_ProviderError_Dev* error,
252 struct PP_CompletionCallback callback);
253 /**
254 * Unmount() unregister the file system
255 * @param[in] filesystem_id A <code>PP_VARTYPE_STRING</code>
256 * @param[out] error A <code>PP_ProviderError</code>
257 * @param[in] callback <code>PP_CompletionCallback</code> called when the
258 * operation completes asynchronously.
259 */
260 int32_t (*Unmount)(PP_Resource filesystem_prov,
261 struct PP_Var filesystem_id,
262 PP_ProviderError_Dev* error,
263 struct PP_CompletionCallback callback);
264 /**
265 * Most of the operation will rely on the bellow 2 function calls to
266 * to report status to the browser.
267 * SendSuccessResponse() sends acknowledges the successful completion of the
268 * requested file system operation.
269 * @param[in] operation_type A <code>PP_OperationType_Dev</code>
270 * @param[in] request_id A <code>int32_t</code> the id of the request
271 */
272 int32_t (*SendSuccessResponse)(PP_Resource filesystem_prov,
273 PP_OperationType_Dev operation_type,
274 int32_t request_id);
275 /**
276 * SendErrorResponse() notifies the browser that the request failed.
277 * @param[in] operationType A <code>PP_ProviderError</code>
278 * @param[in] request_id A <code>int32_t</code>
279 */
280 int32_t (*SendErrorResponse)(PP_Resource filesystem_prov,
281 PP_OperationType_Dev operation_type,
282 PP_ProviderError_Dev error,
283 int32_t request_id);
284 /**
285 * Special functions that don't follow the above template
286 * for browser responses.
287 * SendMetadataSuccessResponse() acknowledges the successful retrieval of the
288 * metadata information
289 * @param[in] metadata A <code>PP_EntryMetadata_Dev</code>
290 * @param[in] request_id <code>int32_t</code>
291 */
292 int32_t (*SendMetadataSuccessResponse)(
293 PP_Resource filesystem_prov,
294 const struct PP_EntryMetadata_Dev* metadata,
295 int32_t request_id);
296 /**
297 * SendReadDirectorySuccessResponse acknowledges the successful retrieval of
298 * metadatas information for directories and files
299 * @param[in] array_size A <code>uint32_t</code>
300 * @param[in] entries several <code>PP_EntryMetadata_Dev</code>
301 * @param[in] has_more A <code>PP_VARTYPE_BOOL</code>
302 * @param[in] request_id A <code>int32_t</code>
303 */
304 int32_t (*SendReadDirectorySuccessResponse)(
305 PP_Resource filesystem_prov,
306 uint32_t array_size,
307 const struct PP_EntryMetadata_Dev entries[],
308 PP_Bool has_more,
309 int32_t request_id);
310 /**
311 * SendReadFileSuccessResponse() acknowledges the successful completion of a
312 * read request.
313 * @param[in] data_size A <code>uint32_t</code>
314 * @param[in] data A pointer to the begining of the file chunk read from file
315 * @param[in] has_more A <code>PP_VARTYPE_BOOL</code>
316 * @param[in] request_id A <code>int32_t</code>
317 */
318 int32_t (*SendReadFileSuccessResponse)(PP_Resource filesystem_prov,
319 uint32_t data_size,
320 const void* data,
321 PP_Bool has_more,
322 int32_t request_id);
323 /**
324 * GetNextRequest() registers a callback for any pending requests.
325 * @param[out] request A <code>PP_FilesystemRequest</code> this contains the
326 * request for a file system operation
327 * @param[in] callback A <code>PP_CompletionCallback</code> that is called
328 when
329 * a request becomes available.
330 */
331 int32_t (*GetNextRequest)(PP_Resource filesystem_prov,
332 struct PP_FilesystemRequest* request,
333 struct PP_CompletionCallback callback);
334 /**
335 * FreeWriteRequestBuffer frees resource buffer. This MUST be called after the
336 * request is processed
337 * @param[in] buffer A pointer to the start of the file chunk in memory
338 */
339 int32_t (*FreeWriteRequestBuffer)(PP_Resource filesystem_prov,
340 const void* buffer);
341 };
342
343 typedef struct PPB_FilesystemProvider_Dev_0_1 PPB_FilesystemProvider_Dev;
344 /**
345 * @}
346 */
347
348 #endif /* PPAPI_C_DEV_PPB_FILESYSTEMPROVIDER_DEV_H_ */
349
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698