OLD | NEW |
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 "native_client/src/shared/ppapi_proxy/plugin_ppb_messaging.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_messaging.h" |
6 | 6 |
7 #include "native_client/src/include/nacl_scoped_ptr.h" | 7 #include "native_client/src/include/nacl_scoped_ptr.h" |
8 #include "native_client/src/include/portability.h" | 8 #include "native_client/src/include/portability.h" |
9 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" | 9 #include "native_client/src/shared/ppapi_proxy/object_serialize.h" |
10 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 10 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
11 #include "native_client/src/shared/ppapi_proxy/utility.h" | 11 #include "native_client/src/shared/ppapi_proxy/utility.h" |
12 #include "native_client/src/shared/srpc/nacl_srpc.h" | 12 #include "native_client/src/shared/srpc/nacl_srpc.h" |
13 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
14 #include "ppapi/c/pp_var.h" | 14 #include "ppapi/c/pp_var.h" |
15 #include "srpcgen/ppb_rpc.h" | 15 #include "srpcgen/ppb_rpc.h" |
16 | 16 |
17 namespace ppapi_proxy { | 17 namespace ppapi_proxy { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 void PostMessage(PP_Instance instance, struct PP_Var message) { | 21 void PostMessage(PP_Instance instance, struct PP_Var message) { |
22 DebugPrintf("PPB_Messaging::PostMessage: instance=%"NACL_PRIu32"\n", | 22 DebugPrintf("PPB_Messaging::PostMessage: instance=%"NACL_PRId32"\n", |
23 instance); | 23 instance); |
24 if (!ppapi_proxy::PPBCoreInterface()->IsMainThread()) | 24 if (!ppapi_proxy::PPBCoreInterface()->IsMainThread()) |
25 return; // Only supported on main thread. | 25 return; // Only supported on main thread. |
26 | 26 |
27 uint32_t message_length = 0; | 27 uint32_t message_length = 0; |
28 nacl::scoped_array<char> message_bytes(Serialize(&message, 1, | 28 nacl::scoped_array<char> message_bytes(Serialize(&message, 1, |
29 &message_length)); | 29 &message_length)); |
30 NaClSrpcError srpc_result = | 30 NaClSrpcError srpc_result = |
31 PpbMessagingRpcClient::PPB_Messaging_PostMessage( | 31 PpbMessagingRpcClient::PPB_Messaging_PostMessage( |
32 GetMainSrpcChannel(), | 32 GetMainSrpcChannel(), |
33 instance, | 33 instance, |
34 message_length, | 34 message_length, |
35 message_bytes.get()); | 35 message_bytes.get()); |
36 DebugPrintf("PPB_Messaging::PostMessage: %s\n", | 36 DebugPrintf("PPB_Messaging::PostMessage: %s\n", |
37 NaClSrpcErrorString(srpc_result)); | 37 NaClSrpcErrorString(srpc_result)); |
38 } | 38 } |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 const PPB_Messaging* PluginMessaging::GetInterface() { | 42 const PPB_Messaging* PluginMessaging::GetInterface() { |
43 static const PPB_Messaging messaging_interface = { | 43 static const PPB_Messaging messaging_interface = { |
44 PostMessage | 44 PostMessage |
45 }; | 45 }; |
46 return &messaging_interface; | 46 return &messaging_interface; |
47 } | 47 } |
48 | 48 |
49 } // namespace ppapi_proxy | 49 } // namespace ppapi_proxy |
OLD | NEW |