diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 23:04:24 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 23:04:24 +0000 |
commit | ceadc397e01759ce1fb876f35357427766b70c2a (patch) | |
tree | 2d2ba77bcc48065140a88545801415574241fb2f /ppapi | |
parent | 9af75df68c6103002f27298dee8e53574457a1ab (diff) | |
download | chromium_src-ceadc397e01759ce1fb876f35357427766b70c2a.zip chromium_src-ceadc397e01759ce1fb876f35357427766b70c2a.tar.gz chromium_src-ceadc397e01759ce1fb876f35357427766b70c2a.tar.bz2 |
Move fullscreen and instance to the new thunk system.
This takes it in a slightl different direction. Rather than maintaining separate
APIs, proxies, and impls for each interface, I think smaller instance-related
interfaces can just be added on the Instance_API. There's no need for binary
compatibility here and it saves a whole lot of boilerplate. Although
PPB_Instance_API will get large, this isn't necessarily bad, and is probably
more clear than the alternative (it saves a whole lot of code).
This means that the interface IDs no longer have a 1:1 mapping to interface
names. But this was already going to be the case when we have multiple versions
of different interfaces. Currently the code in dispatcher to deal with this is
a bit weird, because of the way the mapping works. Long term, I'm going to
change these from interface IDs in the proxy to API IDs in the thunk layer.
This adds APIs and thunks for several other interfaces without implementing
them yet (this patch was getting too large): URL loading and surface 3D.
TEST=ppapi tests
BUG=none
Review URL: http://codereview.chromium.org/7058015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89265 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
33 files changed, 1026 insertions, 483 deletions
diff --git a/ppapi/c/ppb_instance.h b/ppapi/c/ppb_instance.h index 09e8c99..eb89a70 100644 --- a/ppapi/c/ppb_instance.h +++ b/ppapi/c/ppb_instance.h @@ -95,6 +95,12 @@ struct PPB_Instance { struct PP_Var* exception); }; +#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING +typedef struct PPB_Instance PPB_Instance_0_5; +#else +typedef struct PPB_Instance PPB_Instance_0_4; +#endif + /** * @} */ diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index c2600dc..5d63efe 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -92,16 +92,12 @@ 'proxy/ppb_flash_net_connector_proxy.h', 'proxy/ppb_font_proxy.cc', 'proxy/ppb_font_proxy.h', - 'proxy/ppb_fullscreen_proxy.cc', - 'proxy/ppb_fullscreen_proxy.h', 'proxy/ppb_gles_chromium_texture_mapping_proxy.cc', 'proxy/ppb_gles_chromium_texture_mapping_proxy.h', 'proxy/ppb_graphics_2d_proxy.cc', 'proxy/ppb_graphics_2d_proxy.h', 'proxy/ppb_image_data_proxy.cc', 'proxy/ppb_image_data_proxy.h', - 'proxy/ppb_instance_private_proxy.cc', - 'proxy/ppb_instance_private_proxy.h', 'proxy/ppb_instance_proxy.cc', 'proxy/ppb_instance_proxy.h', 'proxy/ppb_opengles2_proxy.cc', diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 3367183..49d6777 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -84,11 +84,25 @@ 'thunk/ppb_flash_net_connector_thunk.cc', 'thunk/ppb_font_api.h', 'thunk/ppb_font_thunk.cc', + 'thunk/ppb_fullscreen_thunk.cc', 'thunk/ppb_graphics_2d_api.h', 'thunk/ppb_graphics_2d_thunk.cc', 'thunk/ppb_image_data_api.h', 'thunk/ppb_image_data_thunk.cc', 'thunk/ppb_image_data_trusted_thunk.cc', + 'thunk/ppb_instance_api.h', + 'thunk/ppb_instance_thunk.cc', + 'thunk/ppb_pdf_api.h', + 'thunk/ppb_surface_3d_api.h', + 'thunk/ppb_surface_3d_thunk.cc', + 'thunk/ppb_url_loader_api.h', + 'thunk/ppb_url_loader_thunk.cc', + 'thunk/ppb_url_request_info_api.h', + 'thunk/ppb_url_request_info_thunk.cc', + 'thunk/ppb_url_response_info_api.h', + 'thunk/ppb_url_response_info_thunk.cc', + 'thunk/ppb_widget_api.h', + 'thunk/ppb_widget_thunk.cc', 'thunk/thunk.h', ], 'conditions': [ diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc index 8a1fa74..78b558c 100644 --- a/ppapi/proxy/dispatcher.cc +++ b/ppapi/proxy/dispatcher.cc @@ -18,7 +18,6 @@ #include "ppapi/c/dev/ppb_cursor_control_dev.h" #include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h" #include "ppapi/c/dev/ppb_font_dev.h" -#include "ppapi/c/dev/ppb_fullscreen_dev.h" #include "ppapi/c/dev/ppb_opengles_dev.h" #include "ppapi/c/dev/ppb_surface_3d_dev.h" #include "ppapi/c/dev/ppb_testing_dev.h" @@ -63,11 +62,9 @@ #include "ppapi/proxy/ppb_flash_menu_proxy.h" #include "ppapi/proxy/ppb_flash_net_connector_proxy.h" #include "ppapi/proxy/ppb_font_proxy.h" -#include "ppapi/proxy/ppb_fullscreen_proxy.h" #include "ppapi/proxy/ppb_gles_chromium_texture_mapping_proxy.h" #include "ppapi/proxy/ppb_graphics_2d_proxy.h" #include "ppapi/proxy/ppb_image_data_proxy.h" -#include "ppapi/proxy/ppb_instance_private_proxy.h" #include "ppapi/proxy/ppb_instance_proxy.h" #include "ppapi/proxy/ppb_opengles2_proxy.h" #include "ppapi/proxy/ppb_pdf_proxy.h" @@ -102,6 +99,11 @@ struct InterfaceList { NameToInfo name_to_plugin_info_; NameToInfo name_to_browser_info_; + // Note that there can be multiple interface names mapping to the same ID. + // In this case, the ID will map to one of them. This is temporary while + // we're converting to the thunk system, when that is complete, we need to + // have a better way of handling multiple interface implemented by one + // proxy object. const InterfaceProxy::Info* id_to_plugin_info_[INTERFACE_ID_COUNT]; const InterfaceProxy::Info* id_to_browser_info_[INTERFACE_ID_COUNT]; }; @@ -130,12 +132,13 @@ InterfaceList::InterfaceList() { AddPPB(PPB_Flash_Proxy::GetInfo()); AddPPB(PPB_Flash_Menu_Proxy::GetInfo()); AddPPB(PPB_Font_Proxy::GetInfo()); - AddPPB(PPB_Fullscreen_Proxy::GetInfo()); AddPPB(PPB_GLESChromiumTextureMapping_Proxy::GetInfo()); AddPPB(PPB_Graphics2D_Proxy::GetInfo()); AddPPB(PPB_ImageData_Proxy::GetInfo()); - AddPPB(PPB_Instance_Private_Proxy::GetInfo()); - AddPPB(PPB_Instance_Proxy::GetInfo()); + AddPPB(PPB_Instance_Proxy::GetInfoPrivate()); + AddPPB(PPB_Instance_Proxy::GetInfo0_4()); + AddPPB(PPB_Instance_Proxy::GetInfo0_5()); + AddPPB(PPB_Instance_Proxy::GetInfoFullscreen()); AddPPB(PPB_OpenGLES2_Proxy::GetInfo()); AddPPB(PPB_PDF_Proxy::GetInfo()); AddPPB(PPB_Surface3D_Proxy::GetInfo()); @@ -161,21 +164,24 @@ InterfaceList::InterfaceList() { void InterfaceList::AddPPP(const InterfaceProxy::Info* info) { DCHECK(name_to_plugin_info_.find(info->name) == name_to_plugin_info_.end()); - DCHECK(info->id > 0 && info->id < INTERFACE_ID_COUNT); - DCHECK(id_to_plugin_info_[info->id] == NULL); + DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT); + DCHECK(info->id == INTERFACE_ID_NONE || id_to_plugin_info_[info->id] == NULL); name_to_plugin_info_[info->name] = info; - id_to_plugin_info_[info->id] = info; + if (info->id != INTERFACE_ID_NONE) + id_to_plugin_info_[info->id] = info; } void InterfaceList::AddPPB(const InterfaceProxy::Info* info) { DCHECK(name_to_browser_info_.find(info->name) == name_to_browser_info_.end()); - DCHECK(info->id > 0 && info->id < INTERFACE_ID_COUNT); - DCHECK(id_to_browser_info_[info->id] == NULL); + DCHECK(info->id >= INTERFACE_ID_NONE && info->id < INTERFACE_ID_COUNT); + DCHECK(info->id == INTERFACE_ID_NONE || + id_to_browser_info_[info->id] == NULL); name_to_browser_info_[std::string(info->name)] = info; - id_to_browser_info_[info->id] = info; + if (info->id != INTERFACE_ID_NONE) + id_to_browser_info_[info->id] = info; } // static diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h index 7363340..544e727 100644 --- a/ppapi/proxy/interface_id.h +++ b/ppapi/proxy/interface_id.h @@ -34,7 +34,6 @@ enum InterfaceID { INTERFACE_ID_PPB_FLASH_MENU, INTERFACE_ID_PPB_FLASH_NETCONNECTOR, INTERFACE_ID_PPB_FONT, - INTERFACE_ID_PPB_FULLSCREEN, INTERFACE_ID_PPB_GLES_CHROMIUM_TM, INTERFACE_ID_PPB_GRAPHICS_2D, INTERFACE_ID_PPB_IMAGE_DATA, diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc index 26c8af2..a701947 100644 --- a/ppapi/proxy/plugin_dispatcher.cc +++ b/ppapi/proxy/plugin_dispatcher.cc @@ -20,6 +20,7 @@ #include "ppapi/proxy/ppb_char_set_proxy.h" #include "ppapi/proxy/ppb_cursor_control_proxy.h" #include "ppapi/proxy/ppb_font_proxy.h" +#include "ppapi/proxy/ppb_instance_proxy.h" #include "ppapi/proxy/ppp_class_proxy.h" #include "ppapi/proxy/resource_creation_proxy.h" #include "ppapi/shared_impl/tracker_base.h" @@ -235,6 +236,8 @@ ppapi::WebKitForwarding* PluginDispatcher::GetWebKitForwarding() { proxy.reset(new PPB_CursorControl_Proxy(this, NULL)); else if (id == INTERFACE_ID_PPB_FONT) proxy.reset(new PPB_Font_Proxy(this, NULL)); + else if (id == INTERFACE_ID_PPB_INSTANCE) + proxy.reset(new PPB_Instance_Proxy(this, NULL)); else if (id == INTERFACE_ID_RESOURCE_CREATION) proxy.reset(new ResourceCreationProxy(this)); diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 7ceb936..d31b0d7 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -540,16 +540,6 @@ IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBFlashNetConnector_ConnectTcpAddress, IPC_SYNC_MESSAGE_CONTROL0_1(PpapiHostMsg_PPBFont_GetFontFamilies, std::string /* result */) -// PPB_Fullscreen. -IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBFullscreen_SetFullscreen, - PP_Instance /* instance */, - PP_Bool /* fullscreen */, - PP_Bool /* result */) -IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBFullscreen_GetScreenSize, - PP_Instance /* instance */, - PP_Bool /* result */, - PP_Size /* size */) - // PPB_Graphics2D. IPC_MESSAGE_ROUTED5(PpapiHostMsg_PPBGraphics2D_PaintImageData, pp::proxy::HostResource /* graphics_2d */, @@ -587,20 +577,14 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBInstance_ExecuteScript, pp::proxy::SerializedVar /* script */, pp::proxy::SerializedVar /* out_exception */, pp::proxy::SerializedVar /* result */) - -// PPB_Instance_Private. -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstancePrivate_GetWindowObject, +IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBInstance_SetFullscreen, PP_Instance /* instance */, - pp::proxy::SerializedVar /* result */) -IPC_SYNC_MESSAGE_ROUTED1_1( - PpapiHostMsg_PPBInstancePrivate_GetOwnerElementObject, - PP_Instance /* instance */, - pp::proxy::SerializedVar /* result */) -IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBInstancePrivate_ExecuteScript, + PP_Bool /* fullscreen */, + PP_Bool /* result */) +IPC_SYNC_MESSAGE_ROUTED1_2(PpapiHostMsg_PPBInstance_GetScreenSize, PP_Instance /* instance */, - pp::proxy::SerializedVar /* script */, - pp::proxy::SerializedVar /* out_exception */, - pp::proxy::SerializedVar /* result */) + PP_Bool /* result */, + PP_Size /* size */) IPC_SYNC_MESSAGE_ROUTED3_1( PpapiHostMsg_PPBPDF_GetFontFileWithFallback, diff --git a/ppapi/proxy/ppb_fullscreen_proxy.cc b/ppapi/proxy/ppb_fullscreen_proxy.cc deleted file mode 100644 index ac768d4..0000000 --- a/ppapi/proxy/ppb_fullscreen_proxy.cc +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) 2011 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_fullscreen_proxy.h" - -#include "ppapi/c/dev/ppb_fullscreen_dev.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/ppapi_messages.h" - -namespace pp { -namespace proxy { - -namespace { - -PP_Bool IsFullscreen(PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_FALSE; - InstanceData* data = dispatcher->GetInstanceData(instance); - if (!data) - return PP_FALSE; - return data->fullscreen; -} - -PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_FALSE; - - PP_Bool result = PP_FALSE; - dispatcher->Send(new PpapiHostMsg_PPBFullscreen_SetFullscreen( - INTERFACE_ID_PPB_FULLSCREEN, instance, fullscreen, &result)); - return result; -} - -PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_FALSE; - - PP_Bool result = PP_FALSE; - dispatcher->Send(new PpapiHostMsg_PPBFullscreen_GetScreenSize( - INTERFACE_ID_PPB_FULLSCREEN, instance, &result, size)); - return result; -} - -const PPB_Fullscreen_Dev fullscreen_interface = { - &IsFullscreen, - &SetFullscreen, - &GetScreenSize -}; - -InterfaceProxy* CreateFullscreenProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Fullscreen_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_Fullscreen_Proxy::PPB_Fullscreen_Proxy(Dispatcher* dispatcher, - const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_Fullscreen_Proxy::~PPB_Fullscreen_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_Fullscreen_Proxy::GetInfo() { - static const Info info = { - &fullscreen_interface, - PPB_FULLSCREEN_DEV_INTERFACE, - INTERFACE_ID_PPB_FULLSCREEN, - false, - &CreateFullscreenProxy, - }; - return &info; -} - -bool PPB_Fullscreen_Proxy::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_Fullscreen_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFullscreen_SetFullscreen, - OnMsgSetFullscreen) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFullscreen_GetScreenSize, - OnMsgGetScreenSize) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - // TODO(brettw): handle bad messages! - return handled; -} - -void PPB_Fullscreen_Proxy::OnMsgSetFullscreen(PP_Instance instance, - PP_Bool fullscreen, - PP_Bool* result) { - *result = ppb_fullscreen_target()->SetFullscreen(instance, fullscreen); -} - -void PPB_Fullscreen_Proxy::OnMsgGetScreenSize(PP_Instance instance, - PP_Bool* result, - PP_Size* size) { - *result = ppb_fullscreen_target()->GetScreenSize(instance, size); -} - -} // namespace proxy -} // namespace pp diff --git a/ppapi/proxy/ppb_fullscreen_proxy.h b/ppapi/proxy/ppb_fullscreen_proxy.h deleted file mode 100644 index 4bb66f4..0000000 --- a/ppapi/proxy/ppb_fullscreen_proxy.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2011 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_PPB_FULLSCREEN_PROXY_H_ -#define PPAPI_PPB_FULLSCREEN_PROXY_H_ - -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_size.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/proxy/interface_proxy.h" - -struct PPB_Fullscreen_Dev; - -namespace pp { -namespace proxy { - -class PPB_Fullscreen_Proxy : public InterfaceProxy { - public: - PPB_Fullscreen_Proxy(Dispatcher* dispatcher, const void* target_interface); - virtual ~PPB_Fullscreen_Proxy(); - - static const Info* GetInfo(); - - const PPB_Fullscreen_Dev* ppb_fullscreen_target() const { - return reinterpret_cast<const PPB_Fullscreen_Dev*>(target_interface()); - } - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - private: - // Message handlers. - void OnMsgSetFullscreen(PP_Instance instance, - PP_Bool fullscreen, - PP_Bool* result); - void OnMsgGetScreenSize(PP_Instance instance, - PP_Bool* result, - PP_Size* size); -}; - -} // namespace proxy -} // namespace pp - -#endif // PPAPI_PPB_FULLSCREEN_PROXY_H_ diff --git a/ppapi/proxy/ppb_instance_private_proxy.cc b/ppapi/proxy/ppb_instance_private_proxy.cc deleted file mode 100644 index 1029372..0000000 --- a/ppapi/proxy/ppb_instance_private_proxy.cc +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2011 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_instance_private_proxy.h" - -#include "ppapi/c/pp_var.h" -#include "ppapi/c/private/ppb_instance_private.h" -#include "ppapi/proxy/host_dispatcher.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/plugin_resource.h" -#include "ppapi/proxy/plugin_resource_tracker.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/serialized_var.h" - -namespace pp { -namespace proxy { - -namespace { - -PP_Var GetWindowObject(PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_MakeUndefined(); - - ReceiveSerializedVarReturnValue result; - dispatcher->Send(new PpapiHostMsg_PPBInstancePrivate_GetWindowObject( - INTERFACE_ID_PPB_INSTANCE_PRIVATE, instance, &result)); - return result.Return(dispatcher); -} - -PP_Var GetOwnerElementObject(PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_MakeUndefined(); - - ReceiveSerializedVarReturnValue result; - dispatcher->Send(new PpapiHostMsg_PPBInstancePrivate_GetOwnerElementObject( - INTERFACE_ID_PPB_INSTANCE_PRIVATE, instance, &result)); - return result.Return(dispatcher); -} - -PP_Var ExecuteScript(PP_Instance instance, PP_Var script, PP_Var* exception) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_MakeUndefined(); - - ReceiveSerializedException se(dispatcher, exception); - if (se.IsThrown()) - return PP_MakeUndefined(); - - ReceiveSerializedVarReturnValue result; - dispatcher->Send(new PpapiHostMsg_PPBInstancePrivate_ExecuteScript( - INTERFACE_ID_PPB_INSTANCE_PRIVATE, instance, - SerializedVarSendInput(dispatcher, script), &se, &result)); - return result.Return(dispatcher); -} - -const PPB_Instance_Private instance_private_interface = { - &GetWindowObject, - &GetOwnerElementObject, - &ExecuteScript -}; - -InterfaceProxy* CreateInstancePrivateProxy(Dispatcher* dispatcher, - const void* target_interface) { - return new PPB_Instance_Private_Proxy(dispatcher, target_interface); -} - -} // namespace - -PPB_Instance_Private_Proxy::PPB_Instance_Private_Proxy( - Dispatcher* dispatcher, const void* target_interface) - : InterfaceProxy(dispatcher, target_interface) { -} - -PPB_Instance_Private_Proxy::~PPB_Instance_Private_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_Instance_Private_Proxy::GetInfo() { - static const Info info = { - &instance_private_interface, - PPB_INSTANCE_PRIVATE_INTERFACE, - INTERFACE_ID_PPB_INSTANCE_PRIVATE, - false, - &CreateInstancePrivateProxy, - }; - return &info; -} - -bool PPB_Instance_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { - // Prevent the dispatcher from going away during a call to ExecuteScript. - // This must happen OUTSIDE of ExecuteScript since the SerializedVars use - // the dispatcher upon return of the function (converting the - // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor). - ScopedModuleReference death_grip(dispatcher()); - - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Private_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstancePrivate_GetWindowObject, - OnMsgGetWindowObject) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstancePrivate_GetOwnerElementObject, - OnMsgGetOwnerElementObject) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstancePrivate_ExecuteScript, - OnMsgExecuteScript) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void PPB_Instance_Private_Proxy::OnMsgGetWindowObject( - PP_Instance instance, - SerializedVarReturnValue result) { - result.Return(dispatcher(), - ppb_instance_private_target()->GetWindowObject(instance)); -} - -void PPB_Instance_Private_Proxy::OnMsgGetOwnerElementObject( - PP_Instance instance, - SerializedVarReturnValue result) { - result.Return(dispatcher(), - ppb_instance_private_target()->GetOwnerElementObject(instance)); -} - -void PPB_Instance_Private_Proxy::OnMsgExecuteScript( - PP_Instance instance, - SerializedVarReceiveInput script, - SerializedVarOutParam out_exception, - SerializedVarReturnValue result) { - if (dispatcher()->IsPlugin()) - NOTREACHED(); - else - static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); - - result.Return(dispatcher(), ppb_instance_private_target()->ExecuteScript( - instance, - script.Get(dispatcher()), - out_exception.OutParam(dispatcher()))); -} - -} // namespace proxy -} // namespace pp diff --git a/ppapi/proxy/ppb_instance_private_proxy.h b/ppapi/proxy/ppb_instance_private_proxy.h deleted file mode 100644 index 11062ee..0000000 --- a/ppapi/proxy/ppb_instance_private_proxy.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2011 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_INSTANCE_PRIVATE_PROXY_H_ -#define PPAPI_PROXY_PPB_INSTANCE_PRIVATE_PROXY_H_ - -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/c/pp_var.h" -#include "ppapi/proxy/host_resource.h" -#include "ppapi/proxy/interface_proxy.h" - -struct PPB_Instance_Private; - -namespace pp { -namespace proxy { - -class SerializedVarReceiveInput; -class SerializedVarOutParam; -class SerializedVarReturnValue; - -class PPB_Instance_Private_Proxy : public InterfaceProxy { - public: - PPB_Instance_Private_Proxy(Dispatcher* dispatcher, - const void* target_interface); - virtual ~PPB_Instance_Private_Proxy(); - - static const Info* GetInfo(); - - const PPB_Instance_Private* ppb_instance_private_target() const { - return reinterpret_cast<const PPB_Instance_Private*>(target_interface()); - } - - private: - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - // Message handlers. - void OnMsgGetWindowObject(PP_Instance instance, - SerializedVarReturnValue result); - void OnMsgGetOwnerElementObject(PP_Instance instance, - SerializedVarReturnValue result); - void OnMsgExecuteScript(PP_Instance instance, - SerializedVarReceiveInput script, - SerializedVarOutParam out_exception, - SerializedVarReturnValue result); -}; - -} // namespace proxy -} // namespace pp - -#endif // PPAPI_PROXY_PPB_INSTANCE_PRIVATE_PROXY_H_ diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index b2d6291..af12d28 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -4,6 +4,7 @@ #include "ppapi/proxy/ppb_instance_proxy.h" +#include "ppapi/c/dev/ppb_fullscreen_dev.h" #include "ppapi/c/pp_var.h" #include "ppapi/c/ppb_instance.h" #include "ppapi/proxy/host_dispatcher.h" @@ -12,86 +13,18 @@ #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/ppapi_messages.h" #include "ppapi/proxy/serialized_var.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/thunk.h" + +using ppapi::thunk::EnterFunctionNoLock; +using ppapi::thunk::EnterResourceNoLock; +using ppapi::thunk::PPB_Instance_FunctionAPI; namespace pp { namespace proxy { namespace { -PP_Var GetWindowObject(PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_MakeUndefined(); - - ReceiveSerializedVarReturnValue result; - dispatcher->Send(new PpapiHostMsg_PPBInstance_GetWindowObject( - INTERFACE_ID_PPB_INSTANCE, instance, &result)); - return result.Return(dispatcher); -} - -PP_Var GetOwnerElementObject(PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_MakeUndefined(); - - ReceiveSerializedVarReturnValue result; - dispatcher->Send(new PpapiHostMsg_PPBInstance_GetOwnerElementObject( - INTERFACE_ID_PPB_INSTANCE, instance, &result)); - return result.Return(dispatcher); -} - -PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_FALSE; - - PluginResource* object = - PluginResourceTracker::GetInstance()->GetResourceObject(device); - if (!object || object->instance() != instance) - return PP_FALSE; - - PP_Bool result = PP_FALSE; - dispatcher->Send(new PpapiHostMsg_PPBInstance_BindGraphics( - INTERFACE_ID_PPB_INSTANCE, instance, object->host_resource(), - &result)); - return result; -} - -PP_Bool IsFullFrame(PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_FALSE; - - PP_Bool result = PP_FALSE; - dispatcher->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( - INTERFACE_ID_PPB_INSTANCE, instance, &result)); - return result; -} - -PP_Var ExecuteScript(PP_Instance instance, PP_Var script, PP_Var* exception) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_MakeUndefined(); - - ReceiveSerializedException se(dispatcher, exception); - if (se.IsThrown()) - return PP_MakeUndefined(); - - ReceiveSerializedVarReturnValue result; - dispatcher->Send(new PpapiHostMsg_PPBInstance_ExecuteScript( - INTERFACE_ID_PPB_INSTANCE, instance, - SerializedVarSendInput(dispatcher, script), &se, &result)); - return result.Return(dispatcher); -} - -const PPB_Instance instance_interface = { - &GetWindowObject, - &GetOwnerElementObject, - &BindGraphics, - &IsFullFrame, - &ExecuteScript -}; - InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher, const void* target_interface) { return new PPB_Instance_Proxy(dispatcher, target_interface); @@ -108,10 +41,22 @@ PPB_Instance_Proxy::~PPB_Instance_Proxy() { } // static -const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo() { +const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo0_4() { static const Info info = { - &instance_interface, - PPB_INSTANCE_INTERFACE, + ppapi::thunk::GetPPB_Instance_0_4_Thunk(), + PPB_INSTANCE_INTERFACE_0_4, + INTERFACE_ID_NONE, // 0_5 is the canonical one. + false, + &CreateInstanceProxy, + }; + return &info; +} + +// static +const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo0_5() { + static const Info info = { + ppapi::thunk::GetPPB_Instance_0_5_Thunk(), + PPB_INSTANCE_INTERFACE_0_5, INTERFACE_ID_PPB_INSTANCE, false, &CreateInstanceProxy, @@ -119,6 +64,30 @@ const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo() { return &info; } +// static +const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { + static const Info info = { + ppapi::thunk::GetPPB_Instance_Private_Thunk(), + PPB_INSTANCE_PRIVATE_INTERFACE, + INTERFACE_ID_NONE, // 0_5 is the canonical one. + false, + &CreateInstanceProxy, + }; + return &info; +} + +// static +const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoFullscreen() { + static const Info info = { + ppapi::thunk::GetPPB_Fullscreen_Thunk(), + PPB_FULLSCREEN_DEV_INTERFACE, + INTERFACE_ID_NONE, // 0_5 is the canonical one. + false, + &CreateInstanceProxy, + }; + return &info; +} + bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { // Prevent the dispatcher from going away during a call to ExecuteScript. // This must happen OUTSIDE of ExecuteScript since the SerializedVars use @@ -138,35 +107,125 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnMsgIsFullFrame) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, OnMsgExecuteScript) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen, + OnMsgSetFullscreen) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetScreenSize, + OnMsgGetScreenSize) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } +PPB_Instance_FunctionAPI* PPB_Instance_Proxy::AsPPB_Instance_FunctionAPI() { + return this; +} + +PP_Bool PPB_Instance_Proxy::BindGraphics(PP_Instance instance, + PP_Resource device) { + PluginResource* object = + PluginResourceTracker::GetInstance()->GetResourceObject(device); + if (!object || object->instance() != instance) + return PP_FALSE; + + PP_Bool result = PP_FALSE; + dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics( + INTERFACE_ID_PPB_INSTANCE, instance, object->host_resource(), + &result)); + return result; +} + +PP_Bool PPB_Instance_Proxy::IsFullFrame(PP_Instance instance) { + PP_Bool result = PP_FALSE; + dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame( + INTERFACE_ID_PPB_INSTANCE, instance, &result)); + return result; +} + +PP_Var PPB_Instance_Proxy::GetWindowObject(PP_Instance instance) { + ReceiveSerializedVarReturnValue result; + dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetWindowObject( + INTERFACE_ID_PPB_INSTANCE, instance, &result)); + return result.Return(dispatcher()); +} + +PP_Var PPB_Instance_Proxy::GetOwnerElementObject(PP_Instance instance) { + ReceiveSerializedVarReturnValue result; + dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetOwnerElementObject( + INTERFACE_ID_PPB_INSTANCE, instance, &result)); + return result.Return(dispatcher()); +} + +PP_Var PPB_Instance_Proxy::ExecuteScript(PP_Instance instance, + PP_Var script, + PP_Var* exception) { + ReceiveSerializedException se(dispatcher(), exception); + if (se.IsThrown()) + return PP_MakeUndefined(); + + ReceiveSerializedVarReturnValue result; + dispatcher()->Send(new PpapiHostMsg_PPBInstance_ExecuteScript( + INTERFACE_ID_PPB_INSTANCE, instance, + SerializedVarSendInput(dispatcher(), script), &se, &result)); + return result.Return(dispatcher()); +} + +PP_Bool PPB_Instance_Proxy::IsFullscreen(PP_Instance instance) { + InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> + GetInstanceData(instance); + if (!data) + return PP_FALSE; + return data->fullscreen; +} + +PP_Bool PPB_Instance_Proxy::SetFullscreen(PP_Instance instance, + PP_Bool fullscreen) { + PP_Bool result = PP_FALSE; + dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetFullscreen( + INTERFACE_ID_PPB_INSTANCE, instance, fullscreen, &result)); + return result; +} + +PP_Bool PPB_Instance_Proxy::GetScreenSize(PP_Instance instance, + PP_Size* size) { + PP_Bool result = PP_FALSE; + dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetScreenSize( + INTERFACE_ID_PPB_INSTANCE, instance, &result, size)); + return result; +} + void PPB_Instance_Proxy::OnMsgGetWindowObject( PP_Instance instance, SerializedVarReturnValue result) { - result.Return(dispatcher(), - ppb_instance_target()->GetWindowObject(instance)); + EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + if (enter.succeeded()) + result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); } void PPB_Instance_Proxy::OnMsgGetOwnerElementObject( PP_Instance instance, SerializedVarReturnValue result) { - result.Return(dispatcher(), - ppb_instance_target()->GetOwnerElementObject(instance)); + EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + if (enter.succeeded()) { + result.Return(dispatcher(), + enter.functions()->GetOwnerElementObject(instance)); + } } void PPB_Instance_Proxy::OnMsgBindGraphics(PP_Instance instance, HostResource device, PP_Bool* result) { - *result = ppb_instance_target()->BindGraphics(instance, - device.host_resource()); + EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + if (enter.succeeded()) { + *result = enter.functions()->BindGraphics(instance, + device.host_resource()); + } } void PPB_Instance_Proxy::OnMsgIsFullFrame(PP_Instance instance, PP_Bool* result) { - *result = ppb_instance_target()->IsFullFrame(instance); + EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + if (enter.succeeded()) + *result = enter.functions()->IsFullFrame(instance); } void PPB_Instance_Proxy::OnMsgExecuteScript( @@ -174,16 +233,36 @@ void PPB_Instance_Proxy::OnMsgExecuteScript( SerializedVarReceiveInput script, SerializedVarOutParam out_exception, SerializedVarReturnValue result) { + EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + if (enter.failed()) + return; + if (dispatcher()->IsPlugin()) NOTREACHED(); else static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); - result.Return(dispatcher(), ppb_instance_target()->ExecuteScript( + result.Return(dispatcher(), enter.functions()->ExecuteScript( instance, script.Get(dispatcher()), out_exception.OutParam(dispatcher()))); } +void PPB_Instance_Proxy::OnMsgSetFullscreen(PP_Instance instance, + PP_Bool fullscreen, + PP_Bool* result) { + EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + if (enter.succeeded()) + *result = enter.functions()->SetFullscreen(instance, fullscreen); +} + +void PPB_Instance_Proxy::OnMsgGetScreenSize(PP_Instance instance, + PP_Bool* result, + PP_Size* size) { + EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); + if (enter.succeeded()) + *result = enter.functions()->GetScreenSize(instance, size); +} + } // namespace proxy } // namespace pp diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index e90e518..b765279 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -10,8 +10,8 @@ #include "ppapi/c/pp_var.h" #include "ppapi/proxy/host_resource.h" #include "ppapi/proxy/interface_proxy.h" - -struct PPB_Instance; +#include "ppapi/shared_impl/function_group_base.h" +#include "ppapi/thunk/ppb_instance_api.h" namespace pp { namespace proxy { @@ -20,20 +20,38 @@ class SerializedVarReceiveInput; class SerializedVarOutParam; class SerializedVarReturnValue; -class PPB_Instance_Proxy : public InterfaceProxy { +class PPB_Instance_Proxy : public InterfaceProxy, + public ppapi::FunctionGroupBase, + public ppapi::thunk::PPB_Instance_FunctionAPI { public: PPB_Instance_Proxy(Dispatcher* dispatcher, const void* target_interface); virtual ~PPB_Instance_Proxy(); - static const Info* GetInfo(); - - const PPB_Instance* ppb_instance_target() const { - return reinterpret_cast<const PPB_Instance*>(target_interface()); - } + static const Info* GetInfo0_4(); + static const Info* GetInfo0_5(); + static const Info* GetInfoPrivate(); + static const Info* GetInfoFullscreen(); // InterfaceProxy implementation. virtual bool OnMessageReceived(const IPC::Message& msg); + // FunctionGroupBase overrides. + ppapi::thunk::PPB_Instance_FunctionAPI* AsPPB_Instance_FunctionAPI() OVERRIDE; + + // PPB_Instance_FunctionAPI implementation. + virtual PP_Bool BindGraphics(PP_Instance instance, + PP_Resource device) OVERRIDE; + virtual PP_Bool IsFullFrame(PP_Instance instance) OVERRIDE; + virtual PP_Var GetWindowObject(PP_Instance instance) OVERRIDE; + virtual PP_Var GetOwnerElementObject(PP_Instance instance) OVERRIDE; + virtual PP_Var ExecuteScript(PP_Instance instance, + PP_Var script, + PP_Var* exception) OVERRIDE; + virtual PP_Bool IsFullscreen(PP_Instance instance) OVERRIDE; + virtual PP_Bool SetFullscreen(PP_Instance instance, + PP_Bool fullscreen) OVERRIDE; + virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) OVERRIDE; + private: // Message handlers. void OnMsgGetWindowObject(PP_Instance instance, @@ -48,6 +66,12 @@ class PPB_Instance_Proxy : public InterfaceProxy { SerializedVarReceiveInput script, SerializedVarOutParam out_exception, SerializedVarReturnValue result); + void OnMsgSetFullscreen(PP_Instance instance, + PP_Bool fullscreen, + PP_Bool* result); + void OnMsgGetScreenSize(PP_Instance instance, + PP_Bool* result, + PP_Size* size); }; } // namespace proxy diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 36b9300..012c800 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -160,6 +160,24 @@ PP_Resource ResourceCreationProxy::CreateImageData(PP_Instance instance, return PluginResourceTracker::GetInstance()->AddResource(object); } +PP_Resource ResourceCreationProxy::CreateSurface3D( + PP_Instance instance, + PP_Config3D_Dev config, + const int32_t* attrib_list) { + NOTREACHED(); + return 0; +} + +PP_Resource ResourceCreationProxy::CreateURLLoader(PP_Instance instance) { + NOTREACHED(); + return 0; +} + +PP_Resource ResourceCreationProxy::CreateURLRequestInfo(PP_Instance instance) { + NOTREACHED(); + return 0; +} + bool ResourceCreationProxy::Send(IPC::Message* msg) { return dispatcher_->Send(msg); } diff --git a/ppapi/proxy/resource_creation_proxy.h b/ppapi/proxy/resource_creation_proxy.h index b95916e..e59734d 100644 --- a/ppapi/proxy/resource_creation_proxy.h +++ b/ppapi/proxy/resource_creation_proxy.h @@ -65,6 +65,11 @@ class ResourceCreationProxy : public ::ppapi::FunctionGroupBase, PP_ImageDataFormat format, const PP_Size& size, PP_Bool init_to_zero) OVERRIDE; + virtual PP_Resource CreateSurface3D(PP_Instance instance, + PP_Config3D_Dev config, + const int32_t* attrib_list) OVERRIDE; + virtual PP_Resource CreateURLLoader(PP_Instance instance) OVERRIDE; + virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) OVERRIDE; virtual bool Send(IPC::Message* msg) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; diff --git a/ppapi/shared_impl/function_group_base.h b/ppapi/shared_impl/function_group_base.h index 6f828ae..23d82d5 100644 --- a/ppapi/shared_impl/function_group_base.h +++ b/ppapi/shared_impl/function_group_base.h @@ -12,6 +12,8 @@ F(PPB_CursorControl_FunctionAPI) \ F(PPB_Find_FunctionAPI) \ F(PPB_Font_FunctionAPI) \ + F(PPB_Fullscreen_FunctionAPI) \ + F(PPB_Instance_FunctionAPI) \ F(ResourceCreationAPI) namespace ppapi { diff --git a/ppapi/shared_impl/resource_object_base.h b/ppapi/shared_impl/resource_object_base.h index 86b6338..e436651 100644 --- a/ppapi/shared_impl/resource_object_base.h +++ b/ppapi/shared_impl/resource_object_base.h @@ -8,9 +8,9 @@ #include <stddef.h> // For NULL. #define FOR_ALL_PPAPI_RESOURCE_APIS(F) \ - F(PPB_Audio_API) \ F(PPB_AudioConfig_API) \ F(PPB_AudioTrusted_API) \ + F(PPB_Audio_API) \ F(PPB_Broker_API) \ F(PPB_Buffer_API) \ F(PPB_BufferTrusted_API) \ @@ -24,7 +24,14 @@ F(PPB_Flash_NetConnector_API) \ F(PPB_Font_API) \ F(PPB_Graphics2D_API) \ - F(PPB_ImageData_API) + F(PPB_ImageData_API) \ + F(PPB_PDFFont_API) \ + F(PPB_Scrollbar_API) \ + F(PPB_Surface3D_API) \ + F(PPB_URLLoader_API) \ + F(PPB_URLRequestInfo_API) \ + F(PPB_URLResponseInfo_API) \ + F(PPB_Widget_API) namespace ppapi { diff --git a/ppapi/thunk/ppb_fullscreen_thunk.cc b/ppapi/thunk/ppb_fullscreen_thunk.cc new file mode 100644 index 0000000..5cc8cc6 --- /dev/null +++ b/ppapi/thunk/ppb_fullscreen_thunk.cc @@ -0,0 +1,50 @@ +// Copyright (c) 2011 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/dev/ppb_fullscreen_dev.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool IsFullscreen(PP_Instance instance) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->IsFullscreen(instance); +} + +PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->SetFullscreen(instance, fullscreen); +} + +PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->GetScreenSize(instance, size); +} + +const PPB_Fullscreen_Dev g_ppb_fullscreen_thunk = { + &IsFullscreen, + &SetFullscreen, + &GetScreenSize +}; + +} // namespace + +const PPB_Fullscreen_Dev* GetPPB_Fullscreen_Thunk() { + return &g_ppb_fullscreen_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h new file mode 100644 index 0000000..a01ac36 --- /dev/null +++ b/ppapi/thunk/ppb_instance_api.h @@ -0,0 +1,41 @@ +// Copyright (c) 2011 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_THUNK_INSTANCE_API_H_ +#define PPAPI_THUNK_INSTANCE_API_H_ + +#include "ppapi/c/ppb_instance.h" +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/c/private/ppb_instance_private.h" +#include "ppapi/proxy/interface_id.h" + +namespace ppapi { +namespace thunk { + +class PPB_Instance_FunctionAPI { + public: + static const ::pp::proxy::InterfaceID interface_id = + ::pp::proxy::INTERFACE_ID_PPB_INSTANCE; + + virtual PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) = 0; + virtual PP_Bool IsFullFrame(PP_Instance instance) = 0; + + // InstancePrivate. + virtual PP_Var GetWindowObject(PP_Instance instance) = 0; + virtual PP_Var GetOwnerElementObject(PP_Instance instance) = 0; + virtual PP_Var ExecuteScript(PP_Instance instance, + PP_Var script, + PP_Var* exception) = 0; + + // Fullscreen. + virtual PP_Bool IsFullscreen(PP_Instance instance) = 0; + virtual PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) = 0; + virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_INSTANCE_API_H_ diff --git a/ppapi/thunk/ppb_instance_thunk.cc b/ppapi/thunk/ppb_instance_thunk.cc new file mode 100644 index 0000000..025e3e0 --- /dev/null +++ b/ppapi/thunk/ppb_instance_thunk.cc @@ -0,0 +1,84 @@ +// Copyright (c) 2011 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/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Var GetWindowObject(PP_Instance instance) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.functions()->GetWindowObject(instance); +} + +PP_Var GetOwnerElementObject(PP_Instance instance) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.functions()->GetOwnerElementObject(instance); +} + +PP_Bool BindGraphics(PP_Instance instance, PP_Resource graphics_id) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->BindGraphics(instance, graphics_id); +} + +PP_Bool IsFullFrame(PP_Instance instance) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->IsFullFrame(instance); +} + +PP_Var ExecuteScript(PP_Instance instance, + PP_Var script, + PP_Var* exception) { + EnterFunction<PPB_Instance_FunctionAPI> enter(instance, true); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.functions()->ExecuteScript(instance, script, exception); +} + +const PPB_Instance_0_5 g_ppb_instance_0_5_thunk = { + &BindGraphics, + &IsFullFrame +}; + +const PPB_Instance_0_4 g_ppb_instance_0_4_thunk = { + &GetWindowObject, + &GetOwnerElementObject, + &BindGraphics, + &IsFullFrame, + &ExecuteScript +}; + +const PPB_Instance_Private g_ppb_instance_private_thunk = { + &GetWindowObject, + &GetOwnerElementObject, + &ExecuteScript +}; + +} // namespace + +const PPB_Instance_0_4* GetPPB_Instance_0_4_Thunk() { + return &g_ppb_instance_0_4_thunk; +} +const PPB_Instance_0_5* GetPPB_Instance_0_5_Thunk() { + return &g_ppb_instance_0_5_thunk; +} +const PPB_Instance_Private* GetPPB_Instance_Private_Thunk() { + return &g_ppb_instance_private_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_pdf_api.h b/ppapi/thunk/ppb_pdf_api.h new file mode 100644 index 0000000..6637376 --- /dev/null +++ b/ppapi/thunk/ppb_pdf_api.h @@ -0,0 +1,24 @@ +// Copyright (c) 2011 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_THUNK_PPB_PDF_API_H_ +#define PPAPI_THUNK_PPB_PDF_API_H_ + +#include "ppapi/c/private/ppb_pdf.h" + +namespace ppapi { +namespace thunk { + +class PPB_PDFFont_API { + private: + virtual bool GetFontTableForPrivateFontFile(PP_Resource font_file, + uint32_t table, + void* output, + uint32_t* output_length) = 0; +} + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK__API_H_ diff --git a/ppapi/thunk/ppb_surface_3d_api.h b/ppapi/thunk/ppb_surface_3d_api.h new file mode 100644 index 0000000..59c6335 --- /dev/null +++ b/ppapi/thunk/ppb_surface_3d_api.h @@ -0,0 +1,23 @@ +// Copyright (c) 2011 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_THUNK_PPB_SURFACE_3D_API_H_ +#define PPAPI_THUNK_PPB_SURFACE_3D_API_H_ + +#include "ppapi/c/dev/ppb_surface_3d_dev.h" + +namespace ppapi { +namespace thunk { + +class PPB_Surface3D_API { + public: + virtual int32_t SetAttrib(int32_t attribute, int32_t value) = 0; + virtual int32_t GetAttrib(int32_t attribute, int32_t* value) = 0; + virtual int32_t SwapBuffers(PP_CompletionCallback callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_SURFACE_3D_API_H_ diff --git a/ppapi/thunk/ppb_surface_3d_thunk.cc b/ppapi/thunk/ppb_surface_3d_thunk.cc new file mode 100644 index 0000000..0c6d9e6 --- /dev/null +++ b/ppapi/thunk/ppb_surface_3d_thunk.cc @@ -0,0 +1,69 @@ +// Copyright (c) 2011 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/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_surface_3d_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance, + PP_Config3D_Dev config, + const int32_t* attrib_list) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateSurface3D(instance, config, attrib_list); +} + +PP_Bool IsSurface3D(PP_Resource resource) { + EnterResource<PPB_Surface3D_API> enter(resource, true); + return PP_FromBool(enter.succeeded()); +} + +int32_t SetAttrib(PP_Resource surface, int32_t attribute, int32_t value) { + EnterResource<PPB_Surface3D_API> enter(surface, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->SetAttrib(attribute, value); +} + +int32_t GetAttrib(PP_Resource surface, + int32_t attribute, + int32_t* value) { + EnterResource<PPB_Surface3D_API> enter(surface, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->GetAttrib(attribute, value); +} + +int32_t SwapBuffers(PP_Resource surface, + PP_CompletionCallback callback) { + EnterResource<PPB_Surface3D_API> enter(surface, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->SwapBuffers(callback); +} + +const PPB_Surface3D_Dev g_ppb_surface_3d_thunk = { + &Create, + &IsSurface3D, + &SetAttrib, + &GetAttrib, + &SwapBuffers +}; + +} // namespace + +const PPB_Surface3D_Dev* GetPPB_Surface3D_Thunk() { + return &g_ppb_surface_3d_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_url_loader_api.h b/ppapi/thunk/ppb_url_loader_api.h new file mode 100644 index 0000000..cd44c26 --- /dev/null +++ b/ppapi/thunk/ppb_url_loader_api.h @@ -0,0 +1,38 @@ +// Copyright (c) 2011 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_THUNK_URL_LOADER_API_H_ +#define PPAPI_THUNK_URL_LOADER_API_H_ + +#include "ppapi/c/ppb_url_loader.h" +#include "ppapi/c/trusted/ppb_url_loader_trusted.h" + +namespace ppapi { +namespace thunk { + +class PPB_URLLoader_API { + public: + virtual int32_t Open(PP_Resource request_id, + PP_CompletionCallback callback) = 0; + virtual int32_t FollowRedirect(PP_CompletionCallback callback) = 0; + virtual PP_Bool GetUploadProgress(int64_t* bytes_sent, + int64_t* total_bytes_to_be_sent) = 0; + virtual PP_Bool GetDownloadProgress(int64_t* bytes_received, + int64_t* total_bytes_to_be_received) = 0; + virtual PP_Resource GetResponseInfo() = 0; + virtual int32_t ReadResponseBody(void* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) = 0; + virtual int32_t FinishStreamingToFile(PP_CompletionCallback callback) = 0; + virtual void Close() = 0; + + // Trusted API. + virtual void GrantUniversalAccess() = 0; + virtual void SetStatusCallback(PP_URLLoaderTrusted_StatusCallback cb) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_URL_LOADER_API_H_ diff --git a/ppapi/thunk/ppb_url_loader_thunk.cc b/ppapi/thunk/ppb_url_loader_thunk.cc new file mode 100644 index 0000000..e5c0b5a --- /dev/null +++ b/ppapi/thunk/ppb_url_loader_thunk.cc @@ -0,0 +1,145 @@ +// Copyright (c) 2011 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_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_url_loader_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateURLLoader(instance); +} + +PP_Bool IsURLLoader(PP_Resource resource) { + EnterResource<PPB_URLLoader_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t Open(PP_Resource loader, + PP_Resource request_id, + PP_CompletionCallback callback) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->Open(request_id, callback); +} + +int32_t FollowRedirect(PP_Resource loader, + PP_CompletionCallback callback) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->FollowRedirect(callback); +} + +PP_Bool GetUploadProgress(PP_Resource loader, + int64_t* bytes_sent, + int64_t* total_bytes_to_be_sent) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) { + *bytes_sent = 0; + *total_bytes_to_be_sent = 0; + return PP_FALSE; + } + return enter.object()->GetUploadProgress(bytes_sent, + total_bytes_to_be_sent); +} + +PP_Bool GetDownloadProgress(PP_Resource loader, + int64_t* bytes_received, + int64_t* total_bytes_to_be_received) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) { + *bytes_received = 0; + *total_bytes_to_be_received = 0; + return PP_FALSE; + } + return enter.object()->GetDownloadProgress(bytes_received, + total_bytes_to_be_received); +} + +PP_Resource GetResponseInfo(PP_Resource loader) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return 0; + return enter.object()->GetResponseInfo(); +} + +int32_t ReadResponseBody(PP_Resource loader, + void* buffer, + int32_t bytes_to_read, + PP_CompletionCallback callback) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->ReadResponseBody(buffer, bytes_to_read, callback); +} + +int32_t FinishStreamingToFile(PP_Resource loader, + PP_CompletionCallback callback) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + return enter.object()->FinishStreamingToFile(callback); +} + +void Close(PP_Resource loader) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.succeeded()) + enter.object()->Close(); +} + +void GrantUniversalAccess(PP_Resource loader) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.succeeded()) + enter.object()->GrantUniversalAccess(); +} + +void SetStatusCallback(PP_Resource loader, + PP_URLLoaderTrusted_StatusCallback cb) { + EnterResource<PPB_URLLoader_API> enter(loader, true); + if (enter.succeeded()) + enter.object()->SetStatusCallback(cb); +} + +const PPB_URLLoader g_ppb_urlloader_thunk = { + &Create, + &IsURLLoader, + &Open, + &FollowRedirect, + &GetUploadProgress, + &GetDownloadProgress, + &GetResponseInfo, + &ReadResponseBody, + &FinishStreamingToFile, + &Close +}; + +const PPB_URLLoaderTrusted g_ppb_urlloader_trusted_thunk = { + &GrantUniversalAccess, + &SetStatusCallback +}; + +} // namespace + +const PPB_URLLoader* GetPPB_URLLoader_Thunk() { + return &g_ppb_urlloader_thunk; +} + +const PPB_URLLoaderTrusted* GetPPB_URLLoaderTrusted_Thunk() { + return &g_ppb_urlloader_trusted_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_url_request_info_api.h b/ppapi/thunk/ppb_url_request_info_api.h new file mode 100644 index 0000000..46656abf --- /dev/null +++ b/ppapi/thunk/ppb_url_request_info_api.h @@ -0,0 +1,27 @@ +// Copyright (c) 2011 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_THUNK_URL_REQUEST_INFO_API_H_ +#define PPAPI_THUNK_URL_REQUEST_INFO_API_H_ + +#include "ppapi/c/ppb_url_request_info.h" + +namespace ppapi { +namespace thunk { + +class PPB_URLRequestInfo_API { + public: + virtual PP_Bool SetProperty(PP_URLRequestProperty property, + PP_Var var) = 0; + virtual PP_Bool AppendDataToBody(const void* data, uint32_t len) = 0; + virtual PP_Bool AppendFileToBody(PP_Resource file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_URL_REQUEST_INFO_API_H_ diff --git a/ppapi/thunk/ppb_url_request_info_thunk.cc b/ppapi/thunk/ppb_url_request_info_thunk.cc new file mode 100644 index 0000000..5c99d18 --- /dev/null +++ b/ppapi/thunk/ppb_url_request_info_thunk.cc @@ -0,0 +1,72 @@ +// Copyright (c) 2011 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/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_url_request_info_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + EnterFunction<ResourceCreationAPI> enter(instance, true); + if (enter.failed()) + return 0; + return enter.functions()->CreateURLRequestInfo(instance); +} + +PP_Bool IsURLRequestInfo(PP_Resource resource) { + EnterResource<PPB_URLRequestInfo_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +PP_Bool SetProperty(PP_Resource request, + PP_URLRequestProperty property, + PP_Var var) { + EnterResource<PPB_URLRequestInfo_API> enter(request, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->SetProperty(property, var); +} + +PP_Bool AppendDataToBody(PP_Resource request, + const void* data, uint32_t len) { + EnterResource<PPB_URLRequestInfo_API> enter(request, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->AppendDataToBody(data, len); +} + +PP_Bool AppendFileToBody(PP_Resource request, + PP_Resource file_ref, + int64_t start_offset, + int64_t number_of_bytes, + PP_Time expected_last_modified_time) { + EnterResource<PPB_URLRequestInfo_API> enter(request, true); + if (enter.failed()) + return PP_FALSE; + return enter.object()->AppendFileToBody(file_ref, start_offset, + number_of_bytes, + expected_last_modified_time); +} + +const PPB_URLRequestInfo g_ppb_url_request_info_thunk = { + &Create, + &IsURLRequestInfo, + &SetProperty, + &AppendDataToBody, + &AppendFileToBody +}; + +} // namespace + +const PPB_URLRequestInfo* GetPPB_URLRequestInfo_Thunk() { + return &g_ppb_url_request_info_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_url_response_info_api.h b/ppapi/thunk/ppb_url_response_info_api.h new file mode 100644 index 0000000..f62ac48 --- /dev/null +++ b/ppapi/thunk/ppb_url_response_info_api.h @@ -0,0 +1,22 @@ +// Copyright (c) 2011 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_THUNK_PPB_URL_RESPONSE_INFO_API_H_ +#define PPAPI_THUNK_PPB_URL_RESPONSE_INFO_API_H_ + +#include "ppapi/c/ppb_url_response_info.h" + +namespace ppapi { +namespace thunk { + +class PPB_URLResponseInfo_API { + public: + virtual PP_Var GetProperty(PP_URLResponseProperty property) = 0; + virtual PP_Resource GetBodyAsFileRef() = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_URL_LOADER_API_H_ diff --git a/ppapi/thunk/ppb_url_response_info_thunk.cc b/ppapi/thunk/ppb_url_response_info_thunk.cc new file mode 100644 index 0000000..3fecb936 --- /dev/null +++ b/ppapi/thunk/ppb_url_response_info_thunk.cc @@ -0,0 +1,47 @@ +// Copyright (c) 2011 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/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_url_response_info_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool IsURLResponseInfo(PP_Resource resource) { + EnterResource<PPB_URLResponseInfo_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +PP_Var GetProperty(PP_Resource response, PP_URLResponseProperty property) { + EnterResource<PPB_URLResponseInfo_API> enter(response, true); + if (!enter.succeeded()) + return PP_MakeUndefined(); + return enter.object()->GetProperty(property); +} + +PP_Resource GetBodyAsFileRef(PP_Resource response) { + EnterResource<PPB_URLResponseInfo_API> enter(response, true); + if (!enter.succeeded()) + return 0; + return enter.object()->GetBodyAsFileRef(); +} + +const PPB_URLResponseInfo g_ppb_url_response_info_thunk = { + &IsURLResponseInfo, + &GetProperty, + &GetBodyAsFileRef +}; + +} // namespace + +const PPB_URLResponseInfo* GetPPB_URLResponseInfo_Thunk() { + return &g_ppb_url_response_info_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_widget_api.h b/ppapi/thunk/ppb_widget_api.h new file mode 100644 index 0000000..e278f73 --- /dev/null +++ b/ppapi/thunk/ppb_widget_api.h @@ -0,0 +1,24 @@ +// Copyright (c) 2011 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_THUNK_PPB_WIDGET_API_H_ +#define PPAPI_THUNK_PPB_WIDGET_API_H_ + +#include "ppapi/c/dev/ppb_widget_dev.h" + +namespace ppapi { +namespace thunk { + +class PPB_Widget_API { + public: + virtual PP_Bool Paint(const PP_Rect* rect, PP_Resource image_id) = 0; + virtual PP_Bool HandleEvent(const PP_InputEvent* event) = 0; + virtual PP_Bool GetLocation(PP_Rect* location) = 0; + virtual void SetLocation(const PP_Rect* location) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_WIDGET_API_H_ diff --git a/ppapi/thunk/ppb_widget_thunk.cc b/ppapi/thunk/ppb_widget_thunk.cc new file mode 100644 index 0000000..7834a7a --- /dev/null +++ b/ppapi/thunk/ppb_widget_thunk.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2011 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/thunk/thunk.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_widget_api.h" +#include "ppapi/thunk/resource_creation_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Bool IsWidget(PP_Resource resource) { + EnterResource<PPB_Widget_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +PP_Bool Paint(PP_Resource widget, const PP_Rect* rect, PP_Resource image_id) { + EnterResource<PPB_Widget_API> enter(widget, false); + if (enter.failed()) + return PP_FALSE; + return enter.object()->Paint(rect, image_id); +} + +PP_Bool HandleEvent(PP_Resource widget, const PP_InputEvent* event) { + EnterResource<PPB_Widget_API> enter(widget, false); + if (enter.failed()) + return PP_FALSE; + return enter.object()->HandleEvent(event); +} + +PP_Bool GetLocation(PP_Resource widget, PP_Rect* location) { + EnterResource<PPB_Widget_API> enter(widget, false); + if (enter.failed()) + return PP_FALSE; + return enter.object()->GetLocation(location); +} + +void SetLocation(PP_Resource widget, const PP_Rect* location) { + EnterResource<PPB_Widget_API> enter(widget, false); + if (enter.succeeded()) + enter.object()->SetLocation(location); +} + +const PPB_Widget_Dev g_ppb_widget_thunk = { + &IsWidget, + &Paint, + &HandleEvent, + &GetLocation, + &SetLocation, +}; + +} // namespace + +const PPB_Widget_Dev* GetPPB_Widget_Thunk() { + return &g_ppb_widget_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/resource_creation_api.h b/ppapi/thunk/resource_creation_api.h index cbaf92e..11b532f 100644 --- a/ppapi/thunk/resource_creation_api.h +++ b/ppapi/thunk/resource_creation_api.h @@ -7,6 +7,7 @@ #include "ppapi/c/dev/ppb_file_chooser_dev.h" #include "ppapi/c/dev/ppb_file_system_dev.h" +#include "ppapi/c/dev/ppb_graphics_3d_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" #include "ppapi/c/pp_resource.h" @@ -65,6 +66,11 @@ class ResourceCreationAPI { PP_ImageDataFormat format, const PP_Size& size, PP_Bool init_to_zero) = 0; + virtual PP_Resource CreateSurface3D(PP_Instance instance, + PP_Config3D_Dev config, + const int32_t* attrib_list) = 0; + virtual PP_Resource CreateURLLoader(PP_Instance instance) = 0; + virtual PP_Resource CreateURLRequestInfo(PP_Instance instance) = 0; }; } // namespace thunk diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index 78b1b80..8662729 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -23,10 +23,21 @@ struct PPB_Find_Dev; struct PPB_Flash_Menu; struct PPB_Flash_NetConnector; struct PPB_Font_Dev; +struct PPB_Fullscreen_Dev; struct PPB_Graphics2D; struct PPB_ImageData; +struct PPB_Instance; +struct PPB_Instance_Private; struct PPB_ImageDataTrusted; +#ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING +struct PPB_Instance_0_4; +typedef PPB_Instance PPB_Instance_0_5; +#else +struct PPB_Instance_0_5; +typedef PPB_Instance PPB_Instance_0_4; +#endif + namespace ppapi { namespace thunk { @@ -48,8 +59,12 @@ const PPB_Find_Dev* GetPPB_Find_Thunk(); const PPB_Flash_Menu* GetPPB_Flash_Menu_Thunk(); const PPB_Flash_NetConnector* GetPPB_Flash_NetConnector_Thunk(); const PPB_Font_Dev* GetPPB_Font_Thunk(); +const PPB_Fullscreen_Dev* GetPPB_Fullscreen_Thunk(); const PPB_Graphics2D* GetPPB_Graphics2D_Thunk(); const PPB_ImageData* GetPPB_ImageData_Thunk(); +const PPB_Instance_0_4* GetPPB_Instance_0_4_Thunk(); +const PPB_Instance_0_5* GetPPB_Instance_0_5_Thunk(); +const PPB_Instance_Private* GetPPB_Instance_Private_Thunk(); const PPB_ImageDataTrusted* GetPPB_ImageDataTrusted_Thunk(); } // namespace thunk |