diff options
author | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 16:43:43 +0000 |
---|---|---|
committer | dmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-25 16:43:43 +0000 |
commit | 792f1ca3760f004b12ce78911c4afb23ef4b7bdd (patch) | |
tree | 98ae2816b7cc5f06019ad9a34950b029f9e71343 /ppapi | |
parent | 3857cb104c48d9a90a2439452780f96499fe2d00 (diff) | |
download | chromium_src-792f1ca3760f004b12ce78911c4afb23ef4b7bdd.zip chromium_src-792f1ca3760f004b12ce78911c4afb23ef4b7bdd.tar.gz chromium_src-792f1ca3760f004b12ce78911c4afb23ef4b7bdd.tar.bz2 |
Proxy PPB_Instance_Private and PPP_Instance_Private.
BUG=82356
TEST=Run example plugin out-of-process, click on it. Before this, it crashes the plugin. After, behaves as expected.
Review URL: http://codereview.chromium.org/6966043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86640 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/ppapi_proxy.gypi | 4 | ||||
-rw-r--r-- | ppapi/proxy/dispatcher.cc | 4 | ||||
-rw-r--r-- | ppapi/proxy/interface_id.h | 2 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 18 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_private_proxy.cc | 143 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_private_proxy.h | 53 | ||||
-rw-r--r-- | ppapi/proxy/ppp_instance_private_proxy.cc | 78 | ||||
-rw-r--r-- | ppapi/proxy/ppp_instance_private_proxy.h | 45 |
8 files changed, 347 insertions, 0 deletions
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 06ed0ff..1fadbc5 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -100,6 +100,8 @@ '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', @@ -124,6 +126,8 @@ 'proxy/ppp_class_proxy.h', 'proxy/ppp_graphics_3d_proxy.cc', 'proxy/ppp_graphics_3d_proxy.h', + 'proxy/ppp_instance_private_proxy.cc', + 'proxy/ppp_instance_private_proxy.h', 'proxy/ppp_instance_proxy.cc', 'proxy/ppp_instance_proxy.h', 'proxy/proxy_channel.cc', diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc index b34ce48..498aadc 100644 --- a/ppapi/proxy/dispatcher.cc +++ b/ppapi/proxy/dispatcher.cc @@ -66,6 +66,7 @@ #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" @@ -78,6 +79,7 @@ #include "ppapi/proxy/ppb_var_deprecated_proxy.h" #include "ppapi/proxy/ppp_class_proxy.h" #include "ppapi/proxy/ppp_graphics_3d_proxy.h" +#include "ppapi/proxy/ppp_instance_private_proxy.h" #include "ppapi/proxy/ppp_instance_proxy.h" #include "ppapi/proxy/var_serialization_rules.h" @@ -130,6 +132,7 @@ InterfaceList::InterfaceList() { 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_OpenGLES2_Proxy::GetInfo()); AddPPB(PPB_PDF_Proxy::GetInfo()); @@ -148,6 +151,7 @@ InterfaceList::InterfaceList() { // PPP (plugin) interfaces. AddPPP(PPP_Graphics3D_Proxy::GetInfo()); + AddPPP(PPP_Instance_Private_Proxy::GetInfo()); AddPPP(PPP_Instance_Proxy::GetInfo()); } diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h index eef19cb..039008c 100644 --- a/ppapi/proxy/interface_id.h +++ b/ppapi/proxy/interface_id.h @@ -38,6 +38,7 @@ enum InterfaceID { INTERFACE_ID_PPB_GRAPHICS_2D, INTERFACE_ID_PPB_IMAGE_DATA, INTERFACE_ID_PPB_INSTANCE, + INTERFACE_ID_PPB_INSTANCE_PRIVATE, INTERFACE_ID_PPB_OPENGLES2, INTERFACE_ID_PPB_PDF, INTERFACE_ID_PPB_SURFACE_3D, @@ -54,6 +55,7 @@ enum InterfaceID { INTERFACE_ID_PPP_CLASS, INTERFACE_ID_PPP_GRAPHICS_3D_DEV, INTERFACE_ID_PPP_INSTANCE, + INTERFACE_ID_PPP_INSTANCE_PRIVATE, INTERFACE_ID_PPP_VIDEO_DECODER_DEV, INTERFACE_ID_RESOURCE_CREATION, diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 6a313ee..cd65fe8 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -229,6 +229,10 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPInstance_GetInstanceObject, PP_Instance /* instance */, pp::proxy::SerializedVar /* result */) +// PPP_Instance_Private. +IPC_SYNC_MESSAGE_ROUTED1_1(PpapiMsg_PPPInstancePrivate_GetInstanceObject, + PP_Instance /* instance */, + pp::proxy::SerializedVar /* result */) // PPB_URLLoader // (Messages from browser to plugin to notify it of changes in state.) @@ -570,6 +574,20 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBInstance_ExecuteScript, pp::proxy::SerializedVar /* out_exception */, pp::proxy::SerializedVar /* result */) +// PPB_Instance_Private. +IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstancePrivate_GetWindowObject, + 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_Instance /* instance */, + pp::proxy::SerializedVar /* script */, + pp::proxy::SerializedVar /* out_exception */, + pp::proxy::SerializedVar /* result */) + IPC_SYNC_MESSAGE_ROUTED3_1( PpapiHostMsg_PPBPDF_GetFontFileWithFallback, PP_Instance /* instance */, diff --git a/ppapi/proxy/ppb_instance_private_proxy.cc b/ppapi/proxy/ppb_instance_private_proxy.cc new file mode 100644 index 0000000..1029372 --- /dev/null +++ b/ppapi/proxy/ppb_instance_private_proxy.cc @@ -0,0 +1,143 @@ +// 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 new file mode 100644 index 0000000..11062ee --- /dev/null +++ b/ppapi/proxy/ppb_instance_private_proxy.h @@ -0,0 +1,53 @@ +// 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/ppp_instance_private_proxy.cc b/ppapi/proxy/ppp_instance_private_proxy.cc new file mode 100644 index 0000000..20beb8a --- /dev/null +++ b/ppapi/proxy/ppp_instance_private_proxy.cc @@ -0,0 +1,78 @@ +// 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/ppp_instance_private_proxy.h" + +#include <algorithm> + +#include "ppapi/c/pp_var.h" +#include "ppapi/c/private/ppp_instance_private.h" +#include "ppapi/proxy/host_dispatcher.h" +#include "ppapi/proxy/plugin_dispatcher.h" +#include "ppapi/proxy/plugin_resource_tracker.h" +#include "ppapi/proxy/ppapi_messages.h" + +namespace pp { +namespace proxy { + +namespace { + +PP_Var GetInstanceObject(PP_Instance instance) { + Dispatcher* dispatcher = HostDispatcher::GetForInstance(instance); + ReceiveSerializedVarReturnValue result; + dispatcher->Send(new PpapiMsg_PPPInstancePrivate_GetInstanceObject( + INTERFACE_ID_PPP_INSTANCE_PRIVATE, instance, &result)); + return result.Return(dispatcher); +} + +static const PPP_Instance_Private instance_private_interface = { + &GetInstanceObject +}; + +InterfaceProxy* CreateInstancePrivateProxy(Dispatcher* dispatcher, + const void* target_interface) { + return new PPP_Instance_Private_Proxy(dispatcher, target_interface); +} + +} // namespace + +PPP_Instance_Private_Proxy::PPP_Instance_Private_Proxy( + Dispatcher* dispatcher, const void* target_interface) + : InterfaceProxy(dispatcher, target_interface) { +} + +PPP_Instance_Private_Proxy::~PPP_Instance_Private_Proxy() { +} + +// static +const InterfaceProxy::Info* PPP_Instance_Private_Proxy::GetInfo() { + static const Info info = { + &instance_private_interface, + PPP_INSTANCE_PRIVATE_INTERFACE, + INTERFACE_ID_PPP_INSTANCE_PRIVATE, + false, + &CreateInstancePrivateProxy, + }; + return &info; +} + +bool PPP_Instance_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(PPP_Instance_Private_Proxy, msg) + IPC_MESSAGE_HANDLER(PpapiMsg_PPPInstancePrivate_GetInstanceObject, + OnMsgGetInstanceObject) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void PPP_Instance_Private_Proxy::OnMsgGetInstanceObject( + PP_Instance instance, + SerializedVarReturnValue result) { + result.Return(dispatcher(), + ppp_instance_private_target()->GetInstanceObject(instance)); +} + +} // namespace proxy +} // namespace pp diff --git a/ppapi/proxy/ppp_instance_private_proxy.h b/ppapi/proxy/ppp_instance_private_proxy.h new file mode 100644 index 0000000..1df2e44 --- /dev/null +++ b/ppapi/proxy/ppp_instance_private_proxy.h @@ -0,0 +1,45 @@ +// 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_PPP_INSTANCE_PRIVATE_PROXY_H_ +#define PPAPI_PROXY_PPP_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 PPP_Instance_Private; + +namespace pp { +namespace proxy { + +class SerializedVarReturnValue; + +class PPP_Instance_Private_Proxy : public InterfaceProxy { + public: + PPP_Instance_Private_Proxy(Dispatcher* dispatcher, + const void* target_interface); + virtual ~PPP_Instance_Private_Proxy(); + + static const Info* GetInfo(); + + const PPP_Instance_Private* ppp_instance_private_target() const { + return reinterpret_cast<const PPP_Instance_Private*>(target_interface()); + } + + private: + // InterfaceProxy implementation. + virtual bool OnMessageReceived(const IPC::Message& msg); + + // Message handlers. + void OnMsgGetInstanceObject(PP_Instance instance, + SerializedVarReturnValue result); +}; + +} // namespace proxy +} // namespace pp + +#endif // PPAPI_PROXY_PPP_INSTANCE_PRIVATE_PROXY_H_ |