| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/dev/ppb_file_io_dev.h" | |
| 6 #include "ppapi/c/pp_completion_callback.h" | 5 #include "ppapi/c/pp_completion_callback.h" |
| 7 #include "ppapi/c/pp_errors.h" | 6 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/thunk/common.h" | 7 #include "ppapi/thunk/common.h" |
| 9 #include "ppapi/thunk/enter.h" | 8 #include "ppapi/thunk/enter.h" |
| 10 #include "ppapi/thunk/thunk.h" | 9 #include "ppapi/thunk/thunk.h" |
| 11 #include "ppapi/thunk/ppb_file_io_api.h" | 10 #include "ppapi/thunk/ppb_file_io_api.h" |
| 12 #include "ppapi/thunk/resource_creation_api.h" | 11 #include "ppapi/thunk/resource_creation_api.h" |
| 13 | 12 |
| 14 namespace ppapi { | 13 namespace ppapi { |
| 15 namespace thunk { | 14 namespace thunk { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 33 int32_t open_flags, | 32 int32_t open_flags, |
| 34 PP_CompletionCallback callback) { | 33 PP_CompletionCallback callback) { |
| 35 EnterResource<PPB_FileIO_API> enter(file_io, true); | 34 EnterResource<PPB_FileIO_API> enter(file_io, true); |
| 36 if (enter.failed()) | 35 if (enter.failed()) |
| 37 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); | 36 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
| 38 int32_t result = enter.object()->Open(file_ref, open_flags, callback); | 37 int32_t result = enter.object()->Open(file_ref, open_flags, callback); |
| 39 return MayForceCallback(callback, result); | 38 return MayForceCallback(callback, result); |
| 40 } | 39 } |
| 41 | 40 |
| 42 int32_t Query(PP_Resource file_io, | 41 int32_t Query(PP_Resource file_io, |
| 43 PP_FileInfo_Dev* info, | 42 PP_FileInfo* info, |
| 44 PP_CompletionCallback callback) { | 43 PP_CompletionCallback callback) { |
| 45 EnterResource<PPB_FileIO_API> enter(file_io, true); | 44 EnterResource<PPB_FileIO_API> enter(file_io, true); |
| 46 if (enter.failed()) | 45 if (enter.failed()) |
| 47 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); | 46 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
| 48 int32_t result = enter.object()->Query(info, callback); | 47 int32_t result = enter.object()->Query(info, callback); |
| 49 return MayForceCallback(callback, result); | 48 return MayForceCallback(callback, result); |
| 50 } | 49 } |
| 51 | 50 |
| 52 int32_t Touch(PP_Resource file_io, | 51 int32_t Touch(PP_Resource file_io, |
| 53 PP_Time last_access_time, | 52 PP_Time last_access_time, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 int32_t result = enter.object()->Flush(callback); | 104 int32_t result = enter.object()->Flush(callback); |
| 106 return MayForceCallback(callback, result); | 105 return MayForceCallback(callback, result); |
| 107 } | 106 } |
| 108 | 107 |
| 109 void Close(PP_Resource file_io) { | 108 void Close(PP_Resource file_io) { |
| 110 EnterResource<PPB_FileIO_API> enter(file_io, true); | 109 EnterResource<PPB_FileIO_API> enter(file_io, true); |
| 111 if (enter.succeeded()) | 110 if (enter.succeeded()) |
| 112 enter.object()->Close(); | 111 enter.object()->Close(); |
| 113 } | 112 } |
| 114 | 113 |
| 115 const PPB_FileIO_Dev g_ppb_file_io_thunk = { | 114 const PPB_FileIO g_ppb_file_io_thunk = { |
| 116 &Create, | 115 &Create, |
| 117 &IsFileIO, | 116 &IsFileIO, |
| 118 &Open, | 117 &Open, |
| 119 &Query, | 118 &Query, |
| 120 &Touch, | 119 &Touch, |
| 121 &Read, | 120 &Read, |
| 122 &Write, | 121 &Write, |
| 123 &SetLength, | 122 &SetLength, |
| 124 &Flush, | 123 &Flush, |
| 125 &Close | 124 &Close |
| 126 }; | 125 }; |
| 127 | 126 |
| 128 } // namespace | 127 } // namespace |
| 129 | 128 |
| 130 const PPB_FileIO_Dev* GetPPB_FileIO_Thunk() { | 129 const PPB_FileIO* GetPPB_FileIO_Thunk() { |
| 131 return &g_ppb_file_io_thunk; | 130 return &g_ppb_file_io_thunk; |
| 132 } | 131 } |
| 133 | 132 |
| 134 } // namespace thunk | 133 } // namespace thunk |
| 135 } // namespace ppapi | 134 } // namespace ppapi |
| OLD | NEW |