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 // SRPC-abstraction wrappers around PPB_InputEvent functions. |
| 6 |
| 7 #include "native_client/src/include/portability.h" |
| 8 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
| 9 #include "native_client/src/shared/ppapi_proxy/browser_ppp_input_event.h" |
| 10 #include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h" |
| 11 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 12 #include "native_client/src/third_party/ppapi/c/pp_errors.h" |
| 13 #include "native_client/src/third_party/ppapi/c/ppb_input_event.h" |
| 14 |
| 15 |
| 16 using ppapi_proxy::DebugPrintf; |
| 17 |
| 18 void PpbInputEventRpcServer::PPB_InputEvent_RequestInputEvents( |
| 19 NaClSrpcRpc* rpc, |
| 20 NaClSrpcClosure* done, |
| 21 PP_Instance instance, |
| 22 int32_t event_classes, |
| 23 bool filtering, |
| 24 int32_t* success) { |
| 25 NaClSrpcClosureRunner runner(done); |
| 26 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 27 *success = PP_ERROR_FAILED; |
| 28 DebugPrintf("PPB_InputEvent::RequestInputEvents: instance=%"NACL_PRIu32", " |
| 29 "event_classes=%"NACL_PRIu32", filtering=%s\n", |
| 30 instance, static_cast<uint32_t>(event_classes), |
| 31 filtering ? "true" : "false"); |
| 32 const PPB_InputEvent* interface = ppapi_proxy::PPBInputEventInterface(); |
| 33 if (!interface) { |
| 34 *success = PP_ERROR_NOTSUPPORTED; |
| 35 DebugPrintf("PPB_InputEvent::RequestInputEvents: success=%"NACL_PRId32"\n", |
| 36 *success); |
| 37 return; |
| 38 } |
| 39 if (filtering) { |
| 40 *success = interface->RequestFilteringInputEvents( |
| 41 instance, |
| 42 static_cast<uint32_t>(event_classes)); |
| 43 } else { |
| 44 *success = interface->RequestInputEvents( |
| 45 instance, |
| 46 static_cast<uint32_t>(event_classes)); |
| 47 } |
| 48 // Note, according to ppb_input_event.h, if a bit is invalid, |
| 49 // PP_ERROR_NOTSUPPORTED is returned, but the valid bits are still set. |
| 50 // Hence, we set our local bitfields appropriately in case of returns of PP_OK |
| 51 // or PP_ERROR_NOTSUPPORTED. |
| 52 if ((*success == PP_OK) || (*success == PP_ERROR_NOTSUPPORTED)) { |
| 53 ppapi_proxy::BrowserInputEvent::InputEventsRequested( |
| 54 instance, |
| 55 static_cast<uint32_t>(event_classes), |
| 56 filtering); |
| 57 } |
| 58 DebugPrintf("PPB_InputEvent::RequestInputEvents: success=%"NACL_PRId32"\n", |
| 59 *success); |
| 60 rpc->result = NACL_SRPC_RESULT_OK; |
| 61 } |
| 62 |
| 63 void PpbInputEventRpcServer::PPB_InputEvent_ClearInputEventRequest( |
| 64 NaClSrpcRpc* rpc, |
| 65 NaClSrpcClosure* done, |
| 66 PP_Instance instance, |
| 67 int32_t event_classes) { |
| 68 NaClSrpcClosureRunner runner(done); |
| 69 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 70 DebugPrintf("PPB_InputEvent::ClearInputEventRequest: instance=%"NACL_PRIu32 |
| 71 ", event_classes=%"NACL_PRIu32"\n", |
| 72 instance, static_cast<uint32_t>(event_classes)); |
| 73 const PPB_InputEvent* interface = ppapi_proxy::PPBInputEventInterface(); |
| 74 if (!interface) { |
| 75 return; |
| 76 } |
| 77 interface->ClearInputEventRequest(instance, |
| 78 static_cast<uint32_t>(event_classes)); |
| 79 ppapi_proxy::BrowserInputEvent::InputEventsCleared( |
| 80 instance, |
| 81 static_cast<uint32_t>(event_classes)); |
| 82 rpc->result = NACL_SRPC_RESULT_OK; |
| 83 } |
| 84 |
OLD | NEW |