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

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

Issue 9113044: Convert to new enter method (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: PATCH DESCRIPTIONS ARE A STUPID WASTE OF TIME Created 8 years, 10 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
« no previous file with comments | « ppapi/thunk/ppb_file_chooser_thunk.cc ('k') | ppapi/thunk/ppb_file_io_trusted_thunk.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 #include "ppapi/c/pp_completion_callback.h" 5 #include "ppapi/c/pp_completion_callback.h"
6 #include "ppapi/c/pp_errors.h" 6 #include "ppapi/c/pp_errors.h"
7 #include "ppapi/thunk/common.h"
8 #include "ppapi/thunk/enter.h" 7 #include "ppapi/thunk/enter.h"
9 #include "ppapi/thunk/thunk.h" 8 #include "ppapi/thunk/thunk.h"
10 #include "ppapi/thunk/ppb_file_io_api.h" 9 #include "ppapi/thunk/ppb_file_io_api.h"
11 #include "ppapi/thunk/resource_creation_api.h" 10 #include "ppapi/thunk/resource_creation_api.h"
12 11
13 namespace ppapi { 12 namespace ppapi {
14 namespace thunk { 13 namespace thunk {
15 14
16 namespace { 15 namespace {
17 16
17 typedef EnterResource<PPB_FileIO_API> EnterFileIO;
18
18 PP_Resource Create(PP_Instance instance) { 19 PP_Resource Create(PP_Instance instance) {
19 EnterFunction<ResourceCreationAPI> enter(instance, true); 20 EnterResourceCreation enter(instance);
20 if (enter.failed()) 21 if (enter.failed())
21 return 0; 22 return 0;
22 return enter.functions()->CreateFileIO(instance); 23 return enter.functions()->CreateFileIO(instance);
23 } 24 }
24 25
25 PP_Bool IsFileIO(PP_Resource resource) { 26 PP_Bool IsFileIO(PP_Resource resource) {
26 EnterResource<PPB_FileIO_API> enter(resource, false); 27 EnterFileIO enter(resource, false);
27 return PP_FromBool(enter.succeeded()); 28 return PP_FromBool(enter.succeeded());
28 } 29 }
29 30
30 int32_t Open(PP_Resource file_io, 31 int32_t Open(PP_Resource file_io,
31 PP_Resource file_ref, 32 PP_Resource file_ref,
32 int32_t open_flags, 33 int32_t open_flags,
33 PP_CompletionCallback callback) { 34 PP_CompletionCallback callback) {
34 EnterResource<PPB_FileIO_API> enter(file_io, true); 35 EnterFileIO enter(file_io, callback, true);
35 if (enter.failed()) 36 if (enter.failed())
36 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 37 return enter.retval();
37 int32_t result = enter.object()->Open(file_ref, open_flags, callback); 38 return enter.SetResult(enter.object()->Open(file_ref, open_flags, callback));
38 return MayForceCallback(callback, result);
39 } 39 }
40 40
41 int32_t Query(PP_Resource file_io, 41 int32_t Query(PP_Resource file_io,
42 PP_FileInfo* info, 42 PP_FileInfo* info,
43 PP_CompletionCallback callback) { 43 PP_CompletionCallback callback) {
44 EnterResource<PPB_FileIO_API> enter(file_io, true); 44 EnterFileIO enter(file_io, callback, true);
45 if (enter.failed()) 45 if (enter.failed())
46 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 46 return enter.retval();
47 int32_t result = enter.object()->Query(info, callback); 47 return enter.SetResult(enter.object()->Query(info, callback));
48 return MayForceCallback(callback, result);
49 } 48 }
50 49
51 int32_t Touch(PP_Resource file_io, 50 int32_t Touch(PP_Resource file_io,
52 PP_Time last_access_time, 51 PP_Time last_access_time,
53 PP_Time last_modified_time, 52 PP_Time last_modified_time,
54 PP_CompletionCallback callback) { 53 PP_CompletionCallback callback) {
55 EnterResource<PPB_FileIO_API> enter(file_io, true); 54 EnterFileIO enter(file_io, callback, true);
56 if (enter.failed()) 55 if (enter.failed())
57 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 56 return enter.retval();
58 int32_t result = enter.object()->Touch(last_access_time, last_modified_time, 57 return enter.SetResult(enter.object()->Touch(
59 callback); 58 last_access_time, last_modified_time, callback));
60 return MayForceCallback(callback, result);
61 } 59 }
62 60
63 int32_t Read(PP_Resource file_io, 61 int32_t Read(PP_Resource file_io,
64 int64_t offset, 62 int64_t offset,
65 char* buffer, 63 char* buffer,
66 int32_t bytes_to_read, 64 int32_t bytes_to_read,
67 PP_CompletionCallback callback) { 65 PP_CompletionCallback callback) {
68 EnterResource<PPB_FileIO_API> enter(file_io, true); 66 EnterFileIO enter(file_io, callback, true);
69 if (enter.failed()) 67 if (enter.failed())
70 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 68 return enter.retval();
71 int32_t result = enter.object()->Read(offset, buffer, bytes_to_read, 69 return enter.SetResult(enter.object()->Read(offset, buffer, bytes_to_read,
72 callback); 70 callback));
73 return MayForceCallback(callback, result);
74 } 71 }
75 72
76 int32_t Write(PP_Resource file_io, 73 int32_t Write(PP_Resource file_io,
77 int64_t offset, 74 int64_t offset,
78 const char* buffer, 75 const char* buffer,
79 int32_t bytes_to_write, 76 int32_t bytes_to_write,
80 PP_CompletionCallback callback) { 77 PP_CompletionCallback callback) {
81 EnterResource<PPB_FileIO_API> enter(file_io, true); 78 EnterFileIO enter(file_io, callback, true);
82 if (enter.failed()) 79 if (enter.failed())
83 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 80 return enter.retval();
84 int32_t result = enter.object()->Write(offset, buffer, bytes_to_write, 81 return enter.SetResult(enter.object()->Write(offset, buffer, bytes_to_write,
85 callback); 82 callback));
86 return MayForceCallback(callback, result);
87 } 83 }
88 84
89 int32_t SetLength(PP_Resource file_io, 85 int32_t SetLength(PP_Resource file_io,
90 int64_t length, 86 int64_t length,
91 PP_CompletionCallback callback) { 87 PP_CompletionCallback callback) {
92 EnterResource<PPB_FileIO_API> enter(file_io, true); 88 EnterFileIO enter(file_io, callback, true);
93 if (enter.failed()) 89 if (enter.failed())
94 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 90 return enter.retval();
95 int32_t result = enter.object()->SetLength(length, callback); 91 return enter.SetResult(enter.object()->SetLength(length, callback));
96 return MayForceCallback(callback, result);
97 } 92 }
98 93
99 int32_t Flush(PP_Resource file_io, 94 int32_t Flush(PP_Resource file_io,
100 PP_CompletionCallback callback) { 95 PP_CompletionCallback callback) {
101 EnterResource<PPB_FileIO_API> enter(file_io, true); 96 EnterFileIO enter(file_io, callback, true);
102 if (enter.failed()) 97 if (enter.failed())
103 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); 98 return enter.retval();
104 int32_t result = enter.object()->Flush(callback); 99 return enter.SetResult(enter.object()->Flush(callback));
105 return MayForceCallback(callback, result);
106 } 100 }
107 101
108 void Close(PP_Resource file_io) { 102 void Close(PP_Resource file_io) {
109 EnterResource<PPB_FileIO_API> enter(file_io, true); 103 EnterFileIO enter(file_io, true);
110 if (enter.succeeded()) 104 if (enter.succeeded())
111 enter.object()->Close(); 105 enter.object()->Close();
112 } 106 }
113 107
114 const PPB_FileIO g_ppb_file_io_thunk = { 108 const PPB_FileIO g_ppb_file_io_thunk = {
115 &Create, 109 &Create,
116 &IsFileIO, 110 &IsFileIO,
117 &Open, 111 &Open,
118 &Query, 112 &Query,
119 &Touch, 113 &Touch,
120 &Read, 114 &Read,
121 &Write, 115 &Write,
122 &SetLength, 116 &SetLength,
123 &Flush, 117 &Flush,
124 &Close 118 &Close
125 }; 119 };
126 120
127 } // namespace 121 } // namespace
128 122
129 const PPB_FileIO_1_0* GetPPB_FileIO_1_0_Thunk() { 123 const PPB_FileIO_1_0* GetPPB_FileIO_1_0_Thunk() {
130 return &g_ppb_file_io_thunk; 124 return &g_ppb_file_io_thunk;
131 } 125 }
132 126
133 } // namespace thunk 127 } // namespace thunk
134 } // namespace ppapi 128 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_file_chooser_thunk.cc ('k') | ppapi/thunk/ppb_file_io_trusted_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698