| 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/cpp/trusted/file_io_trusted.h" |
| 6 |
| 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/c/trusted/ppb_file_io_trusted.h" |
| 9 #include "ppapi/cpp/completion_callback.h" |
| 10 #include "ppapi/cpp/file_io.h" |
| 11 #include "ppapi/cpp/module_impl.h" |
| 12 |
| 13 namespace pp { |
| 14 |
| 15 namespace { |
| 16 |
| 17 template <> const char* interface_name<PPB_FileIOTrusted>() { |
| 18 return PPB_FILEIOTRUSTED_INTERFACE_0_4; |
| 19 } |
| 20 |
| 21 } // namespace |
| 22 |
| 23 FileIO_Trusted::FileIO_Trusted() { |
| 24 } |
| 25 |
| 26 int32_t FileIO_Trusted::GetOSFileDescriptor(const FileIO& file_io) { |
| 27 const int32_t kInvalidOSFileDescriptor = -1; |
| 28 if (!has_interface<PPB_FileIOTrusted>()) |
| 29 return kInvalidOSFileDescriptor; |
| 30 return get_interface<PPB_FileIOTrusted>()->GetOSFileDescriptor( |
| 31 file_io.pp_resource()); |
| 32 } |
| 33 |
| 34 int32_t FileIO_Trusted::WillWrite(const FileIO& file_io, |
| 35 int64_t offset, |
| 36 int32_t bytes_to_write, |
| 37 const CompletionCallback& callback) { |
| 38 if (!has_interface<PPB_FileIOTrusted>()) |
| 39 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 40 return get_interface<PPB_FileIOTrusted>()->WillWrite( |
| 41 file_io.pp_resource(), offset, bytes_to_write, |
| 42 callback.pp_completion_callback()); |
| 43 } |
| 44 |
| 45 int32_t FileIO_Trusted::WillSetLength(const FileIO& file_io, |
| 46 int64_t length, |
| 47 const CompletionCallback& callback) { |
| 48 if (!has_interface<PPB_FileIOTrusted>()) |
| 49 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 50 return get_interface<PPB_FileIOTrusted>()->WillSetLength( |
| 51 file_io.pp_resource(), length, callback.pp_completion_callback()); |
| 52 } |
| 53 |
| 54 } // namespace pp |
| OLD | NEW |