| 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 <cstring> |
| 6 |
| 7 #include "base/platform_file.h" |
| 5 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 6 #include "ppapi/c/private/ppb_flash_file.h" | 9 #include "ppapi/c/private/ppb_flash_file.h" |
| 7 #include "ppapi/thunk/enter.h" | 10 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/ppb_flash_api.h" | 11 #include "ppapi/thunk/ppb_flash_api.h" |
| 9 #include "ppapi/thunk/ppb_instance_api.h" | 12 #include "ppapi/thunk/ppb_instance_api.h" |
| 10 #include "ppapi/thunk/thunk.h" | 13 #include "ppapi/thunk/thunk.h" |
| 11 | 14 |
| 12 namespace ppapi { | 15 namespace ppapi { |
| 13 namespace thunk { | 16 namespace thunk { |
| 14 | 17 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 EnterInstance enter(instance); | 83 EnterInstance enter(instance); |
| 81 if (enter.failed()) | 84 if (enter.failed()) |
| 82 return PP_ERROR_BADARGUMENT; | 85 return PP_ERROR_BADARGUMENT; |
| 83 return enter.functions()->GetFlashAPI()->GetDirContents(instance, path, | 86 return enter.functions()->GetFlashAPI()->GetDirContents(instance, path, |
| 84 contents); | 87 contents); |
| 85 } | 88 } |
| 86 | 89 |
| 87 void FreeDirContents(PP_Instance instance, | 90 void FreeDirContents(PP_Instance instance, |
| 88 PP_DirContents_Dev* contents) { | 91 PP_DirContents_Dev* contents) { |
| 89 EnterInstance enter(instance); | 92 EnterInstance enter(instance); |
| 90 if (enter.succeeded()) { | 93 if (enter.succeeded()) |
| 91 return enter.functions()->GetFlashAPI()->FreeDirContents(instance, | 94 enter.functions()->GetFlashAPI()->FreeDirContents(instance, contents); |
| 92 contents); | |
| 93 } | |
| 94 } | 95 } |
| 95 | 96 |
| 96 const PPB_Flash_File_ModuleLocal g_ppb_flash_file_modulelocal_thunk = { | 97 int32_t CreateTemporaryFile(PP_Instance instance, |
| 98 const char* dir_path, |
| 99 PP_FileHandle* file, |
| 100 char* file_name_buffer, |
| 101 uint32_t file_name_buffer_size) { |
| 102 EnterInstance enter(instance); |
| 103 if (enter.failed()) |
| 104 return PP_ERROR_BADARGUMENT; |
| 105 |
| 106 std::string file_name; |
| 107 PP_FileHandle file_handle = PP_kInvalidFileHandle; |
| 108 int32_t result = enter.functions()->GetFlashAPI()->CreateTemporaryFile( |
| 109 instance, dir_path, &file_handle, &file_name); |
| 110 if (result == PP_OK) { |
| 111 if (file_name.size() < file_name_buffer_size) { |
| 112 strcpy(file_name_buffer, file_name.c_str()); |
| 113 *file = file_handle; |
| 114 } else { |
| 115 result = PP_ERROR_NOMEMORY; |
| 116 } |
| 117 } |
| 118 if (result != PP_OK && file_handle != PP_kInvalidFileHandle) |
| 119 base::ClosePlatformFile(file_handle); |
| 120 |
| 121 return result; |
| 122 } |
| 123 |
| 124 const PPB_Flash_File_ModuleLocal_2_0 g_ppb_flash_file_modulelocal_thunk_2_0 = { |
| 97 &CreateThreadAdapterForInstance, | 125 &CreateThreadAdapterForInstance, |
| 98 &ClearThreadAdapterForInstance, | 126 &ClearThreadAdapterForInstance, |
| 99 &OpenFile, | 127 &OpenFile, |
| 100 &RenameFile, | 128 &RenameFile, |
| 101 &DeleteFileOrDir, | 129 &DeleteFileOrDir, |
| 102 &CreateDir, | 130 &CreateDir, |
| 103 &QueryFile, | 131 &QueryFile, |
| 104 &GetDirContents, | 132 &GetDirContents, |
| 105 &FreeDirContents | 133 &FreeDirContents |
| 106 }; | 134 }; |
| 107 | 135 |
| 136 const PPB_Flash_File_ModuleLocal_3_0 g_ppb_flash_file_modulelocal_thunk_3_0 = { |
| 137 &CreateThreadAdapterForInstance, |
| 138 &ClearThreadAdapterForInstance, |
| 139 &OpenFile, |
| 140 &RenameFile, |
| 141 &DeleteFileOrDir, |
| 142 &CreateDir, |
| 143 &QueryFile, |
| 144 &GetDirContents, |
| 145 &FreeDirContents, |
| 146 &CreateTemporaryFile |
| 147 }; |
| 148 |
| 108 } // namespace | 149 } // namespace |
| 109 | 150 |
| 110 const PPB_Flash_File_ModuleLocal* GetPPB_Flash_File_ModuleLocal_Thunk() { | 151 const PPB_Flash_File_ModuleLocal_2_0* |
| 111 return &g_ppb_flash_file_modulelocal_thunk; | 152 GetPPB_Flash_File_ModuleLocal_2_0_Thunk() { |
| 153 return &g_ppb_flash_file_modulelocal_thunk_2_0; |
| 154 } |
| 155 |
| 156 const PPB_Flash_File_ModuleLocal_3_0* |
| 157 GetPPB_Flash_File_ModuleLocal_3_0_Thunk() { |
| 158 return &g_ppb_flash_file_modulelocal_thunk_3_0; |
| 112 } | 159 } |
| 113 | 160 |
| 114 } // namespace thunk | 161 } // namespace thunk |
| 115 } // namespace ppapi | 162 } // namespace ppapi |
| OLD | NEW |