diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-11 20:45:01 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-11 20:45:01 +0000 |
commit | 502ec4dda4411088ac46b55754a027235e4b9217 (patch) | |
tree | 97a150aca10c22b5b24060a5194164e636521d40 /ppapi | |
parent | 84734df4b93aa0e7d01313b17ff190022dcca8bf (diff) | |
download | chromium_src-502ec4dda4411088ac46b55754a027235e4b9217.zip chromium_src-502ec4dda4411088ac46b55754a027235e4b9217.tar.gz chromium_src-502ec4dda4411088ac46b55754a027235e4b9217.tar.bz2 |
Add an asynchronous version of the Flash DeviceID API.
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10535062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141486 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
22 files changed, 413 insertions, 3 deletions
diff --git a/ppapi/api/private/ppb_flash.idl b/ppapi/api/private/ppb_flash.idl index 0befda7..4251a4f5 100644 --- a/ppapi/api/private/ppb_flash.idl +++ b/ppapi/api/private/ppb_flash.idl @@ -179,6 +179,7 @@ interface PPB_Flash { /** * Returns the device ID as a string. Returns a PP_VARTYPE_UNDEFINED on error. + * Deprecated, use GetDeviceIDAsync. */ [version=12.2] PP_Var GetDeviceID([in] PP_Instance instance); @@ -187,7 +188,8 @@ interface PPB_Flash { * Deprecated. See GetSetting(). */ [version=12.3] - int32_t GetSettingInt(PP_Instance instance, PP_FlashSetting setting); + int32_t GetSettingInt([in] PP_Instance instance, + [in] PP_FlashSetting setting); /** * Returns the value associated with the given setting. Invalid enums will diff --git a/ppapi/api/private/ppb_flash_device_id.idl b/ppapi/api/private/ppb_flash_device_id.idl new file mode 100644 index 0000000..dd69b3d --- /dev/null +++ b/ppapi/api/private/ppb_flash_device_id.idl @@ -0,0 +1,26 @@ +/* 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. + */ + +/** + * This file contains the <code>PPB_Flash_DeviceID</code> interface. + */ + +label Chrome { + M21 = 1.0 +}; + +interface PPB_Flash_DeviceID { + PP_Resource Create([in] PP_Instance instance); + + /** + * Asynchronously computes the device ID. When available, it will place the + * string in |*id| and will call the completion callback. On failure the + * given var will be PP_VARTYPE_UNDEFINED. + */ + int32_t GetDeviceID([in] PP_Resource device_id, + [out] PP_Var id, + [in] PP_CompletionCallback callback); +}; + diff --git a/ppapi/c/private/ppb_flash.h b/ppapi/c/private/ppb_flash.h index 1bde87b..94b4f85 100644 --- a/ppapi/c/private/ppb_flash.h +++ b/ppapi/c/private/ppb_flash.h @@ -175,6 +175,7 @@ struct PPB_Flash_12_4 { void (*UpdateActivity)(PP_Instance instance); /** * Returns the device ID as a string. Returns a PP_VARTYPE_UNDEFINED on error. + * Deprecated, use GetDeviceIDAsync. */ struct PP_Var (*GetDeviceID)(PP_Instance instance); /** diff --git a/ppapi/c/private/ppb_flash_device_id.h b/ppapi/c/private/ppb_flash_device_id.h new file mode 100644 index 0000000..33d1ba7 --- /dev/null +++ b/ppapi/c/private/ppb_flash_device_id.h @@ -0,0 +1,50 @@ +/* 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. + */ + +/* From private/ppb_flash_device_id.idl modified Fri Jun 1 15:21:17 2012. */ + +#ifndef PPAPI_C_PRIVATE_PPB_FLASH_DEVICE_ID_H_ +#define PPAPI_C_PRIVATE_PPB_FLASH_DEVICE_ID_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_stdint.h" +#include "ppapi/c/pp_var.h" + +#define PPB_FLASH_DEVICEID_INTERFACE_1_0 "PPB_Flash_DeviceID;1.0" +#define PPB_FLASH_DEVICEID_INTERFACE PPB_FLASH_DEVICEID_INTERFACE_1_0 + +/** + * @file + * This file contains the <code>PPB_Flash_DeviceID</code> interface. + */ + + +/** + * @addtogroup Interfaces + * @{ + */ +struct PPB_Flash_DeviceID_1_0 { + PP_Resource (*Create)(PP_Instance instance); + /** + * Asynchronously computes the device ID. When available, it will place the + * string in |*id| and will call the completion callback. On failure the + * given var will be PP_VARTYPE_UNDEFINED. + */ + int32_t (*GetDeviceID)(PP_Resource device_id, + struct PP_Var* id, + struct PP_CompletionCallback callback); +}; + +typedef struct PPB_Flash_DeviceID_1_0 PPB_Flash_DeviceID; +/** + * @} + */ + +#endif /* PPAPI_C_PRIVATE_PPB_FLASH_DEVICE_ID_H_ */ + diff --git a/ppapi/cpp/private/flash_device_id.cc b/ppapi/cpp/private/flash_device_id.cc new file mode 100644 index 0000000..6ed8935 --- /dev/null +++ b/ppapi/cpp/private/flash_device_id.cc @@ -0,0 +1,45 @@ +// 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/cpp/private/flash_device_id.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_flash_device_id.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> const char* interface_name<PPB_Flash_DeviceID_1_0>() { + return PPB_FLASH_DEVICEID_INTERFACE_1_0; +} + +} // namespace + +namespace flash { + +DeviceID::DeviceID() { +} + +DeviceID::DeviceID(const InstanceHandle& instance) : Resource() { + if (has_interface<PPB_Flash_DeviceID_1_0>()) { + PassRefFromConstructor(get_interface<PPB_Flash_DeviceID_1_0>()->Create( + instance.pp_instance())); + } +} + +int32_t DeviceID::GetDeviceID( + const CompletionCallbackWithOutput<Var>& callback) { + if (has_interface<PPB_Flash_DeviceID_1_0>()) { + return get_interface<PPB_Flash_DeviceID_1_0>()->GetDeviceID( + pp_resource(), + callback.output(), + callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +} // namespace flash +} // namespace pp diff --git a/ppapi/cpp/private/flash_device_id.h b/ppapi/cpp/private/flash_device_id.h new file mode 100644 index 0000000..33c5e55 --- /dev/null +++ b/ppapi/cpp/private/flash_device_id.h @@ -0,0 +1,26 @@ +// 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. + +#ifndef PPAPI_CPP_PRIVATE_FLASH_DEVICE_ID_H_ +#define PPAPI_CPP_PRIVATE_FLASH_DEVICE_ID_H_ + +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/resource.h" + +namespace pp { +namespace flash { + +class DeviceID : public Resource { + public: + DeviceID(); + DeviceID(const InstanceHandle& instance); + + // On success, returns a string var. + int32_t GetDeviceID(const CompletionCallbackWithOutput<Var>& callback); +}; + +} // namespace flash +} // namespace pp + +#endif // PPAPI_CPP_PRIVATE_FLASH_DEVICE_ID_H_ diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index fde6415..c6b29d7 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -88,6 +88,8 @@ 'proxy/ppb_file_ref_proxy.h', 'proxy/ppb_file_system_proxy.cc', 'proxy/ppb_file_system_proxy.h', + 'proxy/ppb_flash_device_id_proxy.cc', + 'proxy/ppb_flash_device_id_proxy.h', 'proxy/ppb_flash_proxy.cc', 'proxy/ppb_flash_proxy.h', 'proxy/ppb_flash_menu_proxy.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index e993398..4167c05 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -187,6 +187,8 @@ 'thunk/ppb_find_thunk.cc', 'thunk/ppb_flash_api.h', 'thunk/ppb_flash_clipboard_thunk.cc', + 'thunk/ppb_flash_device_id_api.h', + 'thunk/ppb_flash_device_id_thunk.cc', 'thunk/ppb_flash_file_fileref_thunk.cc', 'thunk/ppb_flash_file_modulelocal_thunk.cc', 'thunk/ppb_flash_fullscreen_thunk.cc', diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index 6b14eaf..5dcbd51 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -252,6 +252,8 @@ 'cpp/private/flash.h', 'cpp/private/flash_clipboard.cc', 'cpp/private/flash_clipboard.h', + 'cpp/private/flash_device_id.cc', + 'cpp/private/flash_device_id.h', 'cpp/private/flash_fullscreen.cc', 'cpp/private/flash_fullscreen.h', 'cpp/private/flash_menu.cc', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 985d3bb..fc5f1ce 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -53,6 +53,7 @@ #include "ppapi/c/private/ppb_flash_file.h" #include "ppapi/c/private/ppb_flash_fullscreen.h" #include "ppapi/c/private/ppb_flash.h" +#include "ppapi/c/private/ppb_flash_device_id.h" #include "ppapi/c/private/ppb_flash_menu.h" #include "ppapi/c/private/ppb_flash_message_loop.h" #include "ppapi/c/private/ppb_flash_print.h" @@ -80,6 +81,7 @@ #include "ppapi/proxy/ppb_file_io_proxy.h" #include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/proxy/ppb_file_system_proxy.h" +#include "ppapi/proxy/ppb_flash_device_id_proxy.h" #include "ppapi/proxy/ppb_flash_menu_proxy.h" #include "ppapi/proxy/ppb_flash_message_loop_proxy.h" #include "ppapi/proxy/ppb_flash_proxy.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 2889ea4..a62d87d 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -437,6 +437,13 @@ IPC_MESSAGE_ROUTED2(PpapiMsg_PPPClass_Deallocate, int64 /* ppp_class */, int64 /* object */) +// PPB_Flash_DeviceID. +IPC_MESSAGE_ROUTED4(PpapiMsg_PPBFlashDeviceID_GetReply, + int32 /* routing_id */, + PP_Resource /* resource */, + int32 /* result */, + std::string /* value */) + // PPP_Graphics3D_Dev. IPC_MESSAGE_ROUTED1(PpapiMsg_PPPGraphics3D_ContextLost, PP_Instance /* instance */) @@ -1259,6 +1266,11 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBFlash_QueryFileRef, IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBFlash_InvokePrinting, PP_Instance /* instance */) +// PPB_Flash_DeviceID. +IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFlashDeviceID_Get, + int32 /* routing_id */, + PP_Resource /* resource */) + // PPB_Flash_Menu IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFlashMenu_Create, PP_Instance /* instance */, diff --git a/ppapi/proxy/ppb_flash_device_id_proxy.cc b/ppapi/proxy/ppb_flash_device_id_proxy.cc new file mode 100644 index 0000000..bb66b33 --- /dev/null +++ b/ppapi/proxy/ppb_flash_device_id_proxy.cc @@ -0,0 +1,126 @@ +// 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/proxy/ppb_flash_device_id_proxy.h" + +#include "base/compiler_specific.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_globals.h" +#include "ppapi/proxy/plugin_proxy_delegate.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ppapi/shared_impl/resource.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/shared_impl/var.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_flash_device_id_api.h" + +using ppapi::thunk::PPB_Flash_DeviceID_API; + +namespace ppapi { +namespace proxy { + +namespace { + +class DeviceID : public Resource, public PPB_Flash_DeviceID_API { + public: + DeviceID(PP_Instance instance); + virtual ~DeviceID(); + + // Resource overrides. + virtual PPB_Flash_DeviceID_API* AsPPB_Flash_DeviceID_API() OVERRIDE; + + // PPB_Flash_DeviceID_API implementation. + virtual int32_t GetDeviceID(PP_Var* id, + const PP_CompletionCallback& callback) OVERRIDE; + + void OnReply(int32_t result, const std::string& id); + + private: + // Non-null when a callback is pending. + PP_Var* dest_; + + scoped_refptr<TrackedCallback> callback_; + + DISALLOW_COPY_AND_ASSIGN(DeviceID); +}; + +DeviceID::DeviceID(PP_Instance instance) + : Resource(OBJECT_IS_PROXY, instance), + dest_(NULL) { +} + +DeviceID::~DeviceID() { +} + +PPB_Flash_DeviceID_API* DeviceID::AsPPB_Flash_DeviceID_API() { + return this; +} + +int32_t DeviceID::GetDeviceID(PP_Var* id, + const PP_CompletionCallback& callback) { + if (TrackedCallback::IsPending(callback_)) + return PP_ERROR_INPROGRESS; + if (!id) + return PP_ERROR_BADARGUMENT; + + callback_ = new TrackedCallback(this, callback); + dest_ = id; + + PluginDispatcher* dispatcher = + PluginDispatcher::GetForInstance(pp_instance()); + + PluginGlobals::Get()->plugin_proxy_delegate()->SendToBrowser( + new PpapiHostMsg_PPBFlashDeviceID_Get( + API_ID_PPB_FLASH_DEVICE_ID, dispatcher->plugin_dispatcher_id(), + pp_resource())); + return PP_OK_COMPLETIONPENDING; +} + +void DeviceID::OnReply(int32_t result, const std::string& id) { + if (result == PP_OK) + *dest_ = StringVar::StringToPPVar(id); + else + *dest_ = PP_MakeUndefined(); + dest_ = NULL; + TrackedCallback::ClearAndRun(&callback_, result); +} + +} // namespace + +PPB_Flash_DeviceID_Proxy::PPB_Flash_DeviceID_Proxy(Dispatcher* dispatcher) + : InterfaceProxy(dispatcher) { +} + +PPB_Flash_DeviceID_Proxy::~PPB_Flash_DeviceID_Proxy() { +} + +// static +PP_Resource PPB_Flash_DeviceID_Proxy::CreateProxyResource( + PP_Instance instance) { + return (new DeviceID(instance))->GetReference(); +} + +bool PPB_Flash_DeviceID_Proxy::OnMessageReceived(const IPC::Message& msg) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(PPB_Flash_DeviceID_Proxy, msg) + IPC_MESSAGE_HANDLER(PpapiMsg_PPBFlashDeviceID_GetReply, + OnPluginMsgGetReply) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void PPB_Flash_DeviceID_Proxy::OnPluginMsgGetReply(int32 routing_id, + PP_Resource resource, + int32 result, + const std::string& id) { + thunk::EnterResourceNoLock<PPB_Flash_DeviceID_API> enter(resource, false); + if (enter.failed()) + return; // Resource destroyed. + static_cast<DeviceID*>(enter.object())->OnReply(result, id); +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/ppb_flash_device_id_proxy.h b/ppapi/proxy/ppb_flash_device_id_proxy.h new file mode 100644 index 0000000..58b15df --- /dev/null +++ b/ppapi/proxy/ppb_flash_device_id_proxy.h @@ -0,0 +1,39 @@ +// 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. + +#ifndef PPAPI_PROXY_PPB_FLASH_DEVICE_ID_PROXY_H_ +#define PPAPI_PROXY_PPB_FLASH_DEVICE_ID_PROXY_H_ + +#include "ppapi/c/pp_instance.h" +#include "ppapi/proxy/interface_proxy.h" + +namespace ppapi { +namespace proxy { + +class PPB_Flash_DeviceID_Proxy : public InterfaceProxy { + public: + PPB_Flash_DeviceID_Proxy(Dispatcher* dispatcher); + virtual ~PPB_Flash_DeviceID_Proxy(); + + static PP_Resource CreateProxyResource(PP_Instance instance); + + // InterfaceProxy implementation. + virtual bool OnMessageReceived(const IPC::Message& msg); + + static const ApiID kApiID = API_ID_PPB_FLASH_DEVICE_ID; + + private: + void OnPluginMsgGetReply(int32 routing_id, + PP_Resource resource, + int32 result, + const std::string& id); + + DISALLOW_COPY_AND_ASSIGN(PPB_Flash_DeviceID_Proxy); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_PPB_FLASH_DEVICE_ID_PROXY_H_ + diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index f25d9de..2472060 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -18,6 +18,7 @@ #include "ppapi/proxy/ppb_file_io_proxy.h" #include "ppapi/proxy/ppb_file_ref_proxy.h" #include "ppapi/proxy/ppb_file_system_proxy.h" +#include "ppapi/proxy/ppb_flash_device_id_proxy.h" #include "ppapi/proxy/ppb_flash_menu_proxy.h" #include "ppapi/proxy/ppb_flash_message_loop_proxy.h" #include "ppapi/proxy/ppb_graphics_2d_proxy.h" @@ -228,6 +229,10 @@ PP_Resource ResourceCreationProxy::CreateFileChooser( accept_types); } +PP_Resource ResourceCreationProxy::CreateFlashDeviceID(PP_Instance instance) { + return PPB_Flash_DeviceID_Proxy::CreateProxyResource(instance); +} + PP_Resource ResourceCreationProxy::CreateFlashMenu( PP_Instance instance, const PP_Flash_Menu* menu_data) { diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index 9c18f27..e242f2d 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -111,6 +111,7 @@ class ResourceCreationProxy : public InterfaceProxy, PP_Instance instance, PP_FileChooserMode_Dev mode, const char* accept_types) OVERRIDE; + virtual PP_Resource CreateFlashDeviceID(PP_Instance instance) OVERRIDE; virtual PP_Resource CreateFlashMenu(PP_Instance instance, const PP_Flash_Menu* menu_data) OVERRIDE; virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) OVERRIDE; diff --git a/ppapi/shared_impl/api_id.h b/ppapi/shared_impl/api_id.h index d83c085..83fbf5a 100644 --- a/ppapi/shared_impl/api_id.h +++ b/ppapi/shared_impl/api_id.h @@ -25,6 +25,7 @@ enum ApiID { API_ID_PPB_FILE_REF, API_ID_PPB_FILE_SYSTEM, API_ID_PPB_FLASH, + API_ID_PPB_FLASH_DEVICE_ID, API_ID_PPB_FLASH_MENU, API_ID_PPB_FLASH_MESSAGELOOP, API_ID_PPB_FONT, diff --git a/ppapi/shared_impl/ppb_audio_config_shared.h b/ppapi/shared_impl/ppb_audio_config_shared.h index 0174666..77826be 100644 --- a/ppapi/shared_impl/ppb_audio_config_shared.h +++ b/ppapi/shared_impl/ppb_audio_config_shared.h @@ -38,8 +38,7 @@ class PPAPI_SHARED_EXPORT PPB_AudioConfig_Shared private: // You must call Init before using this object. - explicit PPB_AudioConfig_Shared(ResourceObjectType type, - PP_Instance instance); + PPB_AudioConfig_Shared(ResourceObjectType type, PP_Instance instance); // Returns false if the arguments are invalid, the object should not be // used in this case. diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h index f920262..a6857543 100644 --- a/ppapi/shared_impl/resource.h +++ b/ppapi/shared_impl/resource.h @@ -35,6 +35,7 @@ F(PPB_FileRef_API) \ F(PPB_FileSystem_API) \ F(PPB_Find_API) \ + F(PPB_Flash_DeviceID_API) \ F(PPB_Flash_Menu_API) \ F(PPB_Flash_MessageLoop_API) \ F(PPB_Graphics2D_API) \ diff --git a/ppapi/thunk/interfaces_ppb_private_flash.h b/ppapi/thunk/interfaces_ppb_private_flash.h index fa8842a..c0bd0df 100644 --- a/ppapi/thunk/interfaces_ppb_private_flash.h +++ b/ppapi/thunk/interfaces_ppb_private_flash.h @@ -40,6 +40,11 @@ PROXIED_IFACE(PPB_Flash, PPB_FLASH_FILE_FILEREF_INTERFACE, PPB_Flash_File_FileRef) +PROXIED_API(PPB_Flash_DeviceID) +PROXIED_IFACE(PPB_Flash_DeviceID, + PPB_FLASH_DEVICEID_INTERFACE_1_0, + PPB_Flash_DeviceID_1_0) + PROXIED_API(PPB_Flash_Menu) PROXIED_IFACE(PPB_Flash_Menu, PPB_FLASH_MENU_INTERFACE_0_2, diff --git a/ppapi/thunk/ppb_flash_device_id_api.h b/ppapi/thunk/ppb_flash_device_id_api.h new file mode 100644 index 0000000..ae31abd --- /dev/null +++ b/ppapi/thunk/ppb_flash_device_id_api.h @@ -0,0 +1,18 @@ +// 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. + +namespace ppapi { +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_Flash_DeviceID_API { + public: + virtual ~PPB_Flash_DeviceID_API() {} + + virtual int32_t GetDeviceID(PP_Var* id, + const PP_CompletionCallback& callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + diff --git a/ppapi/thunk/ppb_flash_device_id_thunk.cc b/ppapi/thunk/ppb_flash_device_id_thunk.cc new file mode 100644 index 0000000..9275648 --- /dev/null +++ b/ppapi/thunk/ppb_flash_device_id_thunk.cc @@ -0,0 +1,44 @@ +// 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/private/ppb_flash_device_id.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/ppb_flash_device_id_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateFlashDeviceID(instance); +} + +int32_t GetDeviceID(PP_Resource resource, + PP_Var* id, + PP_CompletionCallback callback) { + EnterResource<PPB_Flash_DeviceID_API> enter(resource, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->GetDeviceID(id, callback)); +} + +const PPB_Flash_DeviceID g_ppb_flash_deviceid_thunk = { + &Create, + &GetDeviceID +}; + +} // namespace + +const PPB_Flash_DeviceID_1_0* GetPPB_Flash_DeviceID_1_0_Thunk() { + return &g_ppb_flash_deviceid_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index 3cd1752..51b179e 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -115,6 +115,7 @@ class ResourceCreationAPI { PP_Instance instance, PP_FileChooserMode_Dev mode, const char* accept_types) = 0; + virtual PP_Resource CreateFlashDeviceID(PP_Instance instance) = 0; virtual PP_Resource CreateFlashMenu(PP_Instance instance, const PP_Flash_Menu* menu_data) = 0; virtual PP_Resource CreateFlashMessageLoop(PP_Instance instance) = 0; |