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

Side by Side Diff: ppapi/c/ppb_file_io.h

Issue 27730003: Avoid memory allocation for PPB_FileIO Read when callback is blocking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address David's comments. Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2012 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 5
6 /* From ppb_file_io.idl modified Tue Jun 11 15:21:38 2013. */ 6 /* From ppb_file_io.idl modified Tue Oct 22 13:47:58 2013. */
7 7
8 #ifndef PPAPI_C_PPB_FILE_IO_H_ 8 #ifndef PPAPI_C_PPB_FILE_IO_H_
9 #define PPAPI_C_PPB_FILE_IO_H_ 9 #define PPAPI_C_PPB_FILE_IO_H_
10 10
11 #include "ppapi/c/pp_array_output.h" 11 #include "ppapi/c/pp_array_output.h"
12 #include "ppapi/c/pp_bool.h" 12 #include "ppapi/c/pp_bool.h"
13 #include "ppapi/c/pp_completion_callback.h" 13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/pp_file_info.h" 14 #include "ppapi/c/pp_file_info.h"
15 #include "ppapi/c/pp_instance.h" 15 #include "ppapi/c/pp_instance.h"
16 #include "ppapi/c/pp_macros.h" 16 #include "ppapi/c/pp_macros.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 /** 128 /**
129 * Query() queries info about the file opened by this FileIO object. The 129 * Query() queries info about the file opened by this FileIO object. The
130 * FileIO object must be opened, and there must be no other operations 130 * FileIO object must be opened, and there must be no other operations
131 * pending. 131 * pending.
132 * 132 *
133 * @param[in] file_io A <code>PP_Resource</code> corresponding to a 133 * @param[in] file_io A <code>PP_Resource</code> corresponding to a
134 * FileIO. 134 * FileIO.
135 * @param[out] info The <code>PP_FileInfo</code> structure representing all 135 * @param[out] info The <code>PP_FileInfo</code> structure representing all
136 * information about the file. 136 * information about the file.
137 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon 137 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
138 * completion of Query(). 138 * completion of Query(). If <code>callback</code> is blocking, then
139 * <code>info</code> must remain valid until after the callback runs.
139 * 140 *
140 * @return An int32_t containing an error code from <code>pp_errors.h</code>. 141 * @return An int32_t containing an error code from <code>pp_errors.h</code>.
141 * PP_ERROR_FAILED will be returned if the file isn't opened, and 142 * PP_ERROR_FAILED will be returned if the file isn't opened, and
142 * PP_ERROR_INPROGRESS will be returned if there is another operation pending. 143 * PP_ERROR_INPROGRESS will be returned if there is another operation pending.
143 */ 144 */
144 int32_t (*Query)(PP_Resource file_io, 145 int32_t (*Query)(PP_Resource file_io,
145 struct PP_FileInfo* info, 146 struct PP_FileInfo* info,
146 struct PP_CompletionCallback callback); 147 struct PP_CompletionCallback callback);
147 /** 148 /**
148 * Touch() Updates time stamps for the file opened by this FileIO object. 149 * Touch() Updates time stamps for the file opened by this FileIO object.
(...skipping 14 matching lines...) Expand all
163 */ 164 */
164 int32_t (*Touch)(PP_Resource file_io, 165 int32_t (*Touch)(PP_Resource file_io,
165 PP_Time last_access_time, 166 PP_Time last_access_time,
166 PP_Time last_modified_time, 167 PP_Time last_modified_time,
167 struct PP_CompletionCallback callback); 168 struct PP_CompletionCallback callback);
168 /** 169 /**
169 * Read() reads from an offset in the file. The size of the buffer must be 170 * Read() reads from an offset in the file. The size of the buffer must be
170 * large enough to hold the specified number of bytes to read. This function 171 * large enough to hold the specified number of bytes to read. This function
171 * might perform a partial read, meaning all the requested bytes 172 * might perform a partial read, meaning all the requested bytes
172 * might not be returned, even if the end of the file has not been reached. 173 * might not be returned, even if the end of the file has not been reached.
174 * The FileIO object must have been opened with read access.
173 * 175 *
174 * ReadToArray() is preferred to Read() when doing asynchronous operations. 176 * ReadToArray() is preferred to Read() when doing asynchronous operations.
175 * 177 *
176 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file 178 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file
177 * FileIO. 179 * FileIO.
178 * @param[in] offset The offset into the file. 180 * @param[in] offset The offset into the file.
179 * @param[in] buffer The buffer to hold the specified number of bytes read. 181 * @param[in] buffer The buffer to hold the specified number of bytes read.
180 * @param[in] bytes_to_read The number of bytes to read from 182 * @param[in] bytes_to_read The number of bytes to read from
181 * <code>offset</code>. 183 * <code>offset</code>.
182 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon 184 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
183 * completion of Read(). 185 * completion of Read(). If <code>callback</code> is blocking, then
186 * <code>buffer</code> must remain valid until after the callback runs.
184 * 187 *
185 * @return The number of bytes read or an error code from 188 * @return The number of bytes read or an error code from
186 * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was 189 * <code>pp_errors.h</code>. If the return value is 0, then end-of-file was
187 * reached. It is valid to call Read() multiple times with a completion 190 * reached. It is valid to call Read() multiple times with a completion
188 * callback to queue up parallel reads from the file, but pending reads 191 * callback to queue up parallel reads from the file, but pending reads
189 * cannot be interleaved with other operations. 192 * cannot be interleaved with other operations.
190 */ 193 */
191 int32_t (*Read)(PP_Resource file_io, 194 int32_t (*Read)(PP_Resource file_io,
192 int64_t offset, 195 int64_t offset,
193 char* buffer, 196 char* buffer,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 * open, then it will be implicitly closed, so you are not required to call 263 * open, then it will be implicitly closed, so you are not required to call
261 * Close(). 264 * Close().
262 * 265 *
263 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file 266 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file
264 * FileIO. 267 * FileIO.
265 */ 268 */
266 void (*Close)(PP_Resource file_io); 269 void (*Close)(PP_Resource file_io);
267 /** 270 /**
268 * ReadToArray() reads from an offset in the file. A PP_ArrayOutput must be 271 * ReadToArray() reads from an offset in the file. A PP_ArrayOutput must be
269 * provided so that output will be stored in its allocated buffer. This 272 * provided so that output will be stored in its allocated buffer. This
270 * function might perform a partial read. 273 * function might perform a partial read. The FileIO object must have been
274 * opened with read access.
271 * 275 *
272 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file 276 * @param[in] file_io A <code>PP_Resource</code> corresponding to a file
273 * FileIO. 277 * FileIO.
274 * @param[in] offset The offset into the file. 278 * @param[in] offset The offset into the file.
275 * @param[in] max_read_length The maximum number of bytes to read from 279 * @param[in] max_read_length The maximum number of bytes to read from
276 * <code>offset</code>. 280 * <code>offset</code>.
277 * @param[in] output A <code>PP_ArrayOutput</code> to hold the output data. 281 * @param[in] output A <code>PP_ArrayOutput</code> to hold the output data.
278 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon 282 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
279 * completion of ReadToArray(). 283 * completion of ReadToArray().
280 * 284 *
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 struct PP_CompletionCallback callback); 326 struct PP_CompletionCallback callback);
323 int32_t (*Flush)(PP_Resource file_io, struct PP_CompletionCallback callback); 327 int32_t (*Flush)(PP_Resource file_io, struct PP_CompletionCallback callback);
324 void (*Close)(PP_Resource file_io); 328 void (*Close)(PP_Resource file_io);
325 }; 329 };
326 /** 330 /**
327 * @} 331 * @}
328 */ 332 */
329 333
330 #endif /* PPAPI_C_PPB_FILE_IO_H_ */ 334 #endif /* PPAPI_C_PPB_FILE_IO_H_ */
331 335
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698