| 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 <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "native_client/src/include/portability.h" | 9 #include "native_client/src/include/portability.h" |
| 10 #include "native_client/src/include/portability_process.h" | 10 #include "native_client/src/include/portability_process.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return array; | 67 return array; |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 | 72 |
| 73 void PppInstanceRpcServer::PPP_Instance_DidCreate( | 73 void PppInstanceRpcServer::PPP_Instance_DidCreate( |
| 74 NaClSrpcRpc* rpc, | 74 NaClSrpcRpc* rpc, |
| 75 NaClSrpcClosure* done, | 75 NaClSrpcClosure* done, |
| 76 // inputs | 76 // inputs |
| 77 int64_t instance, | 77 PP_Instance instance, |
| 78 int32_t argc, | 78 int32_t argc, |
| 79 uint32_t argn_bytes, char* argn, | 79 uint32_t argn_bytes, char* argn, |
| 80 uint32_t argv_bytes, char* argv, | 80 uint32_t argv_bytes, char* argv, |
| 81 // outputs | 81 // outputs |
| 82 int32_t* success) { | 82 int32_t* success) { |
| 83 NaClSrpcClosureRunner runner(done); | 83 NaClSrpcClosureRunner runner(done); |
| 84 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 84 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 85 *success = kMethodFailure; | 85 *success = kMethodFailure; |
| 86 const PPP_Instance* instance_interface = GetInstanceInterface(); | 86 const PPP_Instance* instance_interface = GetInstanceInterface(); |
| 87 if (instance_interface == NULL || instance_interface->DidCreate == NULL) { | 87 if (instance_interface == NULL || instance_interface->DidCreate == NULL) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 101 argn_copy.get(), | 101 argn_copy.get(), |
| 102 argv_copy.get()); | 102 argv_copy.get()); |
| 103 *success = initialize_result ? kMethodSuccess : kMethodFailure; | 103 *success = initialize_result ? kMethodSuccess : kMethodFailure; |
| 104 rpc->result = NACL_SRPC_RESULT_OK; | 104 rpc->result = NACL_SRPC_RESULT_OK; |
| 105 } | 105 } |
| 106 | 106 |
| 107 void PppInstanceRpcServer::PPP_Instance_DidDestroy( | 107 void PppInstanceRpcServer::PPP_Instance_DidDestroy( |
| 108 NaClSrpcRpc* rpc, | 108 NaClSrpcRpc* rpc, |
| 109 NaClSrpcClosure* done, | 109 NaClSrpcClosure* done, |
| 110 // inputs | 110 // inputs |
| 111 int64_t instance) { | 111 PP_Instance instance) { |
| 112 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 112 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 113 NaClSrpcClosureRunner runner(done); | 113 NaClSrpcClosureRunner runner(done); |
| 114 const PPP_Instance* instance_interface = GetInstanceInterface(); | 114 const PPP_Instance* instance_interface = GetInstanceInterface(); |
| 115 if (instance_interface == NULL || instance_interface->DidDestroy == NULL) { | 115 if (instance_interface == NULL || instance_interface->DidDestroy == NULL) { |
| 116 rpc->result = NACL_SRPC_RESULT_OK; | 116 rpc->result = NACL_SRPC_RESULT_OK; |
| 117 return; | 117 return; |
| 118 } | 118 } |
| 119 instance_interface->DidDestroy(instance); | 119 instance_interface->DidDestroy(instance); |
| 120 rpc->result = NACL_SRPC_RESULT_OK; | 120 rpc->result = NACL_SRPC_RESULT_OK; |
| 121 } | 121 } |
| 122 | 122 |
| 123 void PppInstanceRpcServer::PPP_Instance_DidChangeView( | 123 void PppInstanceRpcServer::PPP_Instance_DidChangeView( |
| 124 NaClSrpcRpc* rpc, | 124 NaClSrpcRpc* rpc, |
| 125 NaClSrpcClosure* done, | 125 NaClSrpcClosure* done, |
| 126 // inputs | 126 // inputs |
| 127 int64_t instance, | 127 PP_Instance instance, |
| 128 uint32_t position_count, int32_t* position, | 128 uint32_t position_count, int32_t* position, |
| 129 uint32_t clip_count, int32_t* clip) { | 129 uint32_t clip_count, int32_t* clip) { |
| 130 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 130 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 131 NaClSrpcClosureRunner runner(done); | 131 NaClSrpcClosureRunner runner(done); |
| 132 const PPP_Instance* instance_interface = GetInstanceInterface(); | 132 const PPP_Instance* instance_interface = GetInstanceInterface(); |
| 133 if (instance_interface == NULL || | 133 if (instance_interface == NULL || |
| 134 instance_interface->DidChangeView == NULL) { | 134 instance_interface->DidChangeView == NULL) { |
| 135 return; | 135 return; |
| 136 } | 136 } |
| 137 if (position_count != 4 || clip_count != 4) { | 137 if (position_count != 4 || clip_count != 4) { |
| 138 return; | 138 return; |
| 139 } | 139 } |
| 140 const PP_Rect position_rect = | 140 const PP_Rect position_rect = |
| 141 PP_MakeRectFromXYWH(position[0], position[1], position[2], position[3]); | 141 PP_MakeRectFromXYWH(position[0], position[1], position[2], position[3]); |
| 142 const PP_Rect clip_rect = | 142 const PP_Rect clip_rect = |
| 143 PP_MakeRectFromXYWH(clip[0], clip[1], clip[2], clip[3]); | 143 PP_MakeRectFromXYWH(clip[0], clip[1], clip[2], clip[3]); |
| 144 | 144 |
| 145 instance_interface->DidChangeView(instance, &position_rect, &clip_rect); | 145 instance_interface->DidChangeView(instance, &position_rect, &clip_rect); |
| 146 rpc->result = NACL_SRPC_RESULT_OK; | 146 rpc->result = NACL_SRPC_RESULT_OK; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void PppInstanceRpcServer::PPP_Instance_DidChangeFocus( | 149 void PppInstanceRpcServer::PPP_Instance_DidChangeFocus( |
| 150 NaClSrpcRpc* rpc, | 150 NaClSrpcRpc* rpc, |
| 151 NaClSrpcClosure* done, | 151 NaClSrpcClosure* done, |
| 152 // inputs | 152 // inputs |
| 153 int64_t instance, | 153 PP_Instance instance, |
| 154 bool has_focus) { | 154 bool has_focus) { |
| 155 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 155 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 156 NaClSrpcClosureRunner runner(done); | 156 NaClSrpcClosureRunner runner(done); |
| 157 // FocusChanged() has a void return, so it always succeeds at this interface | 157 // FocusChanged() has a void return, so it always succeeds at this interface |
| 158 // level. | 158 // level. |
| 159 const PPP_Instance* instance_interface = GetInstanceInterface(); | 159 const PPP_Instance* instance_interface = GetInstanceInterface(); |
| 160 if (instance_interface != NULL && | 160 if (instance_interface != NULL && |
| 161 instance_interface->DidChangeFocus != NULL) { | 161 instance_interface->DidChangeFocus != NULL) { |
| 162 instance_interface->DidChangeFocus(instance, | 162 instance_interface->DidChangeFocus(instance, |
| 163 static_cast<PP_Bool>(has_focus)); | 163 static_cast<PP_Bool>(has_focus)); |
| 164 } | 164 } |
| 165 rpc->result = NACL_SRPC_RESULT_OK; | 165 rpc->result = NACL_SRPC_RESULT_OK; |
| 166 } | 166 } |
| 167 | 167 |
| 168 void PppInstanceRpcServer::PPP_Instance_HandleInputEvent( | 168 void PppInstanceRpcServer::PPP_Instance_HandleInputEvent( |
| 169 NaClSrpcRpc* rpc, | 169 NaClSrpcRpc* rpc, |
| 170 NaClSrpcClosure* done, | 170 NaClSrpcClosure* done, |
| 171 // inputs | 171 // inputs |
| 172 int64_t instance, | 172 PP_Instance instance, |
| 173 uint32_t event_data_bytes, char* event_data, | 173 uint32_t event_data_bytes, char* event_data, |
| 174 // outputs | 174 // outputs |
| 175 int32_t* success) { | 175 int32_t* success) { |
| 176 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 176 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 177 NaClSrpcClosureRunner runner(done); | 177 NaClSrpcClosureRunner runner(done); |
| 178 *success = kMethodFailure; | 178 *success = kMethodFailure; |
| 179 const PPP_Instance* instance_interface = GetInstanceInterface(); | 179 const PPP_Instance* instance_interface = GetInstanceInterface(); |
| 180 if (instance_interface == NULL || | 180 if (instance_interface == NULL || |
| 181 instance_interface->HandleInputEvent == NULL) { | 181 instance_interface->HandleInputEvent == NULL) { |
| 182 rpc->result = NACL_SRPC_RESULT_OK; | 182 rpc->result = NACL_SRPC_RESULT_OK; |
| 183 return; | 183 return; |
| 184 } | 184 } |
| 185 const PP_InputEvent* event = | 185 const PP_InputEvent* event = |
| 186 reinterpret_cast<const PP_InputEvent*>(event_data); | 186 reinterpret_cast<const PP_InputEvent*>(event_data); |
| 187 bool event_result = instance_interface->HandleInputEvent(instance, event); | 187 bool event_result = instance_interface->HandleInputEvent(instance, event); |
| 188 *success = event_result ? kMethodSuccess : kMethodFailure; | 188 *success = event_result ? kMethodSuccess : kMethodFailure; |
| 189 rpc->result = NACL_SRPC_RESULT_OK; | 189 rpc->result = NACL_SRPC_RESULT_OK; |
| 190 } | 190 } |
| 191 | 191 |
| 192 void PppInstanceRpcServer::PPP_Instance_HandleDocumentLoad( | 192 void PppInstanceRpcServer::PPP_Instance_HandleDocumentLoad( |
| 193 NaClSrpcRpc* rpc, | 193 NaClSrpcRpc* rpc, |
| 194 NaClSrpcClosure* done, | 194 NaClSrpcClosure* done, |
| 195 // inputs | 195 // inputs |
| 196 int64_t instance, | 196 PP_Instance instance, |
| 197 int64_t url_loader, | 197 PP_Resource url_loader, |
| 198 // outputs | 198 // outputs |
| 199 int32_t* success) { | 199 int32_t* success) { |
| 200 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 200 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 201 NaClSrpcClosureRunner runner(done); | 201 NaClSrpcClosureRunner runner(done); |
| 202 *success = kMethodFailure; | 202 *success = kMethodFailure; |
| 203 const PPP_Instance* instance_interface = GetInstanceInterface(); | 203 const PPP_Instance* instance_interface = GetInstanceInterface(); |
| 204 if (instance_interface == NULL || | 204 if (instance_interface == NULL || |
| 205 instance_interface->HandleDocumentLoad == NULL) { | 205 instance_interface->HandleDocumentLoad == NULL) { |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 bool handle_result = instance_interface->HandleDocumentLoad(instance, | 208 bool handle_result = instance_interface->HandleDocumentLoad(instance, |
| 209 url_loader); | 209 url_loader); |
| 210 *success = handle_result ? kMethodSuccess : kMethodFailure; | 210 *success = handle_result ? kMethodSuccess : kMethodFailure; |
| 211 rpc->result = NACL_SRPC_RESULT_OK; | 211 rpc->result = NACL_SRPC_RESULT_OK; |
| 212 } | 212 } |
| 213 | 213 |
| 214 void PppInstanceRpcServer::PPP_Instance_GetInstanceObject( | 214 void PppInstanceRpcServer::PPP_Instance_GetInstanceObject( |
| 215 NaClSrpcRpc* rpc, | 215 NaClSrpcRpc* rpc, |
| 216 NaClSrpcClosure* done, | 216 NaClSrpcClosure* done, |
| 217 // inputs | 217 // inputs |
| 218 int64_t instance, | 218 PP_Instance instance, |
| 219 // outputs | 219 // outputs |
| 220 uint32_t* capability_bytes, char* capability) { | 220 uint32_t* capability_bytes, char* capability) { |
| 221 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 221 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 222 NaClSrpcClosureRunner runner(done); | 222 NaClSrpcClosureRunner runner(done); |
| 223 const PPP_Instance* instance_interface = GetInstanceInterface(); | 223 const PPP_Instance* instance_interface = GetInstanceInterface(); |
| 224 if (instance_interface == NULL || | 224 if (instance_interface == NULL || |
| 225 instance_interface->GetInstanceObject == NULL || | 225 instance_interface->GetInstanceObject == NULL || |
| 226 *capability_bytes < sizeof(ppapi_proxy::ObjectCapability)) { | 226 *capability_bytes < sizeof(ppapi_proxy::ObjectCapability)) { |
| 227 return; | 227 return; |
| 228 } | 228 } |
| 229 PP_Var instance_var = instance_interface->GetInstanceObject(instance); | 229 PP_Var instance_var = instance_interface->GetInstanceObject(instance); |
| 230 if (instance_var.type != PP_VARTYPE_OBJECT) { | 230 if (instance_var.type != PP_VARTYPE_OBJECT) { |
| 231 return; | 231 return; |
| 232 } | 232 } |
| 233 // Create the return capability. | 233 // Create the return capability. |
| 234 ppapi_proxy::ObjectCapability cap(GETPID(), instance_var.value.as_id); | 234 ppapi_proxy::ObjectCapability cap(GETPID(), instance_var.value.as_id); |
| 235 *reinterpret_cast<ppapi_proxy::ObjectCapability*>(capability) = cap; | 235 *reinterpret_cast<ppapi_proxy::ObjectCapability*>(capability) = cap; |
| 236 *capability_bytes = sizeof(ppapi_proxy::ObjectCapability); | 236 *capability_bytes = sizeof(ppapi_proxy::ObjectCapability); |
| 237 rpc->result = NACL_SRPC_RESULT_OK; | 237 rpc->result = NACL_SRPC_RESULT_OK; |
| 238 } | 238 } |
| OLD | NEW |