Introduce AndroidMetricsProvider class.
[chromium-blink-merge.git] / ppapi / thunk / ppb_char_set_thunk.cc
bloba663c55dd4a0d57f1ac2042a8e58449c8295ef63
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/c/pp_var.h"
6 #include "ppapi/shared_impl/private/ppb_char_set_shared.h"
7 #include "ppapi/thunk/thunk.h"
8 #include "ppapi/thunk/enter.h"
10 namespace ppapi {
11 namespace thunk {
13 namespace {
15 char* UTF16ToCharSetDeprecated(PP_Instance instance,
16 const uint16_t* utf16, uint32_t utf16_len,
17 const char* output_char_set,
18 PP_CharSet_ConversionError on_error,
19 uint32_t* output_length) {
20 // We validate the instance just to make sure we can make changes in the
21 // future and assume people pass proper instances.
22 EnterInstance enter(instance);
23 if (enter.failed())
24 return NULL;
26 return PPB_CharSet_Shared::UTF16ToCharSetDeprecated(
27 utf16, utf16_len, output_char_set, on_error, output_length);
30 PP_Bool UTF16ToCharSet(const uint16_t utf16[],
31 uint32_t utf16_len,
32 const char* output_char_set,
33 PP_CharSet_Trusted_ConversionError on_error,
34 char* output_buffer,
35 uint32_t* output_length) {
36 // This interface is a bit odd because it contains a function
37 // (GetDefaultCharSet) that must be called on the instance object and
38 // proxied, but the rest of the functions are implemented in the plugin
39 // process by just calling base functions.
41 // We could have PPB_Instance_API functions for the two charset conversion
42 // functions, and then have the instance impl and proxy call through to the
43 // shared_impl. That would be more consistent, and we may want to do that if
44 // this file is autogenerated in the future. For now, however, it's less code
45 // to just call the shared_impl code directly here.
46 return PPB_CharSet_Shared::UTF16ToCharSet(
47 utf16, utf16_len, output_char_set, on_error,
48 output_buffer, output_length);
51 uint16_t* CharSetToUTF16Deprecated(PP_Instance instance,
52 const char* input, uint32_t input_len,
53 const char* input_char_set,
54 PP_CharSet_ConversionError on_error,
55 uint32_t* output_length) {
56 // We validate the instance just to make sure we can make changes in the
57 // future and assume people pass proper instances.
58 EnterInstance enter(instance);
59 if (enter.failed())
60 return NULL;
62 return PPB_CharSet_Shared::CharSetToUTF16Deprecated(
63 input, input_len, input_char_set, on_error, output_length);
66 PP_Bool CharSetToUTF16(const char* input,
67 uint32_t input_len,
68 const char* input_char_set,
69 PP_CharSet_Trusted_ConversionError on_error,
70 uint16_t* output_buffer,
71 uint32_t* output_utf16_length) {
72 return PPB_CharSet_Shared::CharSetToUTF16(
73 input, input_len, input_char_set, on_error,
74 output_buffer, output_utf16_length);
77 PP_Var GetDefaultCharSet(PP_Instance instance) {
78 EnterInstance enter(instance);
79 if (enter.failed())
80 return PP_MakeUndefined();
81 return enter.functions()->GetDefaultCharSet(instance);
84 const PPB_CharSet_Dev g_ppb_char_set_thunk = {
85 &UTF16ToCharSetDeprecated,
86 &CharSetToUTF16Deprecated,
87 &GetDefaultCharSet
90 const PPB_CharSet_Trusted_1_0 g_ppb_char_set_trusted_thunk = {
91 &UTF16ToCharSet,
92 &CharSetToUTF16,
93 &GetDefaultCharSet
96 } // namespace
98 const PPB_CharSet_Dev_0_4* GetPPB_CharSet_Dev_0_4_Thunk() {
99 return &g_ppb_char_set_thunk;
102 const PPB_CharSet_Trusted_1_0* GetPPB_CharSet_Trusted_1_0_Thunk() {
103 return &g_ppb_char_set_trusted_thunk;
106 } // namespace thunk
107 } // namespace ppapi