| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2010 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can | |
| 4 * be found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 #ifndef NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_OBJECT_H_ | |
| 8 #define NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_OBJECT_H_ | |
| 9 | |
| 10 #include <map> | |
| 11 #include <string> | |
| 12 #include "ppapi/c/dev/ppp_class_deprecated.h" | |
| 13 #include "ppapi/c/pp_instance.h" | |
| 14 #include "ppapi/c/pp_module.h" | |
| 15 #include "ppapi/c/pp_var.h" | |
| 16 | |
| 17 #include "native_client/src/include/nacl_macros.h" | |
| 18 #include "native_client/src/shared/ppapi_proxy/object.h" | |
| 19 | |
| 20 namespace fake_browser_ppapi { | |
| 21 | |
| 22 // Implements a scriptable object in PPAPI. | |
| 23 class Object : public ppapi_proxy::Object { | |
| 24 public: | |
| 25 virtual ~Object() {} | |
| 26 // The bindings for the methods invoked by the PPAPI interface. | |
| 27 virtual bool HasProperty(PP_Var name, | |
| 28 PP_Var* exception); | |
| 29 virtual bool HasMethod(PP_Var name, | |
| 30 PP_Var* exception); | |
| 31 virtual PP_Var GetProperty(PP_Var name, | |
| 32 PP_Var* exception); | |
| 33 virtual void GetAllPropertyNames(uint32_t* property_count, | |
| 34 PP_Var** properties, | |
| 35 PP_Var* exception); | |
| 36 virtual void SetProperty(PP_Var name, | |
| 37 PP_Var value, | |
| 38 PP_Var* exception); | |
| 39 virtual void RemoveProperty(PP_Var name, | |
| 40 PP_Var* exception); | |
| 41 virtual PP_Var Call(PP_Var method_name, | |
| 42 uint32_t argc, | |
| 43 PP_Var* argv, | |
| 44 PP_Var* exception); | |
| 45 virtual PP_Var Construct(uint32_t argc, | |
| 46 PP_Var* argv, | |
| 47 PP_Var* exception); | |
| 48 virtual void Deallocate(); | |
| 49 | |
| 50 typedef std::map<std::string, PP_Var*> PropertyMap; | |
| 51 typedef PP_Var (*Method)(Object* object, | |
| 52 uint32_t argc, | |
| 53 PP_Var* argv, | |
| 54 PP_Var* exception); | |
| 55 typedef std::map<std::string, Method> MethodMap; | |
| 56 | |
| 57 // Create a PP_Var object with a set of initial properties. | |
| 58 static PP_Var New(PP_Module module, | |
| 59 PP_Instance instance, | |
| 60 const PropertyMap& properties, | |
| 61 const MethodMap& methods); | |
| 62 | |
| 63 // Construct using a map of initial properties. | |
| 64 Object(PP_Module module, | |
| 65 PP_Instance instance, | |
| 66 const PropertyMap& properties, | |
| 67 const MethodMap& methods); | |
| 68 | |
| 69 PropertyMap* properties() { return &properties_; } | |
| 70 MethodMap* methods() { return &methods_; } | |
| 71 PP_Module module() const { return module_; } | |
| 72 PP_Instance instance() { return instance_; } | |
| 73 | |
| 74 private: | |
| 75 // Maintains the list of properties for Set/Get/Remove. | |
| 76 PropertyMap properties_; | |
| 77 // Maintains the list of methods that can be invoked by Call. | |
| 78 MethodMap methods_; | |
| 79 // Keep track of the PP_Module that created us. | |
| 80 PP_Module module_; | |
| 81 // Keep track of the PP_Instance that created us. | |
| 82 PP_Instance instance_; | |
| 83 | |
| 84 NACL_DISALLOW_COPY_AND_ASSIGN(Object); | |
| 85 }; | |
| 86 | |
| 87 } // namespace fake_browser_ppapi | |
| 88 | |
| 89 #endif // NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_OBJECT_H_ | |
| OLD | NEW |