| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2010 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can | |
| 4 * be found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 #include "native_client/tests/fake_browser_ppapi/fake_file_io_trusted.h" | |
| 8 | |
| 9 #include "native_client/src/include/nacl_macros.h" | |
| 10 #include "native_client/src/include/portability.h" | |
| 11 | |
| 12 #include "native_client/tests/fake_browser_ppapi/fake_file_io.h" | |
| 13 #include "native_client/tests/fake_browser_ppapi/fake_resource.h" | |
| 14 #include "native_client/tests/fake_browser_ppapi/utility.h" | |
| 15 | |
| 16 #include "ppapi/c/pp_errors.h" | |
| 17 #include "ppapi/c/pp_completion_callback.h" | |
| 18 #include "ppapi/c/pp_resource.h" | |
| 19 | |
| 20 using fake_browser_ppapi::DebugPrintf; | |
| 21 | |
| 22 namespace fake_browser_ppapi { | |
| 23 | |
| 24 namespace { | |
| 25 | |
| 26 int32_t GetOSFileDescriptor(PP_Resource file_io_id) { | |
| 27 DebugPrintf("FileIOTrusted::GetOSFileDescriptor: file_io_id=%"NACL_PRId32"\n", | |
| 28 file_io_id); | |
| 29 FileIO* file_io = GetResource(file_io_id)->AsFileIO(); | |
| 30 if (file_io == NULL) | |
| 31 return NACL_NO_FILE_DESC; | |
| 32 | |
| 33 int32_t posix_file_desc = file_io->file_desc(); | |
| 34 | |
| 35 #if NACL_WINDOWS | |
| 36 // On Windows, return the underlying HANDLE to mimic the behavior | |
| 37 // of PPAPI in Chrome. Windows HANDLEs can be safely trunated to int32_t. | |
| 38 posix_file_desc = static_cast<int32_t>(_get_osfhandle(posix_file_desc)); | |
| 39 #endif | |
| 40 | |
| 41 return posix_file_desc; | |
| 42 } | |
| 43 | |
| 44 int32_t WillWrite(PP_Resource file_io_id, | |
| 45 int64_t offset, | |
| 46 int32_t bytes_to_write, | |
| 47 struct PP_CompletionCallback callback) { | |
| 48 DebugPrintf("FileIOTrusted::WillWrite: file_io_id=%"NACL_PRId32"\n", | |
| 49 file_io_id); | |
| 50 UNREFERENCED_PARAMETER(offset); | |
| 51 UNREFERENCED_PARAMETER(bytes_to_write); | |
| 52 UNREFERENCED_PARAMETER(callback); | |
| 53 NACL_UNIMPLEMENTED(); | |
| 54 return PP_ERROR_FAILED; | |
| 55 } | |
| 56 | |
| 57 int32_t WillSetLength(PP_Resource file_io_id, | |
| 58 int64_t length, | |
| 59 struct PP_CompletionCallback callback) { | |
| 60 DebugPrintf("FileIOTrusted::WillSetLength: file_io_id=%"NACL_PRId32"\n", | |
| 61 file_io_id); | |
| 62 UNREFERENCED_PARAMETER(length); | |
| 63 UNREFERENCED_PARAMETER(callback); | |
| 64 NACL_UNIMPLEMENTED(); | |
| 65 return PP_ERROR_FAILED; | |
| 66 } | |
| 67 | |
| 68 } // namespace | |
| 69 | |
| 70 | |
| 71 const PPB_FileIOTrusted_Dev* FileIOTrusted::GetInterface() { | |
| 72 static const PPB_FileIOTrusted_Dev file_io_trusted_interface = { | |
| 73 GetOSFileDescriptor, | |
| 74 WillWrite, | |
| 75 WillSetLength | |
| 76 }; | |
| 77 return &file_io_trusted_interface; | |
| 78 } | |
| 79 | |
| 80 } // namespace fake_browser_ppapi | |
| OLD | NEW |