Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 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 #ifndef PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ | 5 #ifndef PPAPI_C_PPB_FILE_IO_H_ |
| 6 #define PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ | 6 #define PPAPI_C_PPB_FILE_IO_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" | 8 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
| 10 #include "ppapi/c/pp_macros.h" | 10 #include "ppapi/c/pp_macros.h" |
| 11 #include "ppapi/c/pp_resource.h" | 11 #include "ppapi/c/pp_resource.h" |
| 12 #include "ppapi/c/pp_stdint.h" | 12 #include "ppapi/c/pp_stdint.h" |
| 13 #include "ppapi/c/pp_time.h" | 13 #include "ppapi/c/pp_time.h" |
| 14 | 14 |
| 15 struct PP_CompletionCallback; | 15 struct PP_CompletionCallback; |
| 16 struct PP_FileInfo_Dev; | 16 struct PP_FileInfo; |
| 17 | 17 |
| 18 typedef enum { | 18 typedef enum { |
| 19 // Requests read access to a file. | 19 // Requests read access to a file. |
| 20 PP_FILEOPENFLAG_READ = 1 << 0, | 20 PP_FILEOPENFLAG_READ = 1 << 0, |
| 21 | 21 |
| 22 // Requests write access to a file. May be combined with | 22 // Requests write access to a file. May be combined with |
| 23 // PP_FILEOPENFLAG_READ to request read and write access. | 23 // PP_FILEOPENFLAG_READ to request read and write access. |
| 24 PP_FILEOPENFLAG_WRITE = 1 << 1, | 24 PP_FILEOPENFLAG_WRITE = 1 << 1, |
| 25 | 25 |
| 26 // Requests that the file be created if it does not exist. If the file | 26 // Requests that the file be created if it does not exist. If the file |
| 27 // already exists, then this flag is ignored unless PP_FILEOPENFLAG_EXCLUSIVE | 27 // already exists, then this flag is ignored unless PP_FILEOPENFLAG_EXCLUSIVE |
| 28 // was also specified, in which case FileIO::Open will fail. | 28 // was also specified, in which case FileIO::Open will fail. |
| 29 PP_FILEOPENFLAG_CREATE = 1 << 2, | 29 PP_FILEOPENFLAG_CREATE = 1 << 2, |
| 30 | 30 |
| 31 // Requests that the file be truncated to length 0 if it exists and is a | 31 // Requests that the file be truncated to length 0 if it exists and is a |
| 32 // regular file. PP_FILEOPENFLAG_WRITE must also be specified. | 32 // regular file. PP_FILEOPENFLAG_WRITE must also be specified. |
| 33 PP_FILEOPENFLAG_TRUNCATE = 1 << 3, | 33 PP_FILEOPENFLAG_TRUNCATE = 1 << 3, |
| 34 | 34 |
| 35 // Requests that the file is created when this flag is combined with | 35 // Requests that the file is created when this flag is combined with |
| 36 // PP_FILEOPENFLAG_CREATE. If this flag is specified, and the file already | 36 // PP_FILEOPENFLAG_CREATE. If this flag is specified, and the file already |
| 37 // exists, then the FileIO::Open call will fail. | 37 // exists, then the FileIO::Open call will fail. |
| 38 PP_FILEOPENFLAG_EXCLUSIVE = 1 << 4 | 38 PP_FILEOPENFLAG_EXCLUSIVE = 1 << 4 |
| 39 } PP_FileOpenFlags_Dev; | 39 } PP_FileOpenFlags; |
| 40 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileOpenFlags_Dev, 4); | 40 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileOpenFlags, 4); |
| 41 | 41 |
| 42 #define PPB_FILEIO_DEV_INTERFACE_0_3 "PPB_FileIO(Dev);0.3" | 42 #define PPB_FILEIO_INTERFACE_1_0 "PPB_FileIO;1.0" |
|
nfullagar
2011/06/21 20:15:23
When previous interfaces came out of Dev, it was r
Sang Ahn
2011/06/21 20:41:08
Done.
| |
| 43 #define PPB_FILEIO_DEV_INTERFACE PPB_FILEIO_DEV_INTERFACE_0_3 | 43 #define PPB_FILEIO_INTERFACE PPB_FILEIO_INTERFACE_1_0 |
| 44 | 44 |
| 45 // Use this interface to operate on a regular file (PP_FileType_Regular). | 45 // Use this interface to operate on a regular file (PP_FileType_Regular). |
| 46 struct PPB_FileIO_Dev { | 46 struct PPB_FileIO { |
| 47 // Creates a new FileIO object. Returns 0 if the module is invalid. | 47 // Creates a new FileIO object. Returns 0 if the module is invalid. |
| 48 PP_Resource (*Create)(PP_Instance instance); | 48 PP_Resource (*Create)(PP_Instance instance); |
| 49 | 49 |
| 50 // Returns PP_TRUE if the given resource is a FileIO. Returns PP_FALSE if the | 50 // Returns PP_TRUE if the given resource is a FileIO. Returns PP_FALSE if the |
| 51 // resource is invalid or some type other than a FileIO. | 51 // resource is invalid or some type other than a FileIO. |
| 52 PP_Bool (*IsFileIO)(PP_Resource resource); | 52 PP_Bool (*IsFileIO)(PP_Resource resource); |
| 53 | 53 |
| 54 // Open the specified regular file for I/O according to the given open flags, | 54 // Open the specified regular file for I/O according to the given open flags, |
| 55 // which is a bit-mask of the PP_FileOpenFlags values. Upon success, the | 55 // which is a bit-mask of the PP_FileOpenFlags values. Upon success, the |
| 56 // corresponding file is classified as "in use" by this FileIO object until | 56 // corresponding file is classified as "in use" by this FileIO object until |
| 57 // such time as the FileIO object is closed or destroyed. | 57 // such time as the FileIO object is closed or destroyed. |
| 58 int32_t (*Open)(PP_Resource file_io, | 58 int32_t (*Open)(PP_Resource file_io, |
| 59 PP_Resource file_ref, | 59 PP_Resource file_ref, |
| 60 int32_t open_flags, | 60 int32_t open_flags, |
| 61 struct PP_CompletionCallback callback); | 61 struct PP_CompletionCallback callback); |
| 62 | 62 |
| 63 // Queries info about the file opened by this FileIO object. Fails if the | 63 // Queries info about the file opened by this FileIO object. Fails if the |
| 64 // FileIO object has not been opened. | 64 // FileIO object has not been opened. |
| 65 int32_t (*Query)(PP_Resource file_io, | 65 int32_t (*Query)(PP_Resource file_io, |
| 66 struct PP_FileInfo_Dev* info, | 66 struct PP_FileInfo* info, |
| 67 struct PP_CompletionCallback callback); | 67 struct PP_CompletionCallback callback); |
| 68 | 68 |
| 69 // Updates timestamps for the file opened by this FileIO object. Fails if | 69 // Updates timestamps for the file opened by this FileIO object. Fails if |
| 70 // the FileIO object has not been opened. | 70 // the FileIO object has not been opened. |
| 71 int32_t (*Touch)(PP_Resource file_io, | 71 int32_t (*Touch)(PP_Resource file_io, |
| 72 PP_Time last_access_time, | 72 PP_Time last_access_time, |
| 73 PP_Time last_modified_time, | 73 PP_Time last_modified_time, |
| 74 struct PP_CompletionCallback callback); | 74 struct PP_CompletionCallback callback); |
| 75 | 75 |
| 76 // Read from an offset in the file. The size of the buffer must be large | 76 // Read from an offset in the file. The size of the buffer must be large |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 | 109 |
| 110 // Cancels any IO that may be pending, and closes the FileIO object. Any | 110 // Cancels any IO that may be pending, and closes the FileIO object. Any |
| 111 // pending callbacks will still run, reporting PP_Error_Aborted if pending IO | 111 // pending callbacks will still run, reporting PP_Error_Aborted if pending IO |
| 112 // was interrupted. It is NOT valid to call Open again after a call to this | 112 // was interrupted. It is NOT valid to call Open again after a call to this |
| 113 // method. Note: If the FileIO object is destroyed, and it is still open, | 113 // method. Note: If the FileIO object is destroyed, and it is still open, |
| 114 // then it will be implicitly closed, so you are not required to call the | 114 // then it will be implicitly closed, so you are not required to call the |
| 115 // Close method. | 115 // Close method. |
| 116 void (*Close)(PP_Resource file_io); | 116 void (*Close)(PP_Resource file_io); |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 #endif /* PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ */ | 119 #endif /* PPAPI_C_PPB_FILE_IO_H_ */ |
| 120 | |
| OLD | NEW |