OLD | NEW |
(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_trusted_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 int32_t GetOSFileDescriptor(PP_Resource file_io) { |
| 19 EnterResource<PPB_FileIO_API> enter(file_io, true); |
| 20 if (enter.failed()) |
| 21 return PP_ERROR_BADRESOURCE; |
| 22 return enter.object()->GetOSFileDescriptor(); |
| 23 } |
| 24 |
| 25 int32_t WillWrite(PP_Resource file_io, |
| 26 int64_t offset, |
| 27 int32_t bytes_to_write, |
| 28 PP_CompletionCallback callback) { |
| 29 EnterResource<PPB_FileIO_API> enter(file_io, true); |
| 30 if (enter.failed()) |
| 31 return PP_ERROR_BADRESOURCE; |
| 32 return enter.object()->WillWrite(offset, bytes_to_write, callback); |
| 33 } |
| 34 |
| 35 int32_t WillSetLength(PP_Resource file_io, |
| 36 int64_t length, |
| 37 PP_CompletionCallback callback) { |
| 38 EnterResource<PPB_FileIO_API> enter(file_io, true); |
| 39 if (enter.failed()) |
| 40 return PP_ERROR_BADRESOURCE; |
| 41 return enter.object()->WillSetLength(length, callback); |
| 42 } |
| 43 |
| 44 const PPB_FileIOTrusted_Dev g_ppb_file_io_trusted_thunk = { |
| 45 &GetOSFileDescriptor, |
| 46 &WillWrite, |
| 47 &WillSetLength |
| 48 }; |
| 49 |
| 50 } // namespace |
| 51 |
| 52 const PPB_FileIOTrusted_Dev* GetPPB_FileIOTrusted_Thunk() { |
| 53 return &g_ppb_file_io_trusted_thunk; |
| 54 } |
| 55 |
| 56 } // namespace thunk |
| 57 } // namespace ppapi |
OLD | NEW |