Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: ppapi/thunk/ppb_char_set_thunk.cc

Issue 9348069: Move the charset inteface to "trusted" (we can't implement this efficiently (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: STUPID REQUIRED REVIEW COMMENT Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/thunk/interfaces_ppb_private.h ('k') | webkit/plugins/ppapi/plugin_module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/c/pp_var.h" 5 #include "ppapi/c/pp_var.h"
6 #include "ppapi/shared_impl/ppb_char_set_shared.h" 6 #include "ppapi/shared_impl/private/ppb_char_set_shared.h"
7 #include "ppapi/thunk/thunk.h" 7 #include "ppapi/thunk/thunk.h"
8 #include "ppapi/thunk/enter.h" 8 #include "ppapi/thunk/enter.h"
9 9
10 namespace ppapi { 10 namespace ppapi {
11 namespace thunk { 11 namespace thunk {
12 12
13 namespace { 13 namespace {
14 14
15 char* UTF16ToCharSet(PP_Instance instance, 15 char* UTF16ToCharSetDeprecated(PP_Instance instance,
16 const uint16_t* utf16, uint32_t utf16_len, 16 const uint16_t* utf16, uint32_t utf16_len,
17 const char* output_char_set, 17 const char* output_char_set,
18 PP_CharSet_ConversionError on_error, 18 PP_CharSet_ConversionError on_error,
19 uint32_t* output_length) { 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;
25
26 return PPB_CharSet_Shared::UTF16ToCharSetDeprecated(
27 utf16, utf16_len, output_char_set, on_error, output_length);
28 }
29
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) {
20 // This interface is a bit odd because it contains a function 36 // This interface is a bit odd because it contains a function
21 // (GetDefaultCharSet) that must be called on the instance object and 37 // (GetDefaultCharSet) that must be called on the instance object and
22 // proxied, but the rest of the functions are implemented in the plugin 38 // proxied, but the rest of the functions are implemented in the plugin
23 // process by just calling base functions. 39 // process by just calling base functions.
24 // 40 //
25 // We could have PPB_Instance_API functions for the two charset conversion 41 // We could have PPB_Instance_API functions for the two charset conversion
26 // functions, and then have the instance impl and proxy call through to the 42 // functions, and then have the instance impl and proxy call through to the
27 // shared_impl. That would be more consistent, and we may want to do that if 43 // shared_impl. That would be more consistent, and we may want to do that if
28 // this file is autogenerated in the future. For now, however, it's less code 44 // this file is autogenerated in the future. For now, however, it's less code
29 // to just call the shared_impl code directly here. 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);
49 }
30 50
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) {
31 // We validate the instance just to make sure we can make changes in the 56 // We validate the instance just to make sure we can make changes in the
32 // future and assume people pass proper instances. 57 // future and assume people pass proper instances.
33 EnterInstance enter(instance); 58 EnterInstance enter(instance);
34 if (enter.failed()) 59 if (enter.failed())
35 return NULL; 60 return NULL;
36 61
37 return PPB_CharSet_Shared::UTF16ToCharSet(utf16, utf16_len, output_char_set, 62 return PPB_CharSet_Shared::CharSetToUTF16Deprecated(
38 on_error, output_length); 63 input, input_len, input_char_set, on_error, output_length);
39 } 64 }
40 65
41 uint16_t* CharSetToUTF16(PP_Instance instance, 66 PP_Bool CharSetToUTF16(const char* input,
42 const char* input, uint32_t input_len, 67 uint32_t input_len,
43 const char* input_char_set, 68 const char* input_char_set,
44 PP_CharSet_ConversionError on_error, 69 PP_CharSet_Trusted_ConversionError on_error,
45 uint32_t* output_length) { 70 uint16_t* output_buffer,
46 // We validate the instance just to make sure we can make changes in the 71 uint32_t* output_utf16_length) {
47 // future and assume people pass proper instances. 72 return PPB_CharSet_Shared::CharSetToUTF16(
48 EnterInstance enter(instance); 73 input, input_len, input_char_set, on_error,
49 if (enter.failed()) 74 output_buffer, output_utf16_length);
50 return NULL;
51
52 return PPB_CharSet_Shared::CharSetToUTF16(input, input_len, input_char_set,
53 on_error, output_length);
54 } 75 }
55 76
56 PP_Var GetDefaultCharSet(PP_Instance instance) { 77 PP_Var GetDefaultCharSet(PP_Instance instance) {
57 EnterInstance enter(instance); 78 EnterInstance enter(instance);
58 if (enter.failed()) 79 if (enter.failed())
59 return PP_MakeUndefined(); 80 return PP_MakeUndefined();
60 return enter.functions()->GetDefaultCharSet(instance); 81 return enter.functions()->GetDefaultCharSet(instance);
61 } 82 }
62 83
63 const PPB_CharSet_Dev g_ppb_char_set_thunk = { 84 const PPB_CharSet_Dev g_ppb_char_set_thunk = {
85 &UTF16ToCharSetDeprecated,
86 &CharSetToUTF16Deprecated,
87 &GetDefaultCharSet
88 };
89
90 const PPB_CharSet_Trusted_1_0 g_ppb_char_set_trusted_thunk = {
64 &UTF16ToCharSet, 91 &UTF16ToCharSet,
65 &CharSetToUTF16, 92 &CharSetToUTF16,
66 &GetDefaultCharSet 93 &GetDefaultCharSet
67 }; 94 };
68 95
69 } // namespace 96 } // namespace
70 97
71 const PPB_CharSet_Dev_0_4* GetPPB_CharSet_Dev_0_4_Thunk() { 98 const PPB_CharSet_Dev_0_4* GetPPB_CharSet_Dev_0_4_Thunk() {
72 return &g_ppb_char_set_thunk; 99 return &g_ppb_char_set_thunk;
73 } 100 }
74 101
102 const PPB_CharSet_Trusted_1_0* GetPPB_CharSet_Trusted_1_0_Thunk() {
103 return &g_ppb_char_set_trusted_thunk;
104 }
105
75 } // namespace thunk 106 } // namespace thunk
76 } // namespace ppapi 107 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/interfaces_ppb_private.h ('k') | webkit/plugins/ppapi/plugin_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698