OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 #ifndef PPAPI_PROXY_PLUGIN_VAR_TRACKER_H_ | 5 #ifndef PPAPI_PROXY_PLUGIN_VAR_TRACKER_H_ |
6 #define PPAPI_PROXY_PLUGIN_VAR_TRACKER_H_ | 6 #define PPAPI_PROXY_PLUGIN_VAR_TRACKER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 class ProxyObjectVar; | 25 class ProxyObjectVar; |
26 | 26 |
27 namespace proxy { | 27 namespace proxy { |
28 | 28 |
29 class PluginDispatcher; | 29 class PluginDispatcher; |
30 | 30 |
31 // Tracks live strings and objects in the plugin process. | 31 // Tracks live strings and objects in the plugin process. |
32 class PPAPI_PROXY_EXPORT PluginVarTracker : public VarTracker { | 32 class PPAPI_PROXY_EXPORT PluginVarTracker : public VarTracker { |
33 public: | 33 public: |
34 PluginVarTracker(); | 34 PluginVarTracker(); |
35 ~PluginVarTracker(); | 35 ~PluginVarTracker() override; |
36 | 36 |
37 // Manages tracking for receiving a VARTYPE_OBJECT from the remote side | 37 // Manages tracking for receiving a VARTYPE_OBJECT from the remote side |
38 // (either the plugin or the renderer) that has already had its reference | 38 // (either the plugin or the renderer) that has already had its reference |
39 // count incremented on behalf of the caller. | 39 // count incremented on behalf of the caller. |
40 PP_Var ReceiveObjectPassRef(const PP_Var& var, PluginDispatcher* dispatcher); | 40 PP_Var ReceiveObjectPassRef(const PP_Var& var, PluginDispatcher* dispatcher); |
41 | 41 |
42 // See the comment in var_tracker.h for more about what a tracked object is. | 42 // See the comment in var_tracker.h for more about what a tracked object is. |
43 // This adds and releases the "track_with_no_reference_count" for a given | 43 // This adds and releases the "track_with_no_reference_count" for a given |
44 // object. | 44 // object. |
45 PP_Var TrackObjectWithNoReference(const PP_Var& host_var, | 45 PP_Var TrackObjectWithNoReference(const PP_Var& host_var, |
46 PluginDispatcher* dispatcher); | 46 PluginDispatcher* dispatcher); |
47 void StopTrackingObjectWithNoReference(const PP_Var& plugin_var); | 47 void StopTrackingObjectWithNoReference(const PP_Var& plugin_var); |
48 | 48 |
49 // Returns the host var for the corresponding plugin object var. The object | 49 // Returns the host var for the corresponding plugin object var. The object |
50 // should be a VARTYPE_OBJECT. The reference count is not affeceted. | 50 // should be a VARTYPE_OBJECT. The reference count is not affeceted. |
51 PP_Var GetHostObject(const PP_Var& plugin_object) const; | 51 PP_Var GetHostObject(const PP_Var& plugin_object) const; |
52 | 52 |
53 PluginDispatcher* DispatcherForPluginObject( | 53 PluginDispatcher* DispatcherForPluginObject( |
54 const PP_Var& plugin_object) const; | 54 const PP_Var& plugin_object) const; |
55 | 55 |
56 // Like Release() but the var is identified by its host object ID (as | 56 // Like Release() but the var is identified by its host object ID (as |
57 // returned by GetHostObject). | 57 // returned by GetHostObject). |
58 void ReleaseHostObject(PluginDispatcher* dispatcher, | 58 void ReleaseHostObject(PluginDispatcher* dispatcher, |
59 const PP_Var& host_object); | 59 const PP_Var& host_object); |
60 | 60 |
61 // VarTracker public overrides. | 61 // VarTracker public overrides. |
62 virtual PP_Var MakeResourcePPVarFromMessage( | 62 PP_Var MakeResourcePPVarFromMessage(PP_Instance instance, |
63 PP_Instance instance, | 63 const IPC::Message& creation_message, |
64 const IPC::Message& creation_message, | 64 int pending_renderer_id, |
65 int pending_renderer_id, | 65 int pending_browser_id) override; |
66 int pending_browser_id) override; | 66 ResourceVar* MakeResourceVar(PP_Resource pp_resource) override; |
67 virtual ResourceVar* MakeResourceVar(PP_Resource pp_resource) override; | 67 void DidDeleteInstance(PP_Instance instance) override; |
68 virtual void DidDeleteInstance(PP_Instance instance) override; | 68 int TrackSharedMemoryHandle(PP_Instance instance, |
69 virtual int TrackSharedMemoryHandle(PP_Instance instance, | 69 base::SharedMemoryHandle file, |
70 base::SharedMemoryHandle file, | 70 uint32 size_in_bytes) override; |
71 uint32 size_in_bytes) override; | 71 bool StopTrackingSharedMemoryHandle(int id, |
72 virtual bool StopTrackingSharedMemoryHandle(int id, | 72 PP_Instance instance, |
73 PP_Instance instance, | 73 base::SharedMemoryHandle* handle, |
74 base::SharedMemoryHandle* handle, | 74 uint32* size_in_bytes) override; |
75 uint32* size_in_bytes) override; | |
76 | 75 |
77 // Notification that a plugin-implemented object (PPP_Class) was created by | 76 // Notification that a plugin-implemented object (PPP_Class) was created by |
78 // the plugin or deallocated by WebKit over IPC. | 77 // the plugin or deallocated by WebKit over IPC. |
79 void PluginImplementedObjectCreated(PP_Instance instance, | 78 void PluginImplementedObjectCreated(PP_Instance instance, |
80 const PP_Var& created_var, | 79 const PP_Var& created_var, |
81 const PPP_Class_Deprecated* ppp_class, | 80 const PPP_Class_Deprecated* ppp_class, |
82 void* ppp_class_data); | 81 void* ppp_class_data); |
83 void PluginImplementedObjectDestroyed(void* ppp_class_data); | 82 void PluginImplementedObjectDestroyed(void* ppp_class_data); |
84 | 83 |
85 // Returns true if there is an object implemented by the plugin with the | 84 // Returns true if there is an object implemented by the plugin with the |
86 // given user_data that has not been deallocated yet. Call this when | 85 // given user_data that has not been deallocated yet. Call this when |
87 // receiving a scripting call to the plugin to validate that the object | 86 // receiving a scripting call to the plugin to validate that the object |
88 // receiving the call is still alive (see user_data_to_plugin_ below). | 87 // receiving the call is still alive (see user_data_to_plugin_ below). |
89 bool IsPluginImplementedObjectAlive(void* user_data); | 88 bool IsPluginImplementedObjectAlive(void* user_data); |
90 | 89 |
91 // Validates that the given class/user_data pair corresponds to a currently | 90 // Validates that the given class/user_data pair corresponds to a currently |
92 // living plugin object. | 91 // living plugin object. |
93 bool ValidatePluginObjectCall(const PPP_Class_Deprecated* ppp_class, | 92 bool ValidatePluginObjectCall(const PPP_Class_Deprecated* ppp_class, |
94 void* user_data); | 93 void* user_data); |
95 | 94 |
96 void DidDeleteDispatcher(PluginDispatcher* dispatcher); | 95 void DidDeleteDispatcher(PluginDispatcher* dispatcher); |
97 | 96 |
98 private: | 97 private: |
99 // VarTracker protected overrides. | 98 // VarTracker protected overrides. |
100 virtual int32 AddVarInternal(Var* var, AddVarRefMode mode) override; | 99 int32 AddVarInternal(Var* var, AddVarRefMode mode) override; |
101 virtual void TrackedObjectGettingOneRef(VarMap::const_iterator iter) override; | 100 void TrackedObjectGettingOneRef(VarMap::const_iterator iter) override; |
102 virtual void ObjectGettingZeroRef(VarMap::iterator iter) override; | 101 void ObjectGettingZeroRef(VarMap::iterator iter) override; |
103 virtual bool DeleteObjectInfoIfNecessary(VarMap::iterator iter) override; | 102 bool DeleteObjectInfoIfNecessary(VarMap::iterator iter) override; |
104 virtual ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) override; | 103 ArrayBufferVar* CreateArrayBuffer(uint32 size_in_bytes) override; |
105 virtual ArrayBufferVar* CreateShmArrayBuffer( | 104 ArrayBufferVar* CreateShmArrayBuffer( |
106 uint32 size_in_bytes, | 105 uint32 size_in_bytes, |
107 base::SharedMemoryHandle handle) override; | 106 base::SharedMemoryHandle handle) override; |
108 | 107 |
109 private: | 108 private: |
110 friend struct DefaultSingletonTraits<PluginVarTracker>; | 109 friend struct DefaultSingletonTraits<PluginVarTracker>; |
111 friend class PluginProxyTestHarness; | 110 friend class PluginProxyTestHarness; |
112 | 111 |
113 // Represents a var as received from the host. | 112 // Represents a var as received from the host. |
114 struct HostVar { | 113 struct HostVar { |
115 HostVar(PluginDispatcher* d, int32 i); | 114 HostVar(PluginDispatcher* d, int32 i); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 UserDataToPluginImplementedVarMap; | 201 UserDataToPluginImplementedVarMap; |
203 UserDataToPluginImplementedVarMap user_data_to_plugin_; | 202 UserDataToPluginImplementedVarMap user_data_to_plugin_; |
204 | 203 |
205 DISALLOW_COPY_AND_ASSIGN(PluginVarTracker); | 204 DISALLOW_COPY_AND_ASSIGN(PluginVarTracker); |
206 }; | 205 }; |
207 | 206 |
208 } // namespace proxy | 207 } // namespace proxy |
209 } // namespace ppapi | 208 } // namespace ppapi |
210 | 209 |
211 #endif // PPAPI_PROXY_PLUGIN_VAR_TRACKER_H_ | 210 #endif // PPAPI_PROXY_PLUGIN_VAR_TRACKER_H_ |
OLD | NEW |