Chromium Code Reviews| Index: src/shared/ppapi_proxy/browser_ppp_input_event.h |
| diff --git a/src/shared/ppapi_proxy/browser_ppp_input_event.h b/src/shared/ppapi_proxy/browser_ppp_input_event.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..63f41c0ed3b8430705075032407d87e22fed459d |
| --- /dev/null |
| +++ b/src/shared/ppapi_proxy/browser_ppp_input_event.h |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2010 The Native Client Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can |
| +// be found in the LICENSE file. |
| + |
| +#ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_INPUT_EVENT_H_ |
| +#define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_INPUT_EVENT_H_ |
| + |
| +#include <map> |
| + |
| +#include "native_client/src/include/nacl_macros.h" |
| +// Needed because ppp_instance.h does not include everything it needs. |
| +#include "native_client/src/third_party/ppapi/c/pp_resource.h" |
| +#include "native_client/src/third_party/ppapi/c/pp_instance.h" |
| +#include "native_client/src/third_party/ppapi/c/ppb_input_event.h" |
| + |
| +struct PPP_InputEvent; |
| + |
| +namespace ppapi_proxy { |
| + |
| +// Implements the trusted side of the PPP_InputEvent interface. |
| +class BrowserInputEvent { |
| + public: |
| + static const PPP_InputEvent* GetInterface(); |
| + |
| + // PPP_InputEvent is dispatching an event, it needs to know whether it should |
| + // ignore the 'handled' PP_Bool return value for events the NaCl instance is |
| + // not filtering. These functions allow the PPB_InputEvent proxy code to |
| + // BrowserInputEvent what event types are requested (filtering & not) and when |
| + // requests for event types are cleared. See ppb_input_event_rpc_server.cc for |
| + // where these functions are used. |
| + static void InputEventsRequested(PP_Instance instance, uint32_t event_classes, |
| + bool filtering); |
| + static void InputEventsCleared(PP_Instance, uint32_t event_classes); |
| + static bool InputEventTypeIsRegistered(PP_Instance instance, |
| + PP_InputEvent_Type type); |
| + static bool InputEventTypeIsFiltered(PP_Instance instance, |
| + PP_InputEvent_Type type); |
| + |
| + // Allows BrowserInstance to remove and instance from our map on deletion of |
|
sehr (please use chromium)
2011/07/20 00:33:41
s/and/an/
dmichael (off chromium)
2011/07/20 03:50:22
Done.
|
| + // an instance. (TODO(NaCl team): It would probably make sense to use |
| + // observer pattern for instance creation/deletion if we have much of this |
| + // kind of stuff). |
| + static void InstanceDestroyed(PP_Instance instance); |
| + |
| + private: |
| + // A struct to hold 'registered_nonfiltering' and 'registered_filtering' |
| + // bitfields. This is used in the map below. |
| + struct RegisteredTypes { |
| + RegisteredTypes() : filtering(0), nonfiltering(0) { |
| + } |
| + uint32_t filtering; |
| + uint32_t nonfiltering; |
| + }; |
| + |
| + // This map is used so that when PPB_InputEvent is used to request input |
| + // events, it can store the filtering flags here. Then, when PPP_InputEvent is |
| + // dispatching an event, it can ignore the 'handled' PP_Bool return value for |
| + // events the NaCl instance is not filtering. See |
| + // ppb_input_event_rpc_server.cc for where filtering bitfields are added to |
| + // this map. |
| + typedef std::map<PP_Instance, RegisteredTypes> InstanceRegisteredTypesMap; |
| + static InstanceRegisteredTypesMap& instance_registered_map() { |
| + static InstanceRegisteredTypesMap map; |
|
sehr (please use chromium)
2011/07/20 00:33:41
The same thread safety issue we were talking about
dmichael (off chromium)
2011/07/20 03:50:22
Input events always come in on the main thread. Th
|
| + return map; |
| + } |
| + |
| + private: |
| + NACL_DISALLOW_COPY_AND_ASSIGN(BrowserInputEvent); |
| +}; |
| + |
| +} // namespace ppapi_proxy |
| + |
| +#endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_INPUT_EVENT_H_ |