diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-30 16:19:41 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-30 16:19:41 +0000 |
commit | 724fbd317ae5ee1a22add1e0013cb3c08dfe6155 (patch) | |
tree | b8815bd91f10026f2558924185ac04935138ad4b /ppapi/thunk | |
parent | e5bbe3d1366b0fda6d68aac22f904fd72f521b59 (diff) | |
download | chromium_src-724fbd317ae5ee1a22add1e0013cb3c08dfe6155.zip chromium_src-724fbd317ae5ee1a22add1e0013cb3c08dfe6155.tar.gz chromium_src-724fbd317ae5ee1a22add1e0013cb3c08dfe6155.tar.bz2 |
Move the rest of the Flash functions to the thunk system.
This removes the manual Flash interface registration and adds them via the
interfaces_ppb_private_flash.h header. I moved File_ModulalLocal and
File_FileRef to the Flash API virtual interface which allowed me to delete
the separate proxies and stuff associated with those interfaces.
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10169040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r-- | ppapi/thunk/interfaces_ppb_private_flash.h | 23 | ||||
-rw-r--r-- | ppapi/thunk/ppb_flash_api.h | 33 | ||||
-rw-r--r-- | ppapi/thunk/ppb_flash_file_fileref_thunk.cc | 60 | ||||
-rw-r--r-- | ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc | 115 | ||||
-rw-r--r-- | ppapi/thunk/thunk.h | 7 |
5 files changed, 229 insertions, 9 deletions
diff --git a/ppapi/thunk/interfaces_ppb_private_flash.h b/ppapi/thunk/interfaces_ppb_private_flash.h index 1a96fbc..4f13d1c 100644 --- a/ppapi/thunk/interfaces_ppb_private_flash.h +++ b/ppapi/thunk/interfaces_ppb_private_flash.h @@ -8,7 +8,6 @@ #include "ppapi/thunk/interfaces_preamble.h" PROXIED_API(PPB_Flash) - PROXIED_IFACE(PPB_Flash, PPB_FLASH_INTERFACE_11_0, PPB_Flash_11) @@ -21,7 +20,6 @@ PROXIED_IFACE(PPB_Flash, PROXIED_IFACE(PPB_Flash, PPB_FLASH_INTERFACE_12_2, PPB_Flash_12_2) - PROXIED_IFACE(PPB_Flash, PPB_FLASH_CLIPBOARD_INTERFACE_3_LEGACY, PPB_Flash_Clipboard_3_0) @@ -31,5 +29,26 @@ PROXIED_IFACE(PPB_Flash, PROXIED_IFACE(PPB_Flash, PPB_FLASH_CLIPBOARD_INTERFACE_4_0, PPB_Flash_Clipboard_4_0) +PROXIED_IFACE(PPB_Flash, + PPB_FLASH_FILE_MODULELOCAL_INTERFACE, + PPB_Flash_File_ModuleLocal) +PROXIED_IFACE(PPB_Flash, + PPB_FLASH_FILE_FILEREF_INTERFACE, + PPB_Flash_File_FileRef) + +PROXIED_API(PPB_Flash_Menu) +PROXIED_IFACE(PPB_Flash_Menu, + PPB_FLASH_MENU_INTERFACE_0_2, + PPB_Flash_Menu_0_2) + +PROXIED_API(PPB_Flash_MessageLoop) +PROXIED_IFACE(PPB_Flash_MessageLoop, + PPB_FLASH_MESSAGELOOP_INTERFACE_0_1, + PPB_Flash_MessageLoop_0_1) + +// TCPSocketPrivate is defined in the normal private interfaces. +PROXIED_IFACE(PPB_TCPSocket_Private, + PPB_FLASH_TCPSOCKET_INTERFACE_0_2, + PPB_TCPSocket_Private_0_3) #include "ppapi/thunk/interfaces_postamble.h" diff --git a/ppapi/thunk/ppb_flash_api.h b/ppapi/thunk/ppb_flash_api.h index b54bba3..1760480 100644 --- a/ppapi/thunk/ppb_flash_api.h +++ b/ppapi/thunk/ppb_flash_api.h @@ -7,6 +7,7 @@ #include "ppapi/c/private/ppb_flash.h" #include "ppapi/c/private/ppb_flash_clipboard.h" +#include "ppapi/c/private/ppb_flash_file.h" #include "ppapi/thunk/ppapi_thunk_export.h" namespace ppapi { @@ -57,6 +58,38 @@ class PPAPI_THUNK_EXPORT PPB_Flash_API { const PP_Flash_Clipboard_Format formats[], const PP_Var data_items[]) = 0; + // FlashFile_ModuleLocal. + virtual bool CreateThreadAdapterForInstance(PP_Instance instance) = 0; + virtual void ClearThreadAdapterForInstance(PP_Instance instance) = 0; + virtual int32_t OpenFile(PP_Instance instance, + const char* path, + int32_t mode, + PP_FileHandle* file) = 0; + virtual int32_t RenameFile(PP_Instance instance, + const char* path_from, + const char* path_to) = 0; + virtual int32_t DeleteFileOrDir(PP_Instance instance, + const char* path, + PP_Bool recursive) = 0; + virtual int32_t CreateDir(PP_Instance instance, const char* path) = 0; + virtual int32_t QueryFile(PP_Instance instance, + const char* path, + PP_FileInfo* info) = 0; + virtual int32_t GetDirContents(PP_Instance instance, + const char* path, + PP_DirContents_Dev** contents) = 0; + virtual void FreeDirContents(PP_Instance instance, + PP_DirContents_Dev* contents) = 0; + + // FlashFile_FileRef. + virtual int32_t OpenFileRef(PP_Instance instance, + PP_Resource file_ref, + int32_t mode, + PP_FileHandle* file) = 0; + virtual int32_t QueryFileRef(PP_Instance instance, + PP_Resource file_ref, + PP_FileInfo* info) = 0; + // FlashFullscreen. virtual PP_Bool FlashIsFullscreen(PP_Instance instance) = 0; virtual PP_Bool FlashSetFullscreen(PP_Instance instance, diff --git a/ppapi/thunk/ppb_flash_file_fileref_thunk.cc b/ppapi/thunk/ppb_flash_file_fileref_thunk.cc new file mode 100644 index 0000000..2b380c7 --- /dev/null +++ b/ppapi/thunk/ppb_flash_file_fileref_thunk.cc @@ -0,0 +1,60 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_flash_file.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_file_ref_api.h" +#include "ppapi/thunk/ppb_flash_api.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +// Returns 0 on failure. +PP_Instance GetInstanceFromFileRef(PP_Resource file_ref) { + thunk::EnterResource<thunk::PPB_FileRef_API> enter(file_ref, true); + if (enter.failed()) + return 0; + return enter.resource()->pp_instance(); +} + +int32_t OpenFile(PP_Resource file_ref_id, int32_t mode, PP_FileHandle* file) { + // TODO(brettw): this function should take an instance. + // To work around this, use the PP_Instance from the resource. + PP_Instance instance = GetInstanceFromFileRef(file_ref_id); + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->OpenFileRef(instance, file_ref_id, + mode, file); +} + +int32_t QueryFile(PP_Resource file_ref_id, struct PP_FileInfo* info) { + // TODO(brettw): this function should take an instance. + // To work around this, use the PP_Instance from the resource. + PP_Instance instance = GetInstanceFromFileRef(file_ref_id); + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->QueryFileRef(instance, file_ref_id, + info); +} + +const PPB_Flash_File_FileRef g_ppb_flash_file_fileref_thunk = { + &OpenFile, + &QueryFile +}; + +} // namespace + +const PPB_Flash_File_FileRef* GetPPB_Flash_File_FileRef_Thunk() { + return &g_ppb_flash_file_fileref_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc b/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc new file mode 100644 index 0000000..6338779 --- /dev/null +++ b/ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc @@ -0,0 +1,115 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_flash_file.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_flash_api.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +bool CreateThreadAdapterForInstance(PP_Instance instance) { + EnterInstance enter(instance); + if (enter.failed()) + return false; + return enter.functions()->GetFlashAPI()->CreateThreadAdapterForInstance( + instance); +} + +void ClearThreadAdapterForInstance(PP_Instance instance) { + EnterInstance enter(instance); + if (enter.succeeded()) { + return enter.functions()->GetFlashAPI()->ClearThreadAdapterForInstance( + instance); + } +} + +int32_t OpenFile(PP_Instance instance, + const char* path, + int32_t mode, + PP_FileHandle* file) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->OpenFile(instance, path, mode, file); +} + +int32_t RenameFile(PP_Instance instance, + const char* path_from, + const char* path_to) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->RenameFile(instance, + path_from, path_to); +} + +int32_t DeleteFileOrDir(PP_Instance instance, + const char* path, + PP_Bool recursive) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->DeleteFileOrDir(instance, path, + recursive); +} + +int32_t CreateDir(PP_Instance instance, const char* path) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->CreateDir(instance, path); +} + +int32_t QueryFile(PP_Instance instance, const char* path, PP_FileInfo* info) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->QueryFile(instance, path, info); +} + +int32_t GetDirContents(PP_Instance instance, + const char* path, + PP_DirContents_Dev** contents) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->GetDirContents(instance, path, + contents); +} + +void FreeDirContents(PP_Instance instance, + PP_DirContents_Dev* contents) { + EnterInstance enter(instance); + if (enter.succeeded()) { + return enter.functions()->GetFlashAPI()->FreeDirContents(instance, + contents); + } +} + +const PPB_Flash_File_ModuleLocal g_ppb_flash_file_modulelocal_thunk = { + &CreateThreadAdapterForInstance, + &ClearThreadAdapterForInstance, + &OpenFile, + &RenameFile, + &DeleteFileOrDir, + &CreateDir, + &QueryFile, + &GetDirContents, + &FreeDirContents +}; + +} // namespace + +const PPB_Flash_File_ModuleLocal* GetPPB_Flash_File_ModuleLocal_Thunk() { + return &g_ppb_flash_file_modulelocal_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index 09a7e5f..09086de 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -60,13 +60,6 @@ PPAPI_THUNK_EXPORT const PPB_BufferTrusted_0_1* GetPPB_BufferTrusted_0_1_Thunk(); PPAPI_THUNK_EXPORT const PPB_FileChooserTrusted_0_5* GetPPB_FileChooser_Trusted_0_5_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Flash_Clipboard_4_0* - GetPPB_Flash_Clipboard_4_0_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Flash_Clipboard_3_0* - GetPPB_Flash_Clipboard_3_0_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Flash_Menu_0_2* GetPPB_Flash_Menu_0_2_Thunk(); -PPAPI_THUNK_EXPORT const PPB_Flash_MessageLoop_0_1* - GetPPB_Flash_MessageLoop_0_1_Thunk(); PPAPI_THUNK_EXPORT const PPB_Graphics3DTrusted_1_0* GetPPB_Graphics3DTrusted_1_0_Thunk(); PPAPI_THUNK_EXPORT const PPB_HostResolver_Private_0_1* |