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" | |
13 #include "ppapi/proxy/serialized_var.h" | 12 #include "ppapi/proxy/serialized_var.h" |
14 #include "ppapi/shared_impl/char_set_impl.h" | 13 #include "ppapi/shared_impl/char_set_impl.h" |
15 #include "ppapi/thunk/enter.h" | 14 #include "ppapi/thunk/enter.h" |
16 #include "ppapi/thunk/thunk.h" | 15 #include "ppapi/thunk/thunk.h" |
17 | 16 |
18 namespace ppapi { | 17 namespace ppapi { |
19 namespace proxy { | 18 namespace proxy { |
20 | 19 |
21 PPB_CharSet_Proxy::PPB_CharSet_Proxy(Dispatcher* dispatcher) | 20 namespace { |
22 : InterfaceProxy(dispatcher) { | 21 |
| 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) { |
23 } | 37 } |
24 | 38 |
25 PPB_CharSet_Proxy::~PPB_CharSet_Proxy() { | 39 PPB_CharSet_Proxy::~PPB_CharSet_Proxy() { |
26 } | 40 } |
27 | 41 |
| 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 |
28 ppapi::thunk::PPB_CharSet_FunctionAPI* | 54 ppapi::thunk::PPB_CharSet_FunctionAPI* |
29 PPB_CharSet_Proxy::AsPPB_CharSet_FunctionAPI() { | 55 PPB_CharSet_Proxy::AsPPB_CharSet_FunctionAPI() { |
30 return this; | 56 return this; |
31 } | 57 } |
32 | 58 |
33 char* PPB_CharSet_Proxy::UTF16ToCharSet( | 59 char* PPB_CharSet_Proxy::UTF16ToCharSet( |
34 PP_Instance instance, | 60 PP_Instance instance, |
35 const uint16_t* utf16, uint32_t utf16_len, | 61 const uint16_t* utf16, uint32_t utf16_len, |
36 const char* output_char_set, | 62 const char* output_char_set, |
37 PP_CharSet_ConversionError on_error, | 63 PP_CharSet_ConversionError on_error, |
38 uint32_t* output_length) { | 64 uint32_t* output_length) { |
39 return ppapi::CharSetImpl::UTF16ToCharSet( | 65 return ppapi::CharSetImpl::UTF16ToCharSet( |
40 GetPPB_Memory_Interface(), utf16, utf16_len, | 66 GetMemoryDevInterface(), utf16, utf16_len, output_char_set, on_error, |
41 output_char_set, on_error, output_length); | 67 output_length); |
42 } | 68 } |
43 | 69 |
44 uint16_t* PPB_CharSet_Proxy::CharSetToUTF16( | 70 uint16_t* PPB_CharSet_Proxy::CharSetToUTF16( |
45 PP_Instance instance, | 71 PP_Instance instance, |
46 const char* input, uint32_t input_len, | 72 const char* input, uint32_t input_len, |
47 const char* input_char_set, | 73 const char* input_char_set, |
48 PP_CharSet_ConversionError on_error, | 74 PP_CharSet_ConversionError on_error, |
49 uint32_t* output_length) { | 75 uint32_t* output_length) { |
50 return ppapi::CharSetImpl::CharSetToUTF16( | 76 return ppapi::CharSetImpl::CharSetToUTF16( |
51 GetPPB_Memory_Interface(), input, input_len, | 77 GetMemoryDevInterface(), input, input_len, input_char_set, on_error, |
52 input_char_set, on_error, output_length); | 78 output_length); |
53 } | 79 } |
54 | 80 |
55 PP_Var PPB_CharSet_Proxy::GetDefaultCharSet(PP_Instance instance) { | 81 PP_Var PPB_CharSet_Proxy::GetDefaultCharSet(PP_Instance instance) { |
56 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 82 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
57 if (!dispatcher) | 83 if (!dispatcher) |
58 return PP_MakeUndefined(); | 84 return PP_MakeUndefined(); |
59 | 85 |
60 ReceiveSerializedVarReturnValue result; | 86 ReceiveSerializedVarReturnValue result; |
61 dispatcher->Send(new PpapiHostMsg_PPBCharSet_GetDefaultCharSet( | 87 dispatcher->Send(new PpapiHostMsg_PPBCharSet_GetDefaultCharSet( |
62 INTERFACE_ID_PPB_CHAR_SET, instance, &result)); | 88 INTERFACE_ID_PPB_CHAR_SET, instance, &result)); |
(...skipping 14 matching lines...) Expand all Loading... |
77 PP_Instance instance, | 103 PP_Instance instance, |
78 SerializedVarReturnValue result) { | 104 SerializedVarReturnValue result) { |
79 ppapi::thunk::EnterFunctionNoLock<ppapi::thunk::PPB_CharSet_FunctionAPI> | 105 ppapi::thunk::EnterFunctionNoLock<ppapi::thunk::PPB_CharSet_FunctionAPI> |
80 enter(instance, true); | 106 enter(instance, true); |
81 if (enter.succeeded()) | 107 if (enter.succeeded()) |
82 result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance)); | 108 result.Return(dispatcher(), enter.functions()->GetDefaultCharSet(instance)); |
83 } | 109 } |
84 | 110 |
85 } // namespace proxy | 111 } // namespace proxy |
86 } // namespace ppapi | 112 } // namespace ppapi |
OLD | NEW |