Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: ppapi/shared_impl/var_tracker.h

Issue 13887007: Introduce RawVarData and associated classes for serializing PP_Vars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_SHARED_IMPL_VAR_TRACKER_H_ 5 #ifndef PPAPI_SHARED_IMPL_VAR_TRACKER_H_
6 #define PPAPI_SHARED_IMPL_VAR_TRACKER_H_ 6 #define PPAPI_SHARED_IMPL_VAR_TRACKER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // used in production code. The PP_Vars are returned in no particular order, 90 // used in production code. The PP_Vars are returned in no particular order,
91 // and their reference counts are unaffected. 91 // and their reference counts are unaffected.
92 std::vector<PP_Var> GetLiveVars(); 92 std::vector<PP_Var> GetLiveVars();
93 93
94 // Retrieves the internal reference counts for testing. Returns 0 if we 94 // Retrieves the internal reference counts for testing. Returns 0 if we
95 // know about the object but the corresponding value is 0, or -1 if the 95 // know about the object but the corresponding value is 0, or -1 if the
96 // given object ID isn't in our map. 96 // given object ID isn't in our map.
97 int GetRefCountForObject(const PP_Var& object); 97 int GetRefCountForObject(const PP_Var& object);
98 int GetTrackedWithNoReferenceCountForObject(const PP_Var& object); 98 int GetTrackedWithNoReferenceCountForObject(const PP_Var& object);
99 99
100 // Returns true if the given vartype is refcounted and has associated objects
101 // (it's not POD).
102 static bool IsVarTypeRefcounted(PP_VarType type);
103
100 // Called after an instance is deleted to do var cleanup. 104 // Called after an instance is deleted to do var cleanup.
101 virtual void DidDeleteInstance(PP_Instance instance) = 0; 105 virtual void DidDeleteInstance(PP_Instance instance) = 0;
102 106
103 // Returns an "id" for a shared memory handle that can be safely sent between 107 // Returns an "id" for a shared memory handle that can be safely sent between
104 // the host and plugin, and resolved back into the original handle on the 108 // the host and plugin, and resolved back into the original handle on the
105 // host. Not implemented on the plugin side. 109 // host. Not implemented on the plugin side.
106 virtual int TrackSharedMemoryHandle(PP_Instance instance, 110 virtual int TrackSharedMemoryHandle(PP_Instance instance,
107 base::SharedMemoryHandle handle, 111 base::SharedMemoryHandle handle,
108 uint32 size_in_bytes) = 0; 112 uint32 size_in_bytes) = 0;
109 113
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // initial refcount of the added object will be 0 or 1. 159 // initial refcount of the added object will be 0 or 1.
156 // 160 //
157 // Overridden in the plugin proxy to do additional object tracking. 161 // Overridden in the plugin proxy to do additional object tracking.
158 virtual int32 AddVarInternal(Var* var, AddVarRefMode mode); 162 virtual int32 AddVarInternal(Var* var, AddVarRefMode mode);
159 163
160 // Convenience functions for doing lookups into the live_vars_ map. 164 // Convenience functions for doing lookups into the live_vars_ map.
161 VarMap::iterator GetLiveVar(int32 id); 165 VarMap::iterator GetLiveVar(int32 id);
162 VarMap::iterator GetLiveVar(const PP_Var& var); 166 VarMap::iterator GetLiveVar(const PP_Var& var);
163 VarMap::const_iterator GetLiveVar(const PP_Var& var) const; 167 VarMap::const_iterator GetLiveVar(const PP_Var& var) const;
164 168
165 // Returns true if the given vartype is refcounted and has associated objects
166 // (it's not POD).
167 bool IsVarTypeRefcounted(PP_VarType type) const;
168
169 // Called when AddRefVar increases a "tracked" ProxyObject's refcount from 169 // Called when AddRefVar increases a "tracked" ProxyObject's refcount from
170 // zero to one. In the plugin side of the proxy, we need to send some 170 // zero to one. In the plugin side of the proxy, we need to send some
171 // messages to the host. In the host side, this should never be called since 171 // messages to the host. In the host side, this should never be called since
172 // there are no proxy objects. 172 // there are no proxy objects.
173 virtual void TrackedObjectGettingOneRef(VarMap::const_iterator iter); 173 virtual void TrackedObjectGettingOneRef(VarMap::const_iterator iter);
174 174
175 // Called when ReleaseVar decreases a object's refcount from one to zero. It 175 // Called when ReleaseVar decreases a object's refcount from one to zero. It
176 // may still be "tracked" (has a "track_with_no_reference_count") value. In 176 // may still be "tracked" (has a "track_with_no_reference_count") value. In
177 // the plugin side of the proxy, we need to tell the host that we no longer 177 // the plugin side of the proxy, we need to tell the host that we no longer
178 // have a reference. In the host side, this should never be called since 178 // have a reference. In the host side, this should never be called since
(...skipping 27 matching lines...) Expand all
206 // other threads (especially the IO thread). On the plugin side, the tracker 206 // other threads (especially the IO thread). On the plugin side, the tracker
207 // is protected by the proxy lock and is thread-safe, so this will be NULL. 207 // is protected by the proxy lock and is thread-safe, so this will be NULL.
208 scoped_ptr<base::ThreadChecker> thread_checker_; 208 scoped_ptr<base::ThreadChecker> thread_checker_;
209 209
210 DISALLOW_COPY_AND_ASSIGN(VarTracker); 210 DISALLOW_COPY_AND_ASSIGN(VarTracker);
211 }; 211 };
212 212
213 } // namespace ppapi 213 } // namespace ppapi
214 214
215 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_ 215 #endif // PPAPI_SHARED_IMPL_VAR_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698