OLD | NEW |
| (Empty) |
1 /* Copyright (c) 2013 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_file_io_dev.idl modified Thu Sep 19 10:07:03 2013. */ | |
7 | |
8 #ifndef PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ | |
9 #define PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ | |
10 | |
11 #include "ppapi/c/pp_completion_callback.h" | |
12 #include "ppapi/c/pp_macros.h" | |
13 #include "ppapi/c/pp_resource.h" | |
14 #include "ppapi/c/pp_stdint.h" | |
15 | |
16 #define PPB_FILEIO_DEV_INTERFACE_0_1 "PPB_FileIO(Dev);0.1" | |
17 #define PPB_FILEIO_DEV_INTERFACE PPB_FILEIO_DEV_INTERFACE_0_1 | |
18 | |
19 /** | |
20 * @file | |
21 * This file defines methods for use with a PPB_FileIO resource that may become | |
22 * stable in the future. For now, they can be used only in plugins with DEV | |
23 * permissions. | |
24 */ | |
25 | |
26 | |
27 /** | |
28 * @addtogroup Enums | |
29 * @{ | |
30 */ | |
31 /** | |
32 * The PP_FileMapProtection values indicate the permissions requested for the | |
33 * file mapping. These should be used in a uint32_t bitfield. | |
34 */ | |
35 typedef enum { | |
36 /** Requests read access to the mapped address. */ | |
37 PP_FILEMAPPROTECTION_READ = 1u << 0, | |
38 /** Requests write access to the mapped address. */ | |
39 PP_FILEMAPPROTECTION_WRITE = 1u << 1 | |
40 } PP_FileMapProtection; | |
41 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileMapProtection, 4); | |
42 | |
43 /** | |
44 * The PP_FileMapFlags contain flag values for use with Map(). | |
45 */ | |
46 typedef enum { | |
47 /** | |
48 * Requests a shared mapping. If this flag is set, changes written to the | |
49 * memory region will be reflected in the underlying file and will thus | |
50 * eventually be visible to other processes which have opened the file. The | |
51 * file may not actually be updated until Unmap() is called. This is only | |
52 * valid if the PPB_FileIO resource was opened with write permission. | |
53 */ | |
54 PP_FILEMAPFLAG_SHARED = 1u << 0, | |
55 /** | |
56 * Requests a copy-on-write mapping. If this flag is set, changes are not | |
57 * written to the underlying file, but only in the memory of the process | |
58 * (copy-on-write). | |
59 */ | |
60 PP_FILEMAPFLAG_PRIVATE = 1u << 1, | |
61 /** | |
62 * Forces Map() to map the file contents at the provided |address|. If Map() | |
63 * can not comply, Map() will fail. | |
64 */ | |
65 PP_FILEMAPFLAG_FIXED = 1u << 2 | |
66 } PP_FileMapFlags; | |
67 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_FileMapFlags, 4); | |
68 /** | |
69 * @} | |
70 */ | |
71 | |
72 /** | |
73 * @addtogroup Interfaces | |
74 * @{ | |
75 */ | |
76 /** | |
77 * PPB_FileIO_Dev contains functions that are usable with PPB_FileIO resources | |
78 * but aren't yet considered stable yet and thus are not supported for general | |
79 * NaCl or PNaCl apps yet. Features here are being tested and refined for | |
80 * possible future inclusion in (stable) PPB_FileIO. | |
81 */ | |
82 struct PPB_FileIO_Dev_0_1 { | |
83 /** | |
84 * Map() maps the contents from an offset of the file into memory. | |
85 * | |
86 * @param[in] file_io A PP_Resource corresponding to a file. | |
87 * @param[in] length The number of bytes to map. | |
88 * @param[in] map_protection A bitfield containing values from | |
89 * PP_FileMapProtection, indicating what memory operations should be permitted | |
90 * on the mapped region. | |
91 * @param[in] map_flags A bitfield containing values from | |
92 * PP_FileMapFlags, providing options for the behavior of Map. If the region | |
93 * is to be writeable, then exactly one of PP_FILEMAPFLAG_SHARED or | |
94 * PP_FILEMAPFLAG_PRIVATE must be set. | |
95 * @param[in] offset The offset into the file. Must be a multiple of the | |
96 * Map page size as returned by GetMapPageSize. | |
97 * @param[inout] address The value of |*address|, if non-NULL, will be used as | |
98 * a hint to determine where in memory the file should be mapped. If the value | |
99 * is NULL, the host operating system will choose |address|. Upon | |
100 * Map() completing, |*address| will contain the actual memory location at | |
101 * which the file was mapped. If the plugin provides a non-NULL |*address|, it | |
102 * must be a multiple of the map page size as returned by GetMapPageSize(). | |
103 * @param[in] callback A PP_CompletionCallback to be called upon | |
104 * completion of Map(). | |
105 * | |
106 * @return An int32_t containing an error code from <code>pp_errors.h</code>. | |
107 */ | |
108 int32_t (*Map)(PP_Resource file_io, | |
109 int64_t length, | |
110 uint32_t map_protection, | |
111 uint32_t map_flags, | |
112 int64_t offset, | |
113 void** address, | |
114 struct PP_CompletionCallback callback); | |
115 /** | |
116 * Unmap() deletes the mapping of the specified address address to a | |
117 * file io. The specified address must have been retrieved with | |
118 * Map(). | |
119 * @param[in] file_io A PP_Resource corresponding to a file. | |
120 * @param[in] address The starting address of the address in memory to | |
121 * be unmapped. | |
122 * @param[in] length The length of the region to unmap. | |
123 */ | |
124 void (*Unmap)(PP_Resource file_io, void* address, int64_t length); | |
125 /** | |
126 * GetMapPageSize() returns the size of pages that Map() uses. Returns 0 on | |
127 * failure. | |
128 */ | |
129 int64_t (*GetMapPageSize)(PP_Resource file_io); | |
130 }; | |
131 | |
132 typedef struct PPB_FileIO_Dev_0_1 PPB_FileIO_Dev; | |
133 /** | |
134 * @} | |
135 */ | |
136 | |
137 #endif /* PPAPI_C_DEV_PPB_FILE_IO_DEV_H_ */ | |
138 | |
OLD | NEW |