OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 The Native Client Authors. All rights reserved. | 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 | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #ifndef NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_OBJECT_H_ | 7 #ifndef NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_OBJECT_H_ |
8 #define NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_OBJECT_H_ | 8 #define NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_OBJECT_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <string> | 11 #include <string> |
| 12 #include "ppapi/c/pp_module.h" |
12 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
13 #include "ppapi/c/ppp_class.h" | 14 #include "ppapi/c/ppp_class.h" |
14 | 15 |
15 #include "native_client/src/include/nacl_macros.h" | 16 #include "native_client/src/include/nacl_macros.h" |
16 #include "native_client/src/shared/ppapi_proxy/object.h" | 17 #include "native_client/src/shared/ppapi_proxy/object.h" |
17 | 18 |
18 namespace fake_browser_ppapi { | 19 namespace fake_browser_ppapi { |
19 | 20 |
20 // Implements a scriptable object in PPAPI. | 21 // Implements a scriptable object in PPAPI. |
21 class Object : public ppapi_proxy::Object { | 22 class Object : public ppapi_proxy::Object { |
(...skipping 24 matching lines...) Expand all Loading... |
46 virtual void Deallocate(); | 47 virtual void Deallocate(); |
47 | 48 |
48 typedef std::map<std::string, PP_Var*> PropertyMap; | 49 typedef std::map<std::string, PP_Var*> PropertyMap; |
49 typedef PP_Var (*Method)(Object* object, | 50 typedef PP_Var (*Method)(Object* object, |
50 uint32_t argc, | 51 uint32_t argc, |
51 PP_Var* argv, | 52 PP_Var* argv, |
52 PP_Var* exception); | 53 PP_Var* exception); |
53 typedef std::map<std::string, Method> MethodMap; | 54 typedef std::map<std::string, Method> MethodMap; |
54 | 55 |
55 // Create a PP_Var object with a set of initial properties. | 56 // Create a PP_Var object with a set of initial properties. |
56 static PP_Var New(const PropertyMap& properties, const MethodMap& methods); | 57 static PP_Var New(PP_Module module, |
| 58 const PropertyMap& properties, |
| 59 const MethodMap& methods); |
57 | 60 |
58 // Construct using a map of initial properties. | 61 // Construct using a map of initial properties. |
59 Object(const PropertyMap& properties, const MethodMap& methods); | 62 Object(PP_Module module, |
| 63 const PropertyMap& properties, |
| 64 const MethodMap& methods); |
60 | 65 |
61 PropertyMap* properties() { return &properties_; } | 66 PropertyMap* properties() { return &properties_; } |
62 MethodMap* methods() { return &methods_; } | 67 MethodMap* methods() { return &methods_; } |
| 68 PP_Module module() const { return module_; } |
63 | 69 |
64 private: | 70 private: |
65 // Maintains the list of properties for Set/Get/Remove. | 71 // Maintains the list of properties for Set/Get/Remove. |
66 PropertyMap properties_; | 72 PropertyMap properties_; |
67 // Maintains the list of methods that can be invoked by Call. | 73 // Maintains the list of methods that can be invoked by Call. |
68 MethodMap methods_; | 74 MethodMap methods_; |
| 75 // Keep track of the PP_Module that created us. |
| 76 PP_Module module_; |
69 | 77 |
70 NACL_DISALLOW_COPY_AND_ASSIGN(Object); | 78 NACL_DISALLOW_COPY_AND_ASSIGN(Object); |
71 }; | 79 }; |
72 | 80 |
73 } // namespace fake_browser_ppapi | 81 } // namespace fake_browser_ppapi |
74 | 82 |
75 #endif // NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_OBJECT_H_ | 83 #endif // NATIVE_CLIENT_TESTS_FAKE_BROWSER_PPAPI_FAKE_OBJECT_H_ |
OLD | NEW |