| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/proxy/ppb_char_set_proxy.h" | 5 #include "ppapi/proxy/ppb_char_set_proxy.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "ppapi/c/dev/ppb_char_set_dev.h" | 8 #include "ppapi/c/dev/ppb_char_set_dev.h" |
| 9 #include "ppapi/c/dev/ppb_memory_dev.h" | 9 #include "ppapi/c/dev/ppb_memory_dev.h" |
| 10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
| 11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
| 12 #include "ppapi/proxy/ppb_memory_proxy.h" |
| 12 #include "ppapi/proxy/serialized_var.h" | 13 #include "ppapi/proxy/serialized_var.h" |
| 13 #include "ppapi/shared_impl/char_set_impl.h" | 14 #include "ppapi/shared_impl/char_set_impl.h" |
| 14 #include "ppapi/thunk/enter.h" | 15 #include "ppapi/thunk/enter.h" |
| 15 #include "ppapi/thunk/thunk.h" | 16 #include "ppapi/thunk/thunk.h" |
| 16 | 17 |
| 17 namespace ppapi { | 18 namespace ppapi { |
| 18 namespace proxy { | 19 namespace proxy { |
| 19 | 20 |
| 20 namespace { | 21 PPB_CharSet_Proxy::PPB_CharSet_Proxy(Dispatcher* dispatcher) |
| 21 | 22 : InterfaceProxy(dispatcher) { |
| 22 const PPB_Memory_Dev* GetMemoryDevInterface() { | |
| 23 return static_cast<const PPB_Memory_Dev*>( | |
| 24 PluginDispatcher::GetInterfaceFromDispatcher(PPB_MEMORY_DEV_INTERFACE)); | |
| 25 } | |
| 26 | |
| 27 InterfaceProxy* CreateCharSetProxy(Dispatcher* dispatcher, | |
| 28 const void* target_interface) { | |
| 29 return new PPB_CharSet_Proxy(dispatcher, target_interface); | |
| 30 } | |
| 31 | |
| 32 } // namespace | |
| 33 | |
| 34 PPB_CharSet_Proxy::PPB_CharSet_Proxy(Dispatcher* dispatcher, | |
| 35 const void* target_interface) | |
| 36 : InterfaceProxy(dispatcher, target_interface) { | |
| 37 } | 23 } |
| 38 | 24 |
| 39 PPB_CharSet_Proxy::~PPB_CharSet_Proxy() { | 25 PPB_CharSet_Proxy::~PPB_CharSet_Proxy() { |
| 40 } | 26 } |
| 41 | 27 |
| 42 // static | |
| 43 const InterfaceProxy::Info* PPB_CharSet_Proxy::GetInfo() { | |
| 44 static const Info info = { | |
| 45 ppapi::thunk::GetPPB_CharSet_Thunk(), | |
| 46 PPB_CHAR_SET_DEV_INTERFACE, | |
| 47 INTERFACE_ID_PPB_CHAR_SET, | |
| 48 false, | |
| 49 &CreateCharSetProxy, | |
| 50 }; | |
| 51 return &info; | |
| 52 } | |
| 53 | |
| 54 ppapi::thunk::PPB_CharSet_FunctionAPI* | 28 ppapi::thunk::PPB_CharSet_FunctionAPI* |
| 55 PPB_CharSet_Proxy::AsPPB_CharSet_FunctionAPI() { | 29 PPB_CharSet_Proxy::AsPPB_CharSet_FunctionAPI() { |
| 56 return this; | 30 return this; |
| 57 } | 31 } |
| 58 | 32 |
| 59 char* PPB_CharSet_Proxy::UTF16ToCharSet( | 33 char* PPB_CharSet_Proxy::UTF16ToCharSet( |
| 60 PP_Instance instance, | 34 PP_Instance instance, |
| 61 const uint16_t* utf16, uint32_t utf16_len, | 35 const uint16_t* utf16, uint32_t utf16_len, |
| 62 const char* output_char_set, | 36 const char* output_char_set, |
| 63 PP_CharSet_ConversionError on_error, | 37 PP_CharSet_ConversionError on_error, |
| 64 uint32_t* output_length) { | 38 uint32_t* output_length) { |
| 65 return ppapi::CharSetImpl::UTF16ToCharSet( | 39 return ppapi::CharSetImpl::UTF16ToCharSet( |
| 66 GetMemoryDevInterface(), utf16, utf16_len, output_char_set, on_error, | 40 GetPPB_Memory_Interface(), utf16, utf16_len, |
| 67 output_length); | 41 output_char_set, on_error, output_length); |
| 68 } | 42 } |
| 69 | 43 |
| 70 uint16_t* PPB_CharSet_Proxy::CharSetToUTF16( | 44 uint16_t* PPB_CharSet_Proxy::CharSetToUTF16( |
| 71 PP_Instance instance, | 45 PP_Instance instance, |
| 72 const char* input, uint32_t input_len, | 46 const char* input, uint32_t input_len, |
| 73 const char* input_char_set, | 47 const char* input_char_set, |
| 74 PP_CharSet_ConversionError on_error, | 48 PP_CharSet_ConversionError on_error, |
| 75 uint32_t* output_length) { | 49 uint32_t* output_length) { |
| 76 return ppapi::CharSetImpl::CharSetToUTF16( | 50 return ppapi::CharSetImpl::CharSetToUTF16( |
| 77 GetMemoryDevInterface(), input, input_len, input_char_set, on_error, | 51 GetPPB_Memory_Interface(), input, input_len, |
| 78 output_length); | 52 input_char_set, on_error, output_length); |
| 79 } | 53 } |
| 80 | 54 |
| 81 PP_Var PPB_CharSet_Proxy::GetDefaultCharSet(PP_Instance instance) { | 55 PP_Var PPB_CharSet_Proxy::GetDefaultCharSet(PP_Instance instance) { |
| 82 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 56 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 83 if (!dispatcher) | 57 if (!dispatcher) |
| 84 return PP_MakeUndefined(); | 58 return PP_MakeUndefined(); |
| 85 | 59 |
| 86 ReceiveSerializedVarReturnValue result; | 60 ReceiveSerializedVarReturnValue result; |
| 87 dispatcher->Send(new PpapiHostMsg_PPBCharSet_GetDefaultCharSet( | 61 dispatcher->Send(new PpapiHostMsg_PPBCharSet_GetDefaultCharSet( |
| 88 INTERFACE_ID_PPB_CHAR_SET, instance, &result)); | 62 INTERFACE_ID_PPB_CHAR_SET, instance, &result)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 103 PP_Instance instance, | 77 PP_Instance instance, |
| 104 SerializedVarReturnValue result) { | 78 SerializedVarReturnValue result) { |
| 105 ppapi::thunk::EnterFunctionNoLock<ppapi::thunk::PPB_CharSet_FunctionAPI> | 79 ppapi::thunk::EnterFunctionNoLock<ppapi::thunk::PPB_CharSet_FunctionAPI> |
| 106 enter(instance, true); | 80 enter(instance, true); |
| 107 if (enter.succeeded()) | 81 if (enter.succeeded()) |
| 108 result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance)); | 82 result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance)); |
| 109 } | 83 } |
| 110 | 84 |
| 111 } // namespace proxy | 85 } // namespace proxy |
| 112 } // namespace ppapi | 86 } // namespace ppapi |
| OLD | NEW |