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

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

Issue 238923007: PPAPI: Format ppapi/thunk using clang-format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use Popen instead, force carriage returns in thunks Created 6 years, 8 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
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/private/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* UTF16ToCharSetDeprecated(PP_Instance instance, 15 char* UTF16ToCharSetDeprecated(PP_Instance instance,
16 const uint16_t* utf16, uint32_t utf16_len, 16 const uint16_t* utf16,
17 uint32_t utf16_len,
17 const char* output_char_set, 18 const char* output_char_set,
18 PP_CharSet_ConversionError on_error, 19 PP_CharSet_ConversionError on_error,
19 uint32_t* output_length) { 20 uint32_t* output_length) {
20 // We validate the instance just to make sure we can make changes in the 21 // We validate the instance just to make sure we can make changes in the
21 // future and assume people pass proper instances. 22 // future and assume people pass proper instances.
22 EnterInstance enter(instance); 23 EnterInstance enter(instance);
23 if (enter.failed()) 24 if (enter.failed())
24 return NULL; 25 return NULL;
25 26
26 return PPB_CharSet_Shared::UTF16ToCharSetDeprecated( 27 return PPB_CharSet_Shared::UTF16ToCharSetDeprecated(
27 utf16, utf16_len, output_char_set, on_error, output_length); 28 utf16, utf16_len, output_char_set, on_error, output_length);
28 } 29 }
29 30
30 PP_Bool UTF16ToCharSet(const uint16_t utf16[], 31 PP_Bool UTF16ToCharSet(const uint16_t utf16[],
31 uint32_t utf16_len, 32 uint32_t utf16_len,
32 const char* output_char_set, 33 const char* output_char_set,
33 PP_CharSet_Trusted_ConversionError on_error, 34 PP_CharSet_Trusted_ConversionError on_error,
34 char* output_buffer, 35 char* output_buffer,
35 uint32_t* output_length) { 36 uint32_t* output_length) {
36 // This interface is a bit odd because it contains a function 37 // This interface is a bit odd because it contains a function
37 // (GetDefaultCharSet) that must be called on the instance object and 38 // (GetDefaultCharSet) that must be called on the instance object and
38 // proxied, but the rest of the functions are implemented in the plugin 39 // proxied, but the rest of the functions are implemented in the plugin
39 // process by just calling base functions. 40 // process by just calling base functions.
40 // 41 //
41 // We could have PPB_Instance_API functions for the two charset conversion 42 // 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 // 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 // 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 // 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 // to just call the shared_impl code directly here.
46 return PPB_CharSet_Shared::UTF16ToCharSet( 47 return PPB_CharSet_Shared::UTF16ToCharSet(utf16,
47 utf16, utf16_len, output_char_set, on_error, 48 utf16_len,
48 output_buffer, output_length); 49 output_char_set,
50 on_error,
51 output_buffer,
52 output_length);
49 } 53 }
50 54
51 uint16_t* CharSetToUTF16Deprecated(PP_Instance instance, 55 uint16_t* CharSetToUTF16Deprecated(PP_Instance instance,
52 const char* input, uint32_t input_len, 56 const char* input,
57 uint32_t input_len,
53 const char* input_char_set, 58 const char* input_char_set,
54 PP_CharSet_ConversionError on_error, 59 PP_CharSet_ConversionError on_error,
55 uint32_t* output_length) { 60 uint32_t* output_length) {
56 // We validate the instance just to make sure we can make changes in the 61 // We validate the instance just to make sure we can make changes in the
57 // future and assume people pass proper instances. 62 // future and assume people pass proper instances.
58 EnterInstance enter(instance); 63 EnterInstance enter(instance);
59 if (enter.failed()) 64 if (enter.failed())
60 return NULL; 65 return NULL;
61 66
62 return PPB_CharSet_Shared::CharSetToUTF16Deprecated( 67 return PPB_CharSet_Shared::CharSetToUTF16Deprecated(
63 input, input_len, input_char_set, on_error, output_length); 68 input, input_len, input_char_set, on_error, output_length);
64 } 69 }
65 70
66 PP_Bool CharSetToUTF16(const char* input, 71 PP_Bool CharSetToUTF16(const char* input,
67 uint32_t input_len, 72 uint32_t input_len,
68 const char* input_char_set, 73 const char* input_char_set,
69 PP_CharSet_Trusted_ConversionError on_error, 74 PP_CharSet_Trusted_ConversionError on_error,
70 uint16_t* output_buffer, 75 uint16_t* output_buffer,
71 uint32_t* output_utf16_length) { 76 uint32_t* output_utf16_length) {
72 return PPB_CharSet_Shared::CharSetToUTF16( 77 return PPB_CharSet_Shared::CharSetToUTF16(input,
73 input, input_len, input_char_set, on_error, 78 input_len,
74 output_buffer, output_utf16_length); 79 input_char_set,
80 on_error,
81 output_buffer,
82 output_utf16_length);
75 } 83 }
76 84
77 PP_Var GetDefaultCharSet(PP_Instance instance) { 85 PP_Var GetDefaultCharSet(PP_Instance instance) {
78 EnterInstance enter(instance); 86 EnterInstance enter(instance);
79 if (enter.failed()) 87 if (enter.failed())
80 return PP_MakeUndefined(); 88 return PP_MakeUndefined();
81 return enter.functions()->GetDefaultCharSet(instance); 89 return enter.functions()->GetDefaultCharSet(instance);
82 } 90 }
83 91
84 const PPB_CharSet_Dev g_ppb_char_set_thunk = { 92 const PPB_CharSet_Dev g_ppb_char_set_thunk = {
85 &UTF16ToCharSetDeprecated, 93 &UTF16ToCharSetDeprecated, &CharSetToUTF16Deprecated, &GetDefaultCharSet};
86 &CharSetToUTF16Deprecated,
87 &GetDefaultCharSet
88 };
89 94
90 const PPB_CharSet_Trusted_1_0 g_ppb_char_set_trusted_thunk = { 95 const PPB_CharSet_Trusted_1_0 g_ppb_char_set_trusted_thunk = {
91 &UTF16ToCharSet, 96 &UTF16ToCharSet, &CharSetToUTF16, &GetDefaultCharSet};
92 &CharSetToUTF16,
93 &GetDefaultCharSet
94 };
95 97
96 } // namespace 98 } // namespace
97 99
98 const PPB_CharSet_Dev_0_4* GetPPB_CharSet_Dev_0_4_Thunk() { 100 const PPB_CharSet_Dev_0_4* GetPPB_CharSet_Dev_0_4_Thunk() {
99 return &g_ppb_char_set_thunk; 101 return &g_ppb_char_set_thunk;
100 } 102 }
101 103
102 const PPB_CharSet_Trusted_1_0* GetPPB_CharSet_Trusted_1_0_Thunk() { 104 const PPB_CharSet_Trusted_1_0* GetPPB_CharSet_Trusted_1_0_Thunk() {
103 return &g_ppb_char_set_trusted_thunk; 105 return &g_ppb_char_set_trusted_thunk;
104 } 106 }
105 107
106 } // namespace thunk 108 } // namespace thunk
107 } // namespace ppapi 109 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698