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/thunk | |
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/thunk')
-rw-r--r-- | ppapi/thunk/interfaces_ppb_public_dev.h | 5 | ||||
-rw-r--r-- | ppapi/thunk/ppb_char_set_api.h | 37 | ||||
-rw-r--r-- | ppapi/thunk/ppb_char_set_thunk.cc | 36 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_api.h | 3 |
4 files changed, 31 insertions, 50 deletions
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h index fb744db0..dde3182 100644 --- a/ppapi/thunk/interfaces_ppb_public_dev.h +++ b/ppapi/thunk/interfaces_ppb_public_dev.h @@ -8,7 +8,6 @@ #include "ppapi/thunk/interfaces_preamble.h" PROXIED_API(PPB_Buffer) -PROXIED_API(PPB_CharSet) PROXIED_API(PPB_Context3D) PROXIED_API(PPB_CursorControl) UNPROXIED_API(PPB_DirectoryReader) @@ -27,11 +26,11 @@ UNPROXIED_API(PPB_Widget) PROXIED_IFACE(NoAPIName, PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_1, PPB_IMEInputEvent_Dev) PROXIED_IFACE(PPB_Buffer, PPB_BUFFER_DEV_INTERFACE_0_4, PPB_Buffer_Dev) -PROXIED_IFACE(PPB_CharSet, PPB_CHAR_SET_DEV_INTERFACE_0_4, PPB_CharSet_Dev) PROXIED_IFACE(PPB_Context3D, PPB_CONTEXT_3D_DEV_INTERFACE_0_1, PPB_Context3D_Dev) PROXIED_IFACE(PPB_Context3D, PPB_GLES_CHROMIUM_TEXTURE_MAPPING_DEV_INTERFACE, PPB_GLESChromiumTextureMapping_Dev) +PROXIED_IFACE(NoAPIName, PPB_CRYPTO_DEV_INTERFACE, PPB_Crypto_Dev) PROXIED_IFACE(PPB_CursorControl, PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4, PPB_CursorControl_Dev) UNPROXIED_IFACE(PPB_DirectoryReader, PPB_DIRECTORYREADER_DEV_INTERFACE_0_5, @@ -40,6 +39,7 @@ UNPROXIED_IFACE(PPB_Find, PPB_FIND_DEV_INTERFACE_0_3, PPB_Find_Dev) PROXIED_IFACE(PPB_FileChooser, PPB_FILECHOOSER_DEV_INTERFACE_0_5, PPB_FileChooser_Dev) PROXIED_IFACE(PPB_Font, PPB_FONT_DEV_INTERFACE_0_6, PPB_Font_Dev) +PROXIED_IFACE(PPB_Instance, PPB_CHAR_SET_DEV_INTERFACE_0_4, PPB_CharSet_Dev) PROXIED_IFACE(PPB_Instance, PPB_CONSOLE_DEV_INTERFACE, PPB_Console_Dev) PROXIED_IFACE(PPB_Instance, PPB_FULLSCREEN_DEV_INTERFACE, PPB_Fullscreen_Dev) PROXIED_IFACE(PPB_Instance, PPB_MOUSELOCK_DEV_INTERFACE_0_1, @@ -50,6 +50,7 @@ PROXIED_IFACE(PPB_Instance, PPB_URLUTIL_DEV_INTERFACE_0_6, PPB_URLUtil_Dev) UNPROXIED_IFACE(PPB_Instance, PPB_ZOOM_DEV_INTERFACE_0_2, PPB_Zoom_Dev) UNPROXIED_IFACE(PPB_LayerCompositor, PPB_LAYER_COMPOSITOR_DEV_INTERFACE_0_2, PPB_LayerCompositor_Dev) +PROXIED_IFACE(NoAPIName, PPB_MEMORY_DEV_INTERFACE, PPB_Memory_Dev) UNPROXIED_IFACE(PPB_Scrollbar, PPB_SCROLLBAR_DEV_INTERFACE_0_5, PPB_Scrollbar_Dev) PROXIED_IFACE(PPB_Surface3D, PPB_SURFACE_3D_DEV_INTERFACE_0_2, diff --git a/ppapi/thunk/ppb_char_set_api.h b/ppapi/thunk/ppb_char_set_api.h deleted file mode 100644 index b3c4d8a..0000000 --- a/ppapi/thunk/ppb_char_set_api.h +++ /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. - -#ifndef PPAPI_THUNK_PPB_CHAR_SET_API_H_ -#define PPAPI_THUNK_PPB_CHAR_SET_API_H_ - -#include "ppapi/c/dev/ppb_char_set_dev.h" -#include "ppapi/proxy/interface_id.h" - -namespace ppapi { -namespace thunk { - -class PPB_CharSet_FunctionAPI { - public: - virtual ~PPB_CharSet_FunctionAPI() {} - - 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) = 0; - 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) = 0; - virtual PP_Var GetDefaultCharSet(PP_Instance instance) = 0; - - static const proxy::InterfaceID interface_id = - proxy::INTERFACE_ID_PPB_CHAR_SET; -}; - -} // namespace thunk -} // namespace ppapi - -#endif // PPAPI_THUNK_CHAR_SET_API_H_ diff --git a/ppapi/thunk/ppb_char_set_thunk.cc b/ppapi/thunk/ppb_char_set_thunk.cc index 1b02038..3e240e8 100644 --- a/ppapi/thunk/ppb_char_set_thunk.cc +++ b/ppapi/thunk/ppb_char_set_thunk.cc @@ -3,9 +3,9 @@ // found in the LICENSE file. #include "ppapi/c/pp_var.h" +#include "ppapi/shared_impl/char_set_impl.h" #include "ppapi/thunk/thunk.h" #include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_char_set_api.h" namespace ppapi { namespace thunk { @@ -17,12 +17,25 @@ char* UTF16ToCharSet(PP_Instance instance, const char* output_char_set, PP_CharSet_ConversionError on_error, uint32_t* output_length) { - EnterFunction<PPB_CharSet_FunctionAPI> enter(instance, true); + // This interface is a bit odd because it contains a function + // (GetDefaultCharSet) that must be called on the instance object and + // proxied, but the rest of the functions are implemented in the plugin + // process by just calling base functions. + // + // We could have PPB_Instance_API functions for the two charset conversion + // functions, and then have the instance impl and proxy call through to the + // shared_impl. That would be more consistent, and we may want to do that if + // this file is autogenerated in the future. For now, however, it's less code + // to just call the shared_impl code directly here. + + // We validate the instance just to make sure we can make changes in the + // future and assume people pass proper instances. + EnterInstance enter(instance); if (enter.failed()) return NULL; - return enter.functions()->UTF16ToCharSet(instance, utf16, utf16_len, - output_char_set, on_error, - output_length); + + return CharSetImpl::UTF16ToCharSet(utf16, utf16_len, output_char_set, + on_error, output_length); } uint16_t* CharSetToUTF16(PP_Instance instance, @@ -30,16 +43,18 @@ uint16_t* CharSetToUTF16(PP_Instance instance, const char* input_char_set, PP_CharSet_ConversionError on_error, uint32_t* output_length) { - EnterFunction<PPB_CharSet_FunctionAPI> enter(instance, true); + // We validate the instance just to make sure we can make changes in the + // future and assume people pass proper instances. + EnterInstance enter(instance); if (enter.failed()) return NULL; - return enter.functions()->CharSetToUTF16(instance, input, input_len, - input_char_set, on_error, - output_length); + + return CharSetImpl::CharSetToUTF16(input, input_len, input_char_set, + on_error, output_length); } PP_Var GetDefaultCharSet(PP_Instance instance) { - EnterFunction<PPB_CharSet_FunctionAPI> enter(instance, true); + EnterInstance enter(instance); if (enter.failed()) return PP_MakeUndefined(); return enter.functions()->GetDefaultCharSet(instance); @@ -51,7 +66,6 @@ const PPB_CharSet_Dev g_ppb_char_set_thunk = { &GetDefaultCharSet }; - } // namespace const PPB_CharSet_Dev* GetPPB_CharSet_Dev_Thunk() { diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index fa66e2e..2cbd4da 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -30,6 +30,9 @@ class PPB_Instance_FunctionAPI { PP_Var script, PP_Var* exception) = 0; + // CharSet. + virtual PP_Var GetDefaultCharSet(PP_Instance instance) = 0; + // Console. virtual void Log(PP_Instance instance, int log_level, |