Pepper_56_C++_interfaces
Pepper_56_C++_interfaces
 All Classes Namespaces Files Functions Typedefs Enumerations Macros Groups
file_io.h
Go to the documentation of this file.
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
3 // found in the LICENSE file.
4 
5 #ifndef PPAPI_CPP_FILE_IO_H_
6 #define PPAPI_CPP_FILE_IO_H_
7 
8 #include <stdint.h>
9 
10 #include "ppapi/c/pp_time.h"
12 #include "ppapi/cpp/resource.h"
13 
16 
17 struct PP_FileInfo;
18 
19 namespace pp {
20 
21 class FileRef;
22 class InstanceHandle;
23 
25 class FileIO : public Resource {
26  public:
29  FileIO();
30 
36  explicit FileIO(const InstanceHandle& instance);
37 
41  FileIO(const FileIO& other);
42 
66  int32_t Open(const FileRef& file_ref,
67  int32_t open_flags,
68  const CompletionCallback& cc);
69 
82  int32_t Query(PP_FileInfo* result_buf,
83  const CompletionCallback& cc);
84 
95  int32_t Touch(PP_Time last_access_time,
96  PP_Time last_modified_time,
97  const CompletionCallback& cc);
98 
153  int32_t Read(int64_t offset,
154  char* buffer,
155  int32_t bytes_to_read,
156  const CompletionCallback& cc);
157 
176  int32_t Read(int32_t offset,
177  int32_t max_read_length,
178  const CompletionCallbackWithOutput< std::vector<char> >& cc);
179 
195  int32_t Write(int64_t offset,
196  const char* buffer,
197  int32_t bytes_to_write,
198  const CompletionCallback& cc);
199 
210  int32_t SetLength(int64_t length,
211  const CompletionCallback& cc);
212 
220  int32_t Flush(const CompletionCallback& cc);
221 
230  void Close();
231 
232  private:
233  struct CallbackData1_0 {
234  PP_ArrayOutput output;
235  char* temp_buffer;
236  PP_CompletionCallback original_callback;
237  };
238 
239  // Provide backwards-compatibility for older Read versions. Converts the
240  // old-style "char*" output buffer of 1.0 to the new "PP_ArrayOutput"
241  // interface in 1.1.
242  //
243  // This takes a heap-allocated CallbackData1_0 struct passed as the user data
244  // and deletes it when the call completes.
245  static void CallbackConverter(void* user_data, int32_t result);
246 };
247 
248 } // namespace pp
249 
250 #endif // PPAPI_CPP_FILE_IO_H_
Definition: file_ref.h:27
Definition: completion_callback.h:189
The FileIO class represents a regular file.
Definition: file_io.h:25
int32_t Query(PP_FileInfo *result_buf, const CompletionCallback &cc)
int32_t Touch(PP_Time last_access_time, PP_Time last_modified_time, const CompletionCallback &cc)
void Close()
int32_t Flush(const CompletionCallback &cc)
Definition: completion_callback.h:26
int32_t Write(int64_t offset, const char *buffer, int32_t bytes_to_write, const CompletionCallback &cc)
int32_t Read(int64_t offset, char *buffer, int32_t bytes_to_read, const CompletionCallback &cc)
Definition: instance_handle.h:44
int32_t SetLength(int64_t length, const CompletionCallback &cc)
int32_t Open(const FileRef &file_ref, int32_t open_flags, const CompletionCallback &cc)
A reference counted module resource.
Definition: resource.h:20