| Index: ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc
|
| diff --git a/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc b/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc
|
| index 6338779f5d3c2eb5ca8bca9a91191f8fee8e877c..d417d5ddb10e62a97660eaadf3712668ca9b6c17 100644
|
| --- a/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc
|
| +++ b/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc
|
| @@ -2,6 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include <cstring>
|
| +
|
| +#include "base/platform_file.h"
|
| #include "ppapi/c/pp_errors.h"
|
| #include "ppapi/c/private/ppb_flash_file.h"
|
| #include "ppapi/thunk/enter.h"
|
| @@ -87,13 +90,38 @@ int32_t GetDirContents(PP_Instance instance,
|
| void FreeDirContents(PP_Instance instance,
|
| PP_DirContents_Dev* contents) {
|
| EnterInstance enter(instance);
|
| - if (enter.succeeded()) {
|
| - return enter.functions()->GetFlashAPI()->FreeDirContents(instance,
|
| - contents);
|
| + if (enter.succeeded())
|
| + enter.functions()->GetFlashAPI()->FreeDirContents(instance, contents);
|
| +}
|
| +
|
| +int32_t CreateTemporaryFile(PP_Instance instance,
|
| + const char* dir_path,
|
| + PP_FileHandle* file,
|
| + char* file_name_buffer,
|
| + uint32_t file_name_buffer_size) {
|
| + EnterInstance enter(instance);
|
| + if (enter.failed())
|
| + return PP_ERROR_BADARGUMENT;
|
| +
|
| + std::string file_name;
|
| + PP_FileHandle file_handle = PP_kInvalidFileHandle;
|
| + int32_t result = enter.functions()->GetFlashAPI()->CreateTemporaryFile(
|
| + instance, dir_path, &file_handle, &file_name);
|
| + if (result == PP_OK) {
|
| + if (file_name.size() < file_name_buffer_size) {
|
| + strcpy(file_name_buffer, file_name.c_str());
|
| + *file = file_handle;
|
| + } else {
|
| + result = PP_ERROR_NOMEMORY;
|
| + }
|
| }
|
| + if (result != PP_OK && file_handle != PP_kInvalidFileHandle)
|
| + base::ClosePlatformFile(file_handle);
|
| +
|
| + return result;
|
| }
|
|
|
| -const PPB_Flash_File_ModuleLocal g_ppb_flash_file_modulelocal_thunk = {
|
| +const PPB_Flash_File_ModuleLocal_2_0 g_ppb_flash_file_modulelocal_thunk_2_0 = {
|
| &CreateThreadAdapterForInstance,
|
| &ClearThreadAdapterForInstance,
|
| &OpenFile,
|
| @@ -105,10 +133,29 @@ const PPB_Flash_File_ModuleLocal g_ppb_flash_file_modulelocal_thunk = {
|
| &FreeDirContents
|
| };
|
|
|
| +const PPB_Flash_File_ModuleLocal_3_0 g_ppb_flash_file_modulelocal_thunk_3_0 = {
|
| + &CreateThreadAdapterForInstance,
|
| + &ClearThreadAdapterForInstance,
|
| + &OpenFile,
|
| + &RenameFile,
|
| + &DeleteFileOrDir,
|
| + &CreateDir,
|
| + &QueryFile,
|
| + &GetDirContents,
|
| + &FreeDirContents,
|
| + &CreateTemporaryFile
|
| +};
|
| +
|
| } // namespace
|
|
|
| -const PPB_Flash_File_ModuleLocal* GetPPB_Flash_File_ModuleLocal_Thunk() {
|
| - return &g_ppb_flash_file_modulelocal_thunk;
|
| +const PPB_Flash_File_ModuleLocal_2_0*
|
| + GetPPB_Flash_File_ModuleLocal_2_0_Thunk() {
|
| + return &g_ppb_flash_file_modulelocal_thunk_2_0;
|
| +}
|
| +
|
| +const PPB_Flash_File_ModuleLocal_3_0*
|
| + GetPPB_Flash_File_ModuleLocal_3_0_Thunk() {
|
| + return &g_ppb_flash_file_modulelocal_thunk_3_0;
|
| }
|
|
|
| } // namespace thunk
|
|
|