| 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 #ifndef NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_FILE_IO_H_ | |
| 8 #define NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_FILE_IO_H_ | |
| 9 | |
| 10 #include "native_client/src/include/nacl_macros.h" | |
| 11 #include "native_client/src/include/portability_io.h" | |
| 12 #include "native_client/tests/fake_browser_ppapi/fake_resource.h" | |
| 13 #include "ppapi/c/dev/ppb_file_io_dev.h" | |
| 14 | |
| 15 namespace fake_browser_ppapi { | |
| 16 | |
| 17 // Implements the PPB_FileIO_Dev interface. | |
| 18 class FileIO : public Resource { | |
| 19 public: | |
| 20 explicit FileIO(PP_Instance instance_id) | |
| 21 : instance_id_(instance_id), file_desc_(NACL_NO_FILE_DESC) {} | |
| 22 ~FileIO() { | |
| 23 // This crashes on a Mac with: | |
| 24 // Program received signal EXC_BAD_ACCESS, Could not access memory. | |
| 25 // Reason: KERN_INVALID_ADDRESS at address: 0x00235e0e | |
| 26 #if !defined(NACL_OSX) | |
| 27 CLOSE(file_desc_); | |
| 28 #endif | |
| 29 } | |
| 30 | |
| 31 FileIO* AsFileIO() { return this; } | |
| 32 | |
| 33 void set_file_desc(int32_t file_desc) { file_desc_ = file_desc; } | |
| 34 int32_t file_desc() const { return file_desc_; } | |
| 35 | |
| 36 // Return an interface pointer usable by PPAPI. | |
| 37 static const PPB_FileIO_Dev* GetInterface(); | |
| 38 | |
| 39 private: | |
| 40 PP_Instance instance_id_; | |
| 41 int32_t file_desc_; | |
| 42 | |
| 43 NACL_DISALLOW_COPY_AND_ASSIGN(FileIO); | |
| 44 }; | |
| 45 | |
| 46 } // namespace fake_browser_ppapi | |
| 47 | |
| 48 #endif // NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_FILE_IO_H_ | |
| OLD | NEW |