| OLD | NEW |
| 1 // Copyright (c) 2010 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2010 The Native Client 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 // SRPC-abstraction wrappers around PPB_Instance functions. | 5 // SRPC-abstraction wrappers around PPB_Instance functions. |
| 6 | 6 |
| 7 #include "native_client/src/include/nacl_macros.h" | 7 #include "native_client/src/include/nacl_macros.h" |
| 8 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" | 8 #include "native_client/src/shared/ppapi_proxy/browser_globals.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 "srpcgen/ppb_rpc.h" | 10 #include "srpcgen/ppb_rpc.h" |
| 11 | 11 |
| 12 void PpbInstanceRpcServer::PPB_Instance_GetWindowObject( | 12 void PpbInstanceRpcServer::PPB_Instance_GetWindowObject( |
| 13 NaClSrpcRpc* rpc, | 13 NaClSrpcRpc* rpc, |
| 14 NaClSrpcClosure* done, | 14 NaClSrpcClosure* done, |
| 15 // inputs | 15 // inputs |
| 16 int64_t instance, | 16 PP_Instance instance, |
| 17 // outputs | 17 // outputs |
| 18 nacl_abi_size_t* window_size, char* window_bytes) { | 18 nacl_abi_size_t* window_size, char* window_bytes) { |
| 19 NACL_UNTESTED(); | 19 NACL_UNTESTED(); |
| 20 NaClSrpcClosureRunner runner(done); | 20 NaClSrpcClosureRunner runner(done); |
| 21 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 21 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 22 | 22 |
| 23 PP_Var window = | 23 PP_Var window = |
| 24 ppapi_proxy::PPBInstanceInterface()->GetWindowObject( | 24 ppapi_proxy::PPBInstanceInterface()->GetWindowObject(instance); |
| 25 static_cast<PP_Instance>(instance)); | |
| 26 if (!ppapi_proxy::SerializeTo(&window, window_bytes, window_size)) | 25 if (!ppapi_proxy::SerializeTo(&window, window_bytes, window_size)) |
| 27 return; | 26 return; |
| 28 | 27 |
| 29 rpc->result = NACL_SRPC_RESULT_OK; | 28 rpc->result = NACL_SRPC_RESULT_OK; |
| 30 } | 29 } |
| 31 | 30 |
| 32 void PpbInstanceRpcServer::PPB_Instance_GetOwnerElementObject( | 31 void PpbInstanceRpcServer::PPB_Instance_GetOwnerElementObject( |
| 33 NaClSrpcRpc* rpc, | 32 NaClSrpcRpc* rpc, |
| 34 NaClSrpcClosure* done, | 33 NaClSrpcClosure* done, |
| 35 // inputs | 34 // inputs |
| 36 int64_t instance, | 35 PP_Instance instance, |
| 37 // outputs | 36 // outputs |
| 38 nacl_abi_size_t* owner_size, char* owner_bytes) { | 37 nacl_abi_size_t* owner_size, char* owner_bytes) { |
| 39 NACL_UNTESTED(); | 38 NACL_UNTESTED(); |
| 40 NaClSrpcClosureRunner runner(done); | 39 NaClSrpcClosureRunner runner(done); |
| 41 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 40 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 42 | 41 |
| 43 PP_Var owner = | 42 PP_Var owner = |
| 44 ppapi_proxy::PPBInstanceInterface()->GetOwnerElementObject( | 43 ppapi_proxy::PPBInstanceInterface()->GetOwnerElementObject(instance); |
| 45 static_cast<PP_Instance>(instance)); | |
| 46 if (!ppapi_proxy::SerializeTo(&owner, owner_bytes, owner_size)) | 44 if (!ppapi_proxy::SerializeTo(&owner, owner_bytes, owner_size)) |
| 47 return; | 45 return; |
| 48 | 46 |
| 49 rpc->result = NACL_SRPC_RESULT_OK; | 47 rpc->result = NACL_SRPC_RESULT_OK; |
| 50 } | 48 } |
| 51 | 49 |
| 52 void PpbInstanceRpcServer::PPB_Instance_BindGraphics( | 50 void PpbInstanceRpcServer::PPB_Instance_BindGraphics( |
| 53 NaClSrpcRpc* rpc, | 51 NaClSrpcRpc* rpc, |
| 54 NaClSrpcClosure* done, | 52 NaClSrpcClosure* done, |
| 55 // inputs | 53 // inputs |
| 56 int64_t instance, | 54 PP_Instance instance, |
| 57 int64_t graphics_device, | 55 PP_Resource graphics_device, |
| 58 // outputs | 56 // outputs |
| 59 int32_t* success) { | 57 int32_t* success) { |
| 60 NACL_UNTESTED(); | 58 NACL_UNTESTED(); |
| 61 NaClSrpcClosureRunner runner(done); | 59 NaClSrpcClosureRunner runner(done); |
| 62 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 60 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 63 | 61 |
| 64 PP_Bool pp_success = | 62 PP_Bool pp_success = |
| 65 ppapi_proxy::PPBInstanceInterface()->BindGraphics( | 63 ppapi_proxy::PPBInstanceInterface()->BindGraphics( |
| 66 static_cast<PP_Instance>(instance), | 64 instance, |
| 67 static_cast<PP_Resource>(graphics_device)); | 65 graphics_device); |
| 68 *success = (pp_success == PP_TRUE); | 66 *success = (pp_success == PP_TRUE); |
| 69 | 67 |
| 70 rpc->result = NACL_SRPC_RESULT_OK; | 68 rpc->result = NACL_SRPC_RESULT_OK; |
| 71 } | 69 } |
| 72 | 70 |
| 73 void PpbInstanceRpcServer::PPB_Instance_IsFullFrame( | 71 void PpbInstanceRpcServer::PPB_Instance_IsFullFrame( |
| 74 NaClSrpcRpc* rpc, | 72 NaClSrpcRpc* rpc, |
| 75 NaClSrpcClosure* done, | 73 NaClSrpcClosure* done, |
| 76 // inputs | 74 // inputs |
| 77 int64_t instance, | 75 PP_Instance instance, |
| 78 // outputs | 76 // outputs |
| 79 int32_t* is_full_frame) { | 77 int32_t* is_full_frame) { |
| 80 NACL_UNTESTED(); | 78 NACL_UNTESTED(); |
| 81 NaClSrpcClosureRunner runner(done); | 79 NaClSrpcClosureRunner runner(done); |
| 82 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 80 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 83 | 81 |
| 84 PP_Bool pp_is_full_frame = | 82 PP_Bool pp_is_full_frame = |
| 85 ppapi_proxy::PPBInstanceInterface()->IsFullFrame( | 83 ppapi_proxy::PPBInstanceInterface()->IsFullFrame(instance); |
| 86 static_cast<PP_Instance>(instance)); | |
| 87 *is_full_frame = (pp_is_full_frame == PP_TRUE); | 84 *is_full_frame = (pp_is_full_frame == PP_TRUE); |
| 88 | 85 |
| 89 rpc->result = NACL_SRPC_RESULT_OK; | 86 rpc->result = NACL_SRPC_RESULT_OK; |
| 90 } | 87 } |
| 91 | 88 |
| 92 void PpbInstanceRpcServer::PPB_Instance_ExecuteScript( | 89 void PpbInstanceRpcServer::PPB_Instance_ExecuteScript( |
| 93 NaClSrpcRpc* rpc, | 90 NaClSrpcRpc* rpc, |
| 94 NaClSrpcClosure* done, | 91 NaClSrpcClosure* done, |
| 95 // inputs | 92 // inputs |
| 96 int64_t instance, | 93 PP_Instance instance, |
| 97 nacl_abi_size_t script_size, char* script_bytes, | 94 nacl_abi_size_t script_size, char* script_bytes, |
| 98 nacl_abi_size_t exception_in_size, char* exception_in_bytes, | 95 nacl_abi_size_t exception_in_size, char* exception_in_bytes, |
| 99 // outputs | 96 // outputs |
| 100 nacl_abi_size_t* result_size, char* result_bytes, | 97 nacl_abi_size_t* result_size, char* result_bytes, |
| 101 nacl_abi_size_t* exception_size, char* exception_bytes) { | 98 nacl_abi_size_t* exception_size, char* exception_bytes) { |
| 102 NACL_UNTESTED(); | 99 NACL_UNTESTED(); |
| 103 NaClSrpcClosureRunner runner(done); | 100 NaClSrpcClosureRunner runner(done); |
| 104 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 101 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 105 | 102 |
| 106 PP_Var script; | 103 PP_Var script; |
| 107 if (!ppapi_proxy::DeserializeTo( | 104 if (!ppapi_proxy::DeserializeTo( |
| 108 rpc->channel, script_bytes, script_size, 1, &script)) | 105 rpc->channel, script_bytes, script_size, 1, &script)) |
| 109 return; | 106 return; |
| 110 PP_Var exception; | 107 PP_Var exception; |
| 111 if (!ppapi_proxy::DeserializeTo( | 108 if (!ppapi_proxy::DeserializeTo( |
| 112 rpc->channel, exception_in_bytes, exception_in_size, 1, &exception)) | 109 rpc->channel, exception_in_bytes, exception_in_size, 1, &exception)) |
| 113 return; | 110 return; |
| 114 PP_Var result = | 111 PP_Var result = |
| 115 ppapi_proxy::PPBInstanceInterface()->ExecuteScript( | 112 ppapi_proxy::PPBInstanceInterface()->ExecuteScript( |
| 116 static_cast<PP_Instance>(instance), | 113 instance, script, &exception); |
| 117 script, | |
| 118 &exception); | |
| 119 if (!ppapi_proxy::SerializeTo(&result, result_bytes, result_size)) | 114 if (!ppapi_proxy::SerializeTo(&result, result_bytes, result_size)) |
| 120 return; | 115 return; |
| 121 if (!ppapi_proxy::SerializeTo(&exception, exception_bytes, exception_size)) | 116 if (!ppapi_proxy::SerializeTo(&exception, exception_bytes, exception_size)) |
| 122 return; | 117 return; |
| 123 | 118 |
| 124 rpc->result = NACL_SRPC_RESULT_OK; | 119 rpc->result = NACL_SRPC_RESULT_OK; |
| 125 } | 120 } |
| OLD | NEW |