diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-11 04:54:31 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-11 04:54:31 +0000 |
commit | 8d770e49e726ba87cb5b91b2cbf760c57e3f0f68 (patch) | |
tree | 0453c90403154a9f001b426a36b1b4d0f98c90ef /ppapi/proxy | |
parent | 2cb3e6c67ad02e3bf137f74493d28f74ca772527 (diff) | |
download | chromium_src-8d770e49e726ba87cb5b91b2cbf760c57e3f0f68.zip chromium_src-8d770e49e726ba87cb5b91b2cbf760c57e3f0f68.tar.gz chromium_src-8d770e49e726ba87cb5b91b2cbf760c57e3f0f68.tar.bz2 |
Convert the charset, memory, and crypto interfaces to use the thunk system.
This removes a bunch of plumbing for the proxy and impl sides, and uses the
new macro system for registering the interface. This saves a lot of code and
a bunch of boilerplate files could be deleted.
Review URL: http://codereview.chromium.org/8159003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r-- | ppapi/proxy/interface_id.h | 2 | ||||
-rw-r--r-- | ppapi/proxy/interface_list.cc | 6 | ||||
-rw-r--r-- | ppapi/proxy/plugin_dispatcher.cc | 1 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 8 | ||||
-rw-r--r-- | ppapi/proxy/ppb_char_set_proxy.cc | 86 | ||||
-rw-r--r-- | ppapi/proxy/ppb_char_set_proxy.h | 60 | ||||
-rw-r--r-- | ppapi/proxy/ppb_crypto_proxy.cc | 52 | ||||
-rw-r--r-- | ppapi/proxy/ppb_crypto_proxy.h | 33 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.cc | 21 | ||||
-rw-r--r-- | ppapi/proxy/ppb_instance_proxy.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppb_memory_proxy.cc | 37 | ||||
-rw-r--r-- | ppapi/proxy/ppb_memory_proxy.h | 20 |
12 files changed, 27 insertions, 302 deletions
diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h index a2f97df..08ef071 100644 --- a/ppapi/proxy/interface_id.h +++ b/ppapi/proxy/interface_id.h @@ -17,10 +17,8 @@ enum InterfaceID { INTERFACE_ID_PPB_AUDIO_CONFIG, INTERFACE_ID_PPB_BROKER, INTERFACE_ID_PPB_BUFFER, - INTERFACE_ID_PPB_CHAR_SET, INTERFACE_ID_PPB_CONTEXT_3D, INTERFACE_ID_PPB_CORE, - INTERFACE_ID_PPB_CRYPTO, INTERFACE_ID_PPB_CURSORCONTROL, INTERFACE_ID_PPB_FILE_CHOOSER, INTERFACE_ID_PPB_FILE_REF, diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index c317fc3..c88ccd1 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -55,10 +55,8 @@ #include "ppapi/proxy/ppb_audio_proxy.h" #include "ppapi/proxy/ppb_broker_proxy.h" #include "ppapi/proxy/ppb_buffer_proxy.h" -#include "ppapi/proxy/ppb_char_set_proxy.h" #include "ppapi/proxy/ppb_context_3d_proxy.h" #include "ppapi/proxy/ppb_core_proxy.h" -#include "ppapi/proxy/ppb_crypto_proxy.h" #include "ppapi/proxy/ppb_cursor_control_proxy.h" #include "ppapi/proxy/ppb_file_chooser_proxy.h" #include "ppapi/proxy/ppb_file_ref_proxy.h" @@ -75,7 +73,6 @@ #include "ppapi/proxy/ppb_graphics_3d_proxy.h" #include "ppapi/proxy/ppb_image_data_proxy.h" #include "ppapi/proxy/ppb_instance_proxy.h" -#include "ppapi/proxy/ppb_memory_proxy.h" #include "ppapi/proxy/ppp_mouse_lock_proxy.h" #include "ppapi/proxy/ppb_pdf_proxy.h" #include "ppapi/proxy/ppb_surface_3d_proxy.h" @@ -171,15 +168,12 @@ InterfaceList::InterfaceList() { AddProxy(INTERFACE_ID_PPP_CLASS, &PPP_Class_Proxy::Create); AddPPB(PPB_CORE_INTERFACE, INTERFACE_ID_PPB_CORE, PPB_Core_Proxy::GetPPB_Core_Interface()); - AddPPB(PPB_MEMORY_DEV_INTERFACE, INTERFACE_ID_NONE, - GetPPB_Memory_Interface()); AddPPB(PPB_OPENGLES2_INTERFACE, INTERFACE_ID_NONE, OpenGLES2Impl::GetInterface()); AddPPB(PPB_VAR_INTERFACE, INTERFACE_ID_NONE, GetPPB_Var_Interface()); // PPB (browser) interfaces. - AddPPB(PPB_Crypto_Proxy::GetInfo()); AddPPB(PPB_Flash_Clipboard_Proxy::GetInfo()); AddPPB(PPB_Flash_File_FileRef_Proxy::GetInfo()); AddPPB(PPB_Flash_File_ModuleLocal_Proxy::GetInfo()); diff --git a/ppapi/proxy/plugin_dispatcher.cc b/ppapi/proxy/plugin_dispatcher.cc index d1b3476..2bed859 100644 --- a/ppapi/proxy/plugin_dispatcher.cc +++ b/ppapi/proxy/plugin_dispatcher.cc @@ -19,7 +19,6 @@ #include "ppapi/proxy/plugin_resource_tracker.h" #include "ppapi/proxy/plugin_var_serialization_rules.h" #include "ppapi/proxy/ppapi_messages.h" -#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" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index aada5ee..a650577 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -546,11 +546,6 @@ IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_AddRefResource, IPC_MESSAGE_ROUTED1(PpapiHostMsg_PPBCore_ReleaseResource, ppapi::HostResource) -// PPB_CharSet. -IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBCharSet_GetDefaultCharSet, - PP_Instance /* instance */, - ppapi::proxy::SerializedVar /* result */) - // PPB_CursorControl. IPC_SYNC_MESSAGE_ROUTED4_1(PpapiHostMsg_PPBCursorControl_SetCursor, PP_Instance /* instance */, @@ -856,6 +851,9 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBInstance_ExecuteScript, ppapi::proxy::SerializedVar /* script */, ppapi::proxy::SerializedVar /* out_exception */, ppapi::proxy::SerializedVar /* result */) +IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBInstance_GetDefaultCharSet, + PP_Instance /* instance */, + ppapi::proxy::SerializedVar /* result */) IPC_MESSAGE_ROUTED3(PpapiHostMsg_PPBInstance_Log, PP_Instance /* instance */, int /* log_level */, diff --git a/ppapi/proxy/ppb_char_set_proxy.cc b/ppapi/proxy/ppb_char_set_proxy.cc deleted file mode 100644 index 52610f3..0000000 --- a/ppapi/proxy/ppb_char_set_proxy.cc +++ /dev/null @@ -1,86 +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_char_set_proxy.h" - -#include "base/basictypes.h" -#include "ppapi/c/dev/ppb_char_set_dev.h" -#include "ppapi/c/dev/ppb_memory_dev.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/proxy/ppb_memory_proxy.h" -#include "ppapi/proxy/serialized_var.h" -#include "ppapi/shared_impl/char_set_impl.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/thunk.h" - -namespace ppapi { -namespace proxy { - -PPB_CharSet_Proxy::PPB_CharSet_Proxy(Dispatcher* dispatcher) - : InterfaceProxy(dispatcher) { -} - -PPB_CharSet_Proxy::~PPB_CharSet_Proxy() { -} - -ppapi::thunk::PPB_CharSet_FunctionAPI* -PPB_CharSet_Proxy::AsPPB_CharSet_FunctionAPI() { - return this; -} - -char* PPB_CharSet_Proxy::UTF16ToCharSet( - PP_Instance instance, - const uint16_t* utf16, uint32_t utf16_len, - const char* output_char_set, - PP_CharSet_ConversionError on_error, - uint32_t* output_length) { - return ppapi::CharSetImpl::UTF16ToCharSet( - GetPPB_Memory_Interface(), utf16, utf16_len, - output_char_set, on_error, output_length); -} - -uint16_t* PPB_CharSet_Proxy::CharSetToUTF16( - PP_Instance instance, - const char* input, uint32_t input_len, - const char* input_char_set, - PP_CharSet_ConversionError on_error, - uint32_t* output_length) { - return ppapi::CharSetImpl::CharSetToUTF16( - GetPPB_Memory_Interface(), input, input_len, - input_char_set, on_error, output_length); -} - -PP_Var PPB_CharSet_Proxy::GetDefaultCharSet(PP_Instance instance) { - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); - if (!dispatcher) - return PP_MakeUndefined(); - - ReceiveSerializedVarReturnValue result; - dispatcher->Send(new PpapiHostMsg_PPBCharSet_GetDefaultCharSet( - INTERFACE_ID_PPB_CHAR_SET, instance, &result)); - return result.Return(dispatcher); -} - -bool PPB_CharSet_Proxy::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_CharSet_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCharSet_GetDefaultCharSet, - OnMsgGetDefaultCharSet) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void PPB_CharSet_Proxy::OnMsgGetDefaultCharSet( - PP_Instance instance, - SerializedVarReturnValue result) { - ppapi::thunk::EnterFunctionNoLock<ppapi::thunk::PPB_CharSet_FunctionAPI> - enter(instance, true); - if (enter.succeeded()) - result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance)); -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_char_set_proxy.h b/ppapi/proxy/ppb_char_set_proxy.h deleted file mode 100644 index 39ddc7b..0000000 --- a/ppapi/proxy/ppb_char_set_proxy.h +++ /dev/null @@ -1,60 +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_CHAR_SET_PROXY_H_ -#define PPAPI_PROXY_PPB_CHAR_SET_PROXY_H_ - -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" -#include "ppapi/proxy/interface_proxy.h" -#include "ppapi/shared_impl/function_group_base.h" -#include "ppapi/thunk/ppb_char_set_api.h" - -struct PPB_CharSet_Dev; -struct PPB_Core; - -namespace ppapi { -namespace proxy { - -class SerializedVarReturnValue; - -class PPB_CharSet_Proxy : public InterfaceProxy, - public ppapi::thunk::PPB_CharSet_FunctionAPI { - public: - PPB_CharSet_Proxy(Dispatcher* dispatcher); - virtual ~PPB_CharSet_Proxy(); - - // FunctionGroupBase overrides. - virtual ppapi::thunk::PPB_CharSet_FunctionAPI* AsPPB_CharSet_FunctionAPI() - OVERRIDE; - - // PPB_CharSet_FunctionAPI implementation. - virtual char* UTF16ToCharSet(PP_Instance instance, - const uint16_t* utf16, uint32_t utf16_len, - const char* output_char_set, - PP_CharSet_ConversionError on_error, - uint32_t* output_length) OVERRIDE; - virtual uint16_t* CharSetToUTF16(PP_Instance instance, - const char* input, uint32_t input_len, - const char* input_char_set, - PP_CharSet_ConversionError on_error, - uint32_t* output_length) OVERRIDE; - virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE; - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; - - static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_CHAR_SET; - - private: - void OnMsgGetDefaultCharSet(PP_Instance instance, - SerializedVarReturnValue result); - - DISALLOW_COPY_AND_ASSIGN(PPB_CharSet_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_CHAR_SET_PROXY_H_ diff --git a/ppapi/proxy/ppb_crypto_proxy.cc b/ppapi/proxy/ppb_crypto_proxy.cc deleted file mode 100644 index e80e17a..0000000 --- a/ppapi/proxy/ppb_crypto_proxy.cc +++ /dev/null @@ -1,52 +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_crypto_proxy.h" - -#include "ppapi/c/dev/ppb_crypto_dev.h" -#include "ppapi/proxy/interface_id.h" -#include "ppapi/shared_impl/crypto_impl.h" - -namespace ppapi { -namespace proxy { - -namespace { - -const PPB_Crypto_Dev crypto_interface = { - &ppapi::CryptoImpl::GetRandomBytes -}; - -InterfaceProxy* CreateCryptoProxy(Dispatcher* dispatcher) { - return new PPB_Crypto_Proxy(dispatcher); -} - -} // namespace - -PPB_Crypto_Proxy::PPB_Crypto_Proxy(Dispatcher* dispatcher) - : InterfaceProxy(dispatcher) { - NOTREACHED(); // See comment in the header file. -} - -PPB_Crypto_Proxy::~PPB_Crypto_Proxy() { -} - -// static -const InterfaceProxy::Info* PPB_Crypto_Proxy::GetInfo() { - static const Info info = { - &crypto_interface, - PPB_CRYPTO_DEV_INTERFACE, - INTERFACE_ID_PPB_CRYPTO, - false, - &CreateCryptoProxy, - }; - return &info; -} - -bool PPB_Crypto_Proxy::OnMessageReceived(const IPC::Message& msg) { - NOTREACHED(); - return false; -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_crypto_proxy.h b/ppapi/proxy/ppb_crypto_proxy.h deleted file mode 100644 index 8e343a8..0000000 --- a/ppapi/proxy/ppb_crypto_proxy.h +++ /dev/null @@ -1,33 +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_CRYPTO_PROXY_H_ -#define PPAPI_PROXY_PPB_CRYPTO_PROXY_H_ - -#include "ppapi/proxy/interface_proxy.h" - -namespace ppapi { -namespace proxy { - -class PPB_Crypto_Proxy : public InterfaceProxy { - public: - // This class should not normally be instantiated since there's only one - // function that's implemented entirely within the plugin. However, we need - // to support this so the machinery for automatically handling interfaces - // works. As a result, this constructor will assert if it's actually used. - PPB_Crypto_Proxy(Dispatcher* dispatcher); - virtual ~PPB_Crypto_Proxy(); - - static const Info* GetInfo(); - - private: - virtual bool OnMessageReceived(const IPC::Message& msg); - - DISALLOW_COPY_AND_ASSIGN(PPB_Crypto_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_CRYPTO_PROXY_H_ diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc index d26c29f..1856c82 100644 --- a/ppapi/proxy/ppb_instance_proxy.cc +++ b/ppapi/proxy/ppb_instance_proxy.cc @@ -78,6 +78,8 @@ bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message& msg) { OnMsgIsFullFrame) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, OnMsgExecuteScript) + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDefaultCharSet, + OnMsgGetDefaultCharSet) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_Log, OnMsgLog) IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LogWithSource, @@ -167,6 +169,17 @@ PP_Var PPB_Instance_Proxy::ExecuteScript(PP_Instance instance, return result.Return(dispatcher()); } +PP_Var PPB_Instance_Proxy::GetDefaultCharSet(PP_Instance instance) { + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); + if (!dispatcher) + return PP_MakeUndefined(); + + ReceiveSerializedVarReturnValue result; + dispatcher->Send(new PpapiHostMsg_PPBInstance_GetDefaultCharSet( + INTERFACE_ID_PPB_INSTANCE, instance, &result)); + return result.Return(dispatcher); +} + void PPB_Instance_Proxy::Log(PP_Instance instance, int log_level, PP_Var value) { @@ -418,6 +431,14 @@ void PPB_Instance_Proxy::OnMsgExecuteScript( out_exception.OutParam(dispatcher()))); } +void PPB_Instance_Proxy::OnMsgGetDefaultCharSet( + PP_Instance instance, + SerializedVarReturnValue result) { + EnterInstanceNoLock enter(instance, false); + if (enter.succeeded()) + result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance)); +} + void PPB_Instance_Proxy::OnMsgLog(PP_Instance instance, int log_level, SerializedVarReceiveInput value) { diff --git a/ppapi/proxy/ppb_instance_proxy.h b/ppapi/proxy/ppb_instance_proxy.h index 75538ca..b22b6d1 100644 --- a/ppapi/proxy/ppb_instance_proxy.h +++ b/ppapi/proxy/ppb_instance_proxy.h @@ -45,6 +45,7 @@ class PPB_Instance_Proxy : public InterfaceProxy, virtual PP_Var ExecuteScript(PP_Instance instance, PP_Var script, PP_Var* exception) OVERRIDE; + virtual PP_Var GetDefaultCharSet(PP_Instance instance) OVERRIDE; virtual void Log(PP_Instance instance, int log_level, PP_Var value) OVERRIDE; @@ -111,6 +112,8 @@ class PPB_Instance_Proxy : public InterfaceProxy, SerializedVarReceiveInput script, SerializedVarOutParam out_exception, SerializedVarReturnValue result); + void OnMsgGetDefaultCharSet(PP_Instance instance, + SerializedVarReturnValue result); void OnMsgLog(PP_Instance instance, int log_level, SerializedVarReceiveInput value); diff --git a/ppapi/proxy/ppb_memory_proxy.cc b/ppapi/proxy/ppb_memory_proxy.cc deleted file mode 100644 index 88da6b2..0000000 --- a/ppapi/proxy/ppb_memory_proxy.cc +++ /dev/null @@ -1,37 +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_memory_proxy.h" - -#include "ppapi/c/dev/ppb_memory_dev.h" -#include "ppapi/proxy/plugin_var_tracker.h" - -namespace ppapi { -namespace proxy { - -namespace { - -// PPB_Memory_Dev plugin ------------------------------------------------------- - -void* MemAlloc(uint32_t num_bytes) { - return malloc(num_bytes); -} - -void MemFree(void *ptr) { - free(ptr); -} - -const PPB_Memory_Dev memory_dev_interface = { - &MemAlloc, - &MemFree -}; - -} // namespace - -const PPB_Memory_Dev* GetPPB_Memory_Interface() { - return &memory_dev_interface; -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_memory_proxy.h b/ppapi/proxy/ppb_memory_proxy.h deleted file mode 100644 index fd7d5d2..0000000 --- a/ppapi/proxy/ppb_memory_proxy.h +++ /dev/null @@ -1,20 +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_MEMORY_PROXY_H_ -#define PPAPI_PPB_MEMORY_PROXY_H_ - -#include "ppapi/proxy/interface_proxy.h" - -struct PPB_Memory_Dev; - -namespace ppapi { -namespace proxy { - -const PPB_Memory_Dev* GetPPB_Memory_Interface(); - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PPB_MEMORY_PROXY_H_ |