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

Side by Side Diff: ppapi/cpp/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 second round of comments. Created 7 years, 1 month 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
« no previous file with comments | « ppapi/c/ppb_file_io.h ('k') | ppapi/proxy/file_io_resource.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef PPAPI_CPP_FILE_IO_H_ 5 #ifndef PPAPI_CPP_FILE_IO_H_
6 #define PPAPI_CPP_FILE_IO_H_ 6 #define PPAPI_CPP_FILE_IO_H_
7 7
8 #include "ppapi/c/pp_time.h" 8 #include "ppapi/c/pp_time.h"
9 #include "ppapi/cpp/completion_callback.h" 9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/resource.h" 10 #include "ppapi/cpp/resource.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 int32_t Open(const FileRef& file_ref, 64 int32_t Open(const FileRef& file_ref,
65 int32_t open_flags, 65 int32_t open_flags,
66 const CompletionCallback& cc); 66 const CompletionCallback& cc);
67 67
68 /// Query() queries info about the file opened by this FileIO object. This 68 /// Query() queries info about the file opened by this FileIO object. This
69 /// function will fail if the FileIO object has not been opened. 69 /// function will fail if the FileIO object has not been opened.
70 /// 70 ///
71 /// @param[in] result_buf The <code>PP_FileInfo</code> structure representing 71 /// @param[in] result_buf The <code>PP_FileInfo</code> structure representing
72 /// all information about the file. 72 /// all information about the file.
73 /// @param[in] cc A <code>CompletionCallback</code> to be called upon 73 /// @param[in] cc A <code>CompletionCallback</code> to be called upon
74 /// completion of Query(). 74 /// completion of Query(). <code>result_buf</code> must remain valid until
75 /// after the callback runs. If you pass a blocking callback,
76 /// <code>result_buf</code> must remain valid until after Query() returns.
75 /// 77 ///
76 /// @return An int32_t containing an error code from 78 /// @return An int32_t containing an error code from
77 /// <code>pp_errors.h</code>. 79 /// <code>pp_errors.h</code>.
78 int32_t Query(PP_FileInfo* result_buf, 80 int32_t Query(PP_FileInfo* result_buf,
79 const CompletionCallback& cc); 81 const CompletionCallback& cc);
80 82
81 /// Touch() Updates time stamps for the file opened by this FileIO object. 83 /// Touch() Updates time stamps for the file opened by this FileIO object.
82 /// This function will fail if the FileIO object has not been opened. 84 /// This function will fail if the FileIO object has not been opened.
83 /// 85 ///
84 /// @param[in] last_access_time The last time the FileIO was accessed. 86 /// @param[in] last_access_time The last time the FileIO was accessed.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 /// 133 ///
132 /// See the other version of Read() which avoids this problem by writing into 134 /// See the other version of Read() which avoids this problem by writing into
133 /// CompletionCallbackWithOutput, where the output buffer is automatically 135 /// CompletionCallbackWithOutput, where the output buffer is automatically
134 /// managed by the callback. 136 /// managed by the callback.
135 /// 137 ///
136 /// @param[in] offset The offset into the file. 138 /// @param[in] offset The offset into the file.
137 /// @param[in] buffer The buffer to hold the specified number of bytes read. 139 /// @param[in] buffer The buffer to hold the specified number of bytes read.
138 /// @param[in] bytes_to_read The number of bytes to read from 140 /// @param[in] bytes_to_read The number of bytes to read from
139 /// <code>offset</code>. 141 /// <code>offset</code>.
140 /// @param[in] cc A <code>CompletionCallback</code> to be called upon 142 /// @param[in] cc A <code>CompletionCallback</code> to be called upon
141 /// completion of Read(). 143 /// completion of Read(). <code>buffer</code> must remain valid until after
144 /// the callback runs. If you pass a blocking callback, <code>buffer</code>
145 /// must remain valid until after Read() returns.
142 /// 146 ///
143 /// @return An The number of bytes read an error code from 147 /// @return An The number of bytes read an error code from
144 /// <code>pp_errors.h</code>. If the return value is 0, then end-of-file was 148 /// <code>pp_errors.h</code>. If the return value is 0, then end-of-file was
145 /// reached. It is valid to call Read() multiple times with a completion 149 /// reached. It is valid to call Read() multiple times with a completion
146 /// callback to queue up parallel reads from the file at different offsets. 150 /// callback to queue up parallel reads from the file at different offsets.
147 int32_t Read(int64_t offset, 151 int32_t Read(int64_t offset,
148 char* buffer, 152 char* buffer,
149 int32_t bytes_to_read, 153 int32_t bytes_to_read,
150 const CompletionCallback& cc); 154 const CompletionCallback& cc);
151 155
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 // interface in 1.1. 238 // interface in 1.1.
235 // 239 //
236 // This takes a heap-allocated CallbackData1_0 struct passed as the user data 240 // This takes a heap-allocated CallbackData1_0 struct passed as the user data
237 // and deletes it when the call completes. 241 // and deletes it when the call completes.
238 static void CallbackConverter(void* user_data, int32_t result); 242 static void CallbackConverter(void* user_data, int32_t result);
239 }; 243 };
240 244
241 } // namespace pp 245 } // namespace pp
242 246
243 #endif // PPAPI_CPP_FILE_IO_H_ 247 #endif // PPAPI_CPP_FILE_IO_H_
OLDNEW
« no previous file with comments | « ppapi/c/ppb_file_io.h ('k') | ppapi/proxy/file_io_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698