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.
5 // From ppb_file_io.idl modified Thu Oct 31 12:30:06 2013.
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_file_io.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppapi_thunk_export.h"
13 #include "ppapi/thunk/ppb_file_io_api.h"
20 PP_Resource
Create(PP_Instance instance
) {
21 VLOG(4) << "PPB_FileIO::Create()";
22 EnterResourceCreation
enter(instance
);
25 return enter
.functions()->CreateFileIO(instance
);
28 PP_Bool
IsFileIO(PP_Resource resource
) {
29 VLOG(4) << "PPB_FileIO::IsFileIO()";
30 EnterResource
<PPB_FileIO_API
> enter(resource
, false);
31 return PP_FromBool(enter
.succeeded());
34 int32_t Open(PP_Resource file_io
,
37 struct PP_CompletionCallback callback
) {
38 VLOG(4) << "PPB_FileIO::Open()";
39 EnterResource
<PPB_FileIO_API
> enter(file_io
, callback
, true);
41 return enter
.retval();
42 return enter
.SetResult(enter
.object()->Open(file_ref
,
47 int32_t Query(PP_Resource file_io
,
48 struct PP_FileInfo
* info
,
49 struct PP_CompletionCallback callback
) {
50 VLOG(4) << "PPB_FileIO::Query()";
51 EnterResource
<PPB_FileIO_API
> enter(file_io
, callback
, true);
53 return enter
.retval();
54 return enter
.SetResult(enter
.object()->Query(info
, enter
.callback()));
57 int32_t Touch(PP_Resource file_io
,
58 PP_Time last_access_time
,
59 PP_Time last_modified_time
,
60 struct PP_CompletionCallback callback
) {
61 VLOG(4) << "PPB_FileIO::Touch()";
62 EnterResource
<PPB_FileIO_API
> enter(file_io
, callback
, true);
64 return enter
.retval();
65 return enter
.SetResult(enter
.object()->Touch(last_access_time
,
70 int32_t Read(PP_Resource file_io
,
73 int32_t bytes_to_read
,
74 struct PP_CompletionCallback callback
) {
75 VLOG(4) << "PPB_FileIO::Read()";
76 EnterResource
<PPB_FileIO_API
> enter(file_io
, callback
, true);
78 return enter
.retval();
79 return enter
.SetResult(enter
.object()->Read(offset
,
85 int32_t Write(PP_Resource file_io
,
88 int32_t bytes_to_write
,
89 struct PP_CompletionCallback callback
) {
90 VLOG(4) << "PPB_FileIO::Write()";
91 EnterResource
<PPB_FileIO_API
> enter(file_io
, callback
, true);
93 return enter
.retval();
94 return enter
.SetResult(enter
.object()->Write(offset
,
100 int32_t SetLength(PP_Resource file_io
,
102 struct PP_CompletionCallback callback
) {
103 VLOG(4) << "PPB_FileIO::SetLength()";
104 EnterResource
<PPB_FileIO_API
> enter(file_io
, callback
, true);
106 return enter
.retval();
107 return enter
.SetResult(enter
.object()->SetLength(length
, enter
.callback()));
110 int32_t Flush(PP_Resource file_io
, struct PP_CompletionCallback callback
) {
111 VLOG(4) << "PPB_FileIO::Flush()";
112 EnterResource
<PPB_FileIO_API
> enter(file_io
, callback
, true);
114 return enter
.retval();
115 return enter
.SetResult(enter
.object()->Flush(enter
.callback()));
118 void Close(PP_Resource file_io
) {
119 VLOG(4) << "PPB_FileIO::Close()";
120 EnterResource
<PPB_FileIO_API
> enter(file_io
, true);
123 enter
.object()->Close();
126 int32_t ReadToArray(PP_Resource file_io
,
128 int32_t max_read_length
,
129 struct PP_ArrayOutput
* output
,
130 struct PP_CompletionCallback callback
) {
131 VLOG(4) << "PPB_FileIO::ReadToArray()";
132 EnterResource
<PPB_FileIO_API
> enter(file_io
, callback
, true);
134 return enter
.retval();
135 return enter
.SetResult(enter
.object()->ReadToArray(offset
,
141 const PPB_FileIO_1_0 g_ppb_fileio_thunk_1_0
= {
154 const PPB_FileIO_1_1 g_ppb_fileio_thunk_1_1
= {
170 PPAPI_THUNK_EXPORT
const PPB_FileIO_1_0
* GetPPB_FileIO_1_0_Thunk() {
171 return &g_ppb_fileio_thunk_1_0
;
174 PPAPI_THUNK_EXPORT
const PPB_FileIO_1_1
* GetPPB_FileIO_1_1_Thunk() {
175 return &g_ppb_fileio_thunk_1_1
;