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

Side by Side Diff: ppapi/proxy/ppb_char_set_proxy.cc

Issue 6282007: First pass at making the proxy handle multiple renderers. This associates the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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/proxy/ppb_buffer_proxy.cc ('k') | ppapi/proxy/ppb_core_proxy.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "ppapi/c/dev/ppb_char_set_dev.h" 7 #include "ppapi/c/dev/ppb_char_set_dev.h"
8 #include "ppapi/c/ppb_core.h" 8 #include "ppapi/c/ppb_core.h"
9 #include "ppapi/proxy/plugin_dispatcher.h" 9 #include "ppapi/proxy/plugin_dispatcher.h"
10 #include "ppapi/proxy/ppapi_messages.h" 10 #include "ppapi/proxy/ppapi_messages.h"
11 #include "ppapi/proxy/serialized_var.h" 11 #include "ppapi/proxy/serialized_var.h"
12 12
13 namespace pp { 13 namespace pp {
14 namespace proxy { 14 namespace proxy {
15 15
16 namespace { 16 namespace {
17 17
18 char* UTF16ToCharSet(PP_Instance instance, 18 char* UTF16ToCharSet(PP_Instance instance,
19 const uint16_t* utf16, uint32_t utf16_len, 19 const uint16_t* utf16, uint32_t utf16_len,
20 const char* output_char_set, 20 const char* output_char_set,
21 PP_CharSet_ConversionError on_error, 21 PP_CharSet_ConversionError on_error,
22 uint32_t* output_length) { 22 uint32_t* output_length) {
23 *output_length = 0;
24 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
25 if (!dispatcher)
26 return NULL;
27
23 bool output_is_success = false; 28 bool output_is_success = false;
24 std::string result; 29 std::string result;
25 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCharSet_UTF16ToCharSet( 30 dispatcher->Send(new PpapiHostMsg_PPBCharSet_UTF16ToCharSet(
26 INTERFACE_ID_PPB_CHAR_SET, instance, 31 INTERFACE_ID_PPB_CHAR_SET, instance,
27 string16(reinterpret_cast<const char16*>(utf16), utf16_len), 32 string16(reinterpret_cast<const char16*>(utf16), utf16_len),
28 std::string(output_char_set), static_cast<int32_t>(on_error), 33 std::string(output_char_set), static_cast<int32_t>(on_error),
29 &result, &output_is_success)); 34 &result, &output_is_success));
30 if (!output_is_success) 35 if (!output_is_success)
31 return NULL; 36 return NULL;
32 37
33 *output_length = static_cast<uint32_t>(result.size()); 38 *output_length = static_cast<uint32_t>(result.size());
34 char* ret_val = static_cast<char*>(malloc(result.size() + 1)); 39 char* ret_val = static_cast<char*>(malloc(result.size() + 1));
35 memcpy(ret_val, result.c_str(), result.size() + 1); 40 memcpy(ret_val, result.c_str(), result.size() + 1);
36 return ret_val; 41 return ret_val;
37 } 42 }
38 43
39 uint16_t* CharSetToUTF16(PP_Instance instance, 44 uint16_t* CharSetToUTF16(PP_Instance instance,
40 const char* input, uint32_t input_len, 45 const char* input, uint32_t input_len,
41 const char* input_char_set, 46 const char* input_char_set,
42 PP_CharSet_ConversionError on_error, 47 PP_CharSet_ConversionError on_error,
43 uint32_t* output_length) { 48 uint32_t* output_length) {
49 *output_length = 0;
50 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
51 if (!dispatcher)
52 return NULL;
53
44 bool output_is_success = false; 54 bool output_is_success = false;
45 string16 result; 55 string16 result;
46 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCharSet_CharSetToUTF16( 56 dispatcher->Send(new PpapiHostMsg_PPBCharSet_CharSetToUTF16(
47 INTERFACE_ID_PPB_CHAR_SET, instance, 57 INTERFACE_ID_PPB_CHAR_SET, instance,
48 std::string(input, input_len), 58 std::string(input, input_len),
49 std::string(input_char_set), static_cast<int32_t>(on_error), 59 std::string(input_char_set), static_cast<int32_t>(on_error),
50 &result, &output_is_success)); 60 &result, &output_is_success));
51 if (!output_is_success) 61 if (!output_is_success)
52 return NULL; 62 return NULL;
53 63
54 *output_length = static_cast<uint32_t>(result.size()); 64 *output_length = static_cast<uint32_t>(result.size());
55 uint16_t* ret_val = static_cast<uint16_t*>( 65 uint16_t* ret_val = static_cast<uint16_t*>(
56 malloc((result.size() + 1) * sizeof(uint16_t))); 66 malloc((result.size() + 1) * sizeof(uint16_t)));
57 memcpy(ret_val, result.c_str(), (result.size() + 1) * sizeof(uint16_t)); 67 memcpy(ret_val, result.c_str(), (result.size() + 1) * sizeof(uint16_t));
58 return ret_val; 68 return ret_val;
59 } 69 }
60 70
61 PP_Var GetDefaultCharSet(PP_Instance instance) { 71 PP_Var GetDefaultCharSet(PP_Instance instance) {
72 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
73 if (!dispatcher)
74 return PP_MakeUndefined();
75
62 ReceiveSerializedVarReturnValue result; 76 ReceiveSerializedVarReturnValue result;
63 PluginDispatcher::Get()->Send(new PpapiHostMsg_PPBCharSet_GetDefaultCharSet( 77 dispatcher->Send(new PpapiHostMsg_PPBCharSet_GetDefaultCharSet(
64 INTERFACE_ID_PPB_CHAR_SET, instance, &result)); 78 INTERFACE_ID_PPB_CHAR_SET, instance, &result));
65 return result.Return(PluginDispatcher::Get()); 79 return result.Return(dispatcher);
66 } 80 }
67 81
68 const PPB_CharSet_Dev ppb_charset_interface = { 82 const PPB_CharSet_Dev ppb_charset_interface = {
69 &UTF16ToCharSet, 83 &UTF16ToCharSet,
70 &CharSetToUTF16, 84 &CharSetToUTF16,
71 &GetDefaultCharSet 85 &GetDefaultCharSet
72 }; 86 };
73 87
74 } // namespace 88 } // namespace
75 89
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 const PPB_Core* PPB_CharSet_Proxy::GetCoreInterface() { 169 const PPB_Core* PPB_CharSet_Proxy::GetCoreInterface() {
156 if (!core_interface_) { 170 if (!core_interface_) {
157 core_interface_ = static_cast<const PPB_Core*>( 171 core_interface_ = static_cast<const PPB_Core*>(
158 dispatcher()->GetLocalInterface(PPB_CORE_INTERFACE)); 172 dispatcher()->GetLocalInterface(PPB_CORE_INTERFACE));
159 } 173 }
160 return core_interface_; 174 return core_interface_;
161 } 175 }
162 176
163 } // namespace proxy 177 } // namespace proxy
164 } // namespace pp 178 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_buffer_proxy.cc ('k') | ppapi/proxy/ppb_core_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698