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

Side by Side Diff: ppapi/thunk/ppb_file_io_thunk.cc

Issue 7082036: Convert more interfaces to the new thunk system. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #include "ppapi/c/dev/ppb_file_io_dev.h"
6 #include "ppapi/c/pp_completion_callback.h"
7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/thunk/thunk.h"
9 #include "ppapi/thunk/enter.h"
10 #include "ppapi/thunk/ppb_file_io_api.h"
11 #include "ppapi/thunk/resource_creation_api.h"
12
13 namespace ppapi {
14 namespace thunk {
15
16 namespace {
17
18 PP_Resource Create(PP_Instance instance) {
19 EnterFunction<ResourceCreationAPI> enter(instance, true);
20 if (enter.failed())
21 return 0;
22 return enter.functions()->CreateFileIO(instance);
23 }
24
25 PP_Bool IsFileIO(PP_Resource resource) {
26 EnterResource<PPB_FileIO_API> enter(resource, false);
27 return PP_FromBool(enter.succeeded());
28 }
29
30 int32_t Open(PP_Resource file_io,
31 PP_Resource file_ref,
32 int32_t open_flags,
33 PP_CompletionCallback callback) {
34 EnterResource<PPB_FileIO_API> enter(file_io, true);
35 if (enter.failed())
36 return PP_ERROR_BADRESOURCE;
37 return enter.object()->Open(file_ref, open_flags, callback);
38 }
39
40 int32_t Query(PP_Resource file_io,
41 PP_FileInfo_Dev* info,
42 PP_CompletionCallback callback) {
43 EnterResource<PPB_FileIO_API> enter(file_io, true);
44 if (enter.failed())
45 return PP_ERROR_BADRESOURCE;
46 return enter.object()->Query(info, callback);
47 }
48
49 int32_t Touch(PP_Resource file_io,
50 PP_Time last_access_time,
51 PP_Time last_modified_time,
52 PP_CompletionCallback callback) {
53 EnterResource<PPB_FileIO_API> enter(file_io, true);
54 if (enter.failed())
55 return PP_ERROR_BADRESOURCE;
56 return enter.object()->Touch(last_access_time, last_modified_time, callback);
57 }
58
59 int32_t Read(PP_Resource file_io,
60 int64_t offset,
61 char* buffer,
62 int32_t bytes_to_read,
63 PP_CompletionCallback callback) {
64 EnterResource<PPB_FileIO_API> enter(file_io, true);
65 if (enter.failed())
66 return PP_ERROR_BADRESOURCE;
67 return enter.object()->Read(offset, buffer, bytes_to_read, callback);
68 }
69
70 int32_t Write(PP_Resource file_io,
71 int64_t offset,
72 const char* buffer,
73 int32_t bytes_to_write,
74 PP_CompletionCallback callback) {
75 EnterResource<PPB_FileIO_API> enter(file_io, true);
76 if (enter.failed())
77 return PP_ERROR_BADRESOURCE;
78 return enter.object()->Write(offset, buffer, bytes_to_write, callback);
79 }
80
81 int32_t SetLength(PP_Resource file_io,
82 int64_t length,
83 PP_CompletionCallback callback) {
84 EnterResource<PPB_FileIO_API> enter(file_io, true);
85 if (enter.failed())
86 return PP_ERROR_BADRESOURCE;
87 return enter.object()->SetLength(length, callback);
88 }
89
90 int32_t Flush(PP_Resource file_io,
91 PP_CompletionCallback callback) {
92 EnterResource<PPB_FileIO_API> enter(file_io, true);
93 if (enter.failed())
94 return PP_ERROR_BADRESOURCE;
95 return enter.object()->Flush(callback);
96 }
97
98 void Close(PP_Resource file_io) {
99 EnterResource<PPB_FileIO_API> enter(file_io, true);
100 if (enter.succeeded())
101 enter.object()->Close();
102 }
103
104 const PPB_FileIO_Dev g_ppb_file_io_thunk = {
105 &Create,
106 &IsFileIO,
107 &Open,
108 &Query,
109 &Touch,
110 &Read,
111 &Write,
112 &SetLength,
113 &Flush,
114 &Close
115 };
116
117 } // namespace
118
119 const PPB_FileIO_Dev* GetPPB_FileIO_Thunk() {
120 return &g_ppb_file_io_thunk;
121 }
122
123 } // namespace thunk
124 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698