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

Side by Side Diff: sky/engine/platform/Supplementable.h

Issue 683703003: Remove various Heap* types. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sky/engine/platform/RefCountedSupplement.h ('k') | sky/engine/platform/heap/Handle.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2012 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 template<typename T, bool isGarbageCollected> 91 template<typename T, bool isGarbageCollected>
92 class SupplementBase; 92 class SupplementBase;
93 93
94 template<typename T, bool isGarbageCollected> 94 template<typename T, bool isGarbageCollected>
95 class SupplementableBase; 95 class SupplementableBase;
96 96
97 template<typename T, bool isGarbageCollected> 97 template<typename T, bool isGarbageCollected>
98 struct SupplementableTraits; 98 struct SupplementableTraits;
99 99
100 template<typename T> 100 template<typename T>
101 struct SupplementableTraits<T, true> {
102 typedef RawPtr<SupplementBase<T, true> > SupplementArgumentType;
103 typedef HeapHashMap<const char*, Member<SupplementBase<T, true> >, PtrHash<c onst char*> > SupplementMap;
104 };
105
106 template<typename T>
107 struct SupplementableTraits<T, false> { 101 struct SupplementableTraits<T, false> {
108 typedef PassOwnPtr<SupplementBase<T, false> > SupplementArgumentType; 102 typedef PassOwnPtr<SupplementBase<T, false> > SupplementArgumentType;
109 typedef HashMap<const char*, OwnPtr<SupplementBase<T, false> >, PtrHash<cons t char*> > SupplementMap; 103 typedef HashMap<const char*, OwnPtr<SupplementBase<T, false> >, PtrHash<cons t char*> > SupplementMap;
110 }; 104 };
111 105
112 template<bool> 106 template<bool>
113 class SupplementTracing; 107 class SupplementTracing;
114 108
115 template<> 109 template<>
116 class SupplementTracing<true> : public GarbageCollectedMixin { };
117
118 template<>
119 class SupplementTracing<false> { 110 class SupplementTracing<false> {
120 public: 111 public:
121 virtual ~SupplementTracing() { } 112 virtual ~SupplementTracing() { }
122 virtual void trace(Visitor*) { }
123 }; 113 };
124 114
125 template<typename T, bool isGarbageCollected = false> 115 template<typename T, bool isGarbageCollected = false>
126 class SupplementBase : public SupplementTracing<isGarbageCollected> { 116 class SupplementBase : public SupplementTracing<isGarbageCollected> {
127 public: 117 public:
128 #if ENABLE(SECURITY_ASSERT) 118 #if ENABLE(SECURITY_ASSERT)
129 virtual bool isRefCountedWrapper() const { return false; } 119 virtual bool isRefCountedWrapper() const { return false; }
130 #endif 120 #endif
131 121
132 static void provideTo(SupplementableBase<T, isGarbageCollected>& host, const char* key, typename SupplementableTraits<T, isGarbageCollected>::SupplementArgu mentType supplement) 122 static void provideTo(SupplementableBase<T, isGarbageCollected>& host, const char* key, typename SupplementableTraits<T, isGarbageCollected>::SupplementArgu mentType supplement)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 179
190 #if ENABLE(ASSERT) 180 #if ENABLE(ASSERT)
191 protected: 181 protected:
192 SupplementableBase() : m_threadId(currentThread()) { } 182 SupplementableBase() : m_threadId(currentThread()) { }
193 183
194 private: 184 private:
195 ThreadIdentifier m_threadId; 185 ThreadIdentifier m_threadId;
196 #endif 186 #endif
197 }; 187 };
198 188
199 // This class is used to make an on-heap class supplementable. Its supplements
200 // must be HeapSupplement.
201 template<typename T>
202 class HeapSupplement : public SupplementBase<T, true> { };
203
204 // FIXME: Oilpan: Move GarbageCollectedMixin to SupplementableBase<T, true> once PersistentHeapSupplementable is removed again.
205 template<typename T>
206 class GC_PLUGIN_IGNORE("http://crbug.com/395036") HeapSupplementable : public Su pplementableBase<T, true>, public GarbageCollectedMixin {
207 public:
208 virtual void trace(Visitor* visitor) override
209 {
210 visitor->trace(this->m_supplements);
211 SupplementableBase<T, true>::trace(visitor);
212 }
213 };
214 189
215 template<typename T> 190 template<typename T>
216 class Supplement : public SupplementBase<T, false> { }; 191 class Supplement : public SupplementBase<T, false> { };
217 192
218 // This class is used to make an off-heap class supplementable with off-heap 193 // This class is used to make an off-heap class supplementable with off-heap
219 // supplements (Supplement). 194 // supplements (Supplement).
220 template<typename T> 195 template<typename T>
221 class GC_PLUGIN_IGNORE("http://crbug.com/395036") Supplementable : public Supple mentableBase<T, false> { 196 class GC_PLUGIN_IGNORE("http://crbug.com/395036") Supplementable : public Supple mentableBase<T, false> {
222 public:
223 virtual void trace(Visitor* visitor)
224 {
225 }
226 };
227
228 template<typename T>
229 struct ThreadingTrait<SupplementBase<T, true> > {
230 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
231 };
232
233 template<typename T>
234 struct ThreadingTrait<SupplementableBase<T, true> > {
235 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
236 }; 197 };
237 198
238 } // namespace blink 199 } // namespace blink
239 200
240 #endif // Supplementable_h 201 #endif // Supplementable_h
OLDNEW
« no previous file with comments | « sky/engine/platform/RefCountedSupplement.h ('k') | sky/engine/platform/heap/Handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698