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