| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pp_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
| 6 #include "ppapi/c/private/ppb_flash_file.h" | 6 #include "ppapi/c/private/ppb_flash_file.h" |
| 7 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/ppb_flash_api.h" | 8 #include "ppapi/thunk/ppb_flash_file_api.h" |
| 9 #include "ppapi/thunk/ppb_instance_api.h" | |
| 10 #include "ppapi/thunk/thunk.h" | 9 #include "ppapi/thunk/thunk.h" |
| 11 | 10 |
| 12 namespace ppapi { | 11 namespace ppapi { |
| 13 namespace thunk { | 12 namespace thunk { |
| 14 | 13 |
| 15 namespace { | 14 namespace { |
| 16 | 15 |
| 17 bool CreateThreadAdapterForInstance(PP_Instance instance) { | 16 bool CreateThreadAdapterForInstance(PP_Instance instance) { |
| 18 EnterInstance enter(instance); | 17 return true; |
| 19 if (enter.failed()) | |
| 20 return false; | |
| 21 return enter.functions()->GetFlashAPI()->CreateThreadAdapterForInstance( | |
| 22 instance); | |
| 23 } | 18 } |
| 24 | 19 |
| 25 void ClearThreadAdapterForInstance(PP_Instance instance) { | 20 void ClearThreadAdapterForInstance(PP_Instance instance) { |
| 26 EnterInstance enter(instance); | |
| 27 if (enter.succeeded()) { | |
| 28 return enter.functions()->GetFlashAPI()->ClearThreadAdapterForInstance( | |
| 29 instance); | |
| 30 } | |
| 31 } | 21 } |
| 32 | 22 |
| 33 int32_t OpenFile(PP_Instance instance, | 23 int32_t OpenFile(PP_Instance instance, |
| 34 const char* path, | 24 const char* path, |
| 35 int32_t mode, | 25 int32_t mode, |
| 36 PP_FileHandle* file) { | 26 PP_FileHandle* file) { |
| 37 EnterInstance enter(instance); | 27 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); |
| 38 if (enter.failed()) | 28 if (enter.failed()) |
| 39 return PP_ERROR_BADARGUMENT; | 29 return PP_ERROR_BADARGUMENT; |
| 40 return enter.functions()->GetFlashAPI()->OpenFile(instance, path, mode, file); | 30 return enter.functions()->OpenFile(instance, path, mode, file); |
| 41 } | 31 } |
| 42 | 32 |
| 43 int32_t RenameFile(PP_Instance instance, | 33 int32_t RenameFile(PP_Instance instance, |
| 44 const char* path_from, | 34 const char* path_from, |
| 45 const char* path_to) { | 35 const char* path_to) { |
| 46 EnterInstance enter(instance); | 36 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); |
| 47 if (enter.failed()) | 37 if (enter.failed()) |
| 48 return PP_ERROR_BADARGUMENT; | 38 return PP_ERROR_BADARGUMENT; |
| 49 return enter.functions()->GetFlashAPI()->RenameFile(instance, | 39 return enter.functions()->RenameFile(instance, path_from, path_to); |
| 50 path_from, path_to); | |
| 51 } | 40 } |
| 52 | 41 |
| 53 int32_t DeleteFileOrDir(PP_Instance instance, | 42 int32_t DeleteFileOrDir(PP_Instance instance, |
| 54 const char* path, | 43 const char* path, |
| 55 PP_Bool recursive) { | 44 PP_Bool recursive) { |
| 56 EnterInstance enter(instance); | 45 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); |
| 57 if (enter.failed()) | 46 if (enter.failed()) |
| 58 return PP_ERROR_BADARGUMENT; | 47 return PP_ERROR_BADARGUMENT; |
| 59 return enter.functions()->GetFlashAPI()->DeleteFileOrDir(instance, path, | 48 return enter.functions()->DeleteFileOrDir(instance, path, recursive); |
| 60 recursive); | |
| 61 } | 49 } |
| 62 | 50 |
| 63 int32_t CreateDir(PP_Instance instance, const char* path) { | 51 int32_t CreateDir(PP_Instance instance, const char* path) { |
| 64 EnterInstance enter(instance); | 52 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); |
| 65 if (enter.failed()) | 53 if (enter.failed()) |
| 66 return PP_ERROR_BADARGUMENT; | 54 return PP_ERROR_BADARGUMENT; |
| 67 return enter.functions()->GetFlashAPI()->CreateDir(instance, path); | 55 return enter.functions()->CreateDir(instance, path); |
| 68 } | 56 } |
| 69 | 57 |
| 70 int32_t QueryFile(PP_Instance instance, const char* path, PP_FileInfo* info) { | 58 int32_t QueryFile(PP_Instance instance, const char* path, PP_FileInfo* info) { |
| 71 EnterInstance enter(instance); | 59 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); |
| 72 if (enter.failed()) | 60 if (enter.failed()) |
| 73 return PP_ERROR_BADARGUMENT; | 61 return PP_ERROR_BADARGUMENT; |
| 74 return enter.functions()->GetFlashAPI()->QueryFile(instance, path, info); | 62 return enter.functions()->QueryFile(instance, path, info); |
| 75 } | 63 } |
| 76 | 64 |
| 77 int32_t GetDirContents(PP_Instance instance, | 65 int32_t GetDirContents(PP_Instance instance, |
| 78 const char* path, | 66 const char* path, |
| 79 PP_DirContents_Dev** contents) { | 67 PP_DirContents_Dev** contents) { |
| 80 EnterInstance enter(instance); | 68 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); |
| 81 if (enter.failed()) | 69 if (enter.failed()) |
| 82 return PP_ERROR_BADARGUMENT; | 70 return PP_ERROR_BADARGUMENT; |
| 83 return enter.functions()->GetFlashAPI()->GetDirContents(instance, path, | 71 return enter.functions()->GetDirContents(instance, path, contents); |
| 84 contents); | |
| 85 } | 72 } |
| 86 | 73 |
| 87 void FreeDirContents(PP_Instance instance, | 74 void FreeDirContents(PP_Instance instance, |
| 88 PP_DirContents_Dev* contents) { | 75 PP_DirContents_Dev* contents) { |
| 89 EnterInstance enter(instance); | 76 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); |
| 90 if (enter.succeeded()) | 77 if (enter.succeeded()) |
| 91 enter.functions()->GetFlashAPI()->FreeDirContents(instance, contents); | 78 enter.functions()->FreeDirContents(instance, contents); |
| 92 } | 79 } |
| 93 | 80 |
| 94 int32_t CreateTemporaryFile(PP_Instance instance, PP_FileHandle* file) { | 81 int32_t CreateTemporaryFile(PP_Instance instance, PP_FileHandle* file) { |
| 95 EnterInstance enter(instance); | 82 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); |
| 96 if (enter.failed()) | 83 if (enter.failed()) |
| 97 return PP_ERROR_BADARGUMENT; | 84 return PP_ERROR_BADARGUMENT; |
| 98 | 85 |
| 99 *file = PP_kInvalidFileHandle; | 86 *file = PP_kInvalidFileHandle; |
| 100 return enter.functions()->GetFlashAPI()->CreateTemporaryFile(instance, file); | 87 return enter.functions()->CreateTemporaryFile(instance, file); |
| 101 } | 88 } |
| 102 | 89 |
| 103 const PPB_Flash_File_ModuleLocal_2_0 g_ppb_flash_file_modulelocal_thunk_2_0 = { | 90 const PPB_Flash_File_ModuleLocal_2_0 g_ppb_flash_file_modulelocal_thunk_2_0 = { |
| 104 &CreateThreadAdapterForInstance, | 91 &CreateThreadAdapterForInstance, |
| 105 &ClearThreadAdapterForInstance, | 92 &ClearThreadAdapterForInstance, |
| 106 &OpenFile, | 93 &OpenFile, |
| 107 &RenameFile, | 94 &RenameFile, |
| 108 &DeleteFileOrDir, | 95 &DeleteFileOrDir, |
| 109 &CreateDir, | 96 &CreateDir, |
| 110 &QueryFile, | 97 &QueryFile, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 132 return &g_ppb_flash_file_modulelocal_thunk_2_0; | 119 return &g_ppb_flash_file_modulelocal_thunk_2_0; |
| 133 } | 120 } |
| 134 | 121 |
| 135 const PPB_Flash_File_ModuleLocal_3_0* | 122 const PPB_Flash_File_ModuleLocal_3_0* |
| 136 GetPPB_Flash_File_ModuleLocal_3_0_Thunk() { | 123 GetPPB_Flash_File_ModuleLocal_3_0_Thunk() { |
| 137 return &g_ppb_flash_file_modulelocal_thunk_3_0; | 124 return &g_ppb_flash_file_modulelocal_thunk_3_0; |
| 138 } | 125 } |
| 139 | 126 |
| 140 } // namespace thunk | 127 } // namespace thunk |
| 141 } // namespace ppapi | 128 } // namespace ppapi |
| OLD | NEW |