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

Unified Diff: Source/heap/Handle.h

Issue 23243003: [oilpan] Wrap NodeVector into CollectionRoot for ensure that contained nodes stay alive. (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Fix infinite looping Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLMediaElement.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/heap/Handle.h
diff --git a/Source/heap/Handle.h b/Source/heap/Handle.h
index d8d0f5fae4377f30cb45e0a54212a96ad4104855..602270a60cfbdd78f352a2dec0d1db07d49e0b8c 100644
--- a/Source/heap/Handle.h
+++ b/Source/heap/Handle.h
@@ -1128,10 +1128,25 @@ struct CollectionVisitingTrait<WTF::HashMap<K, V> > {
}
};
+template<typename Collection> class CollectionRoot;
+
+// Used to inject correctly typed operator[] into CollectionRoot when we are wrapping Vector.
+template<typename T> class IndexingBehavior { };
+
+template<typename T, size_t inlineCapacity, typename Allocator>
+class IndexingBehavior<CollectionRoot<Vector<T, inlineCapacity, Allocator> > > {
+ typedef CollectionRoot<Vector<T, inlineCapacity, Allocator> > CollectionRootType;
+public:
+ T& operator[] (size_t i) { return (**static_cast<CollectionRootType*>(this))[i]; }
+ const T& operator[] (size_t i) const { return (**static_cast<const CollectionRootType*>(this))[i]; }
+};
+
template<typename Collection>
-class CollectionRoot : public PersistentBase {
+class CollectionRoot : public PersistentBase, public IndexingBehavior<CollectionRoot<Collection> > {
public:
typedef Collection CollectionType;
+ typedef typename Collection::iterator iterator;
+ typedef typename Collection::const_iterator const_iterator;
CollectionRoot() { }
explicit CollectionRoot(size_t size) : m_collection(Collection(size)) { }
« no previous file with comments | « Source/core/html/HTMLMediaElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698