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

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

Issue 681963002: Remove heap/*.cpp files (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/core/loader/ImageLoader.cpp ('k') | sky/engine/platform/heap/BUILD.gn » ('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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>& host, const char* key) 137 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>& host, const char* key)
138 { 138 {
139 return host.requireSupplement(key); 139 return host.requireSupplement(key);
140 } 140 }
141 141
142 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>* host, const char* key) 142 static SupplementBase<T, isGarbageCollected>* from(SupplementableBase<T, isG arbageCollected>* host, const char* key)
143 { 143 {
144 return host ? host->requireSupplement(key) : 0; 144 return host ? host->requireSupplement(key) : 0;
145 } 145 }
146
147 // FIXME: Oilpan: Remove this callback once PersistentHeapSupplementable is removed again.
148 virtual void persistentHostHasBeenDestroyed() { }
149 }; 146 };
150 147
151 // Helper class for implementing Supplementable, HeapSupplementable, and 148 // Helper class for implementing Supplementable, HeapSupplementable, and
152 // PersistentHeapSupplementable. 149 // PersistentHeapSupplementable.
153 template<typename T, bool isGarbageCollected = false> 150 template<typename T, bool isGarbageCollected = false>
154 class SupplementableBase { 151 class SupplementableBase {
155 public: 152 public:
156 void provideSupplement(const char* key, typename SupplementableTraits<T, isG arbageCollected>::SupplementArgumentType supplement) 153 void provideSupplement(const char* key, typename SupplementableTraits<T, isG arbageCollected>::SupplementArgumentType supplement)
157 { 154 {
158 ASSERT(m_threadId == currentThread()); 155 ASSERT(m_threadId == currentThread());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 template<typename T> 205 template<typename T>
209 class GC_PLUGIN_IGNORE("http://crbug.com/395036") HeapSupplementable : public Su pplementableBase<T, true>, public GarbageCollectedMixin { 206 class GC_PLUGIN_IGNORE("http://crbug.com/395036") HeapSupplementable : public Su pplementableBase<T, true>, public GarbageCollectedMixin {
210 public: 207 public:
211 virtual void trace(Visitor* visitor) override 208 virtual void trace(Visitor* visitor) override
212 { 209 {
213 visitor->trace(this->m_supplements); 210 visitor->trace(this->m_supplements);
214 SupplementableBase<T, true>::trace(visitor); 211 SupplementableBase<T, true>::trace(visitor);
215 } 212 }
216 }; 213 };
217 214
218 // This class is used to make an off-heap class supplementable with supplements
219 // that are on-heap, aka. HeapSupplements.
220 template<typename T>
221 class GC_PLUGIN_IGNORE("http://crbug.com/395036") PersistentHeapSupplementable : public SupplementableBase<T, true> {
222 public:
223 PersistentHeapSupplementable() : m_root(this) { }
224 virtual ~PersistentHeapSupplementable()
225 {
226 typedef typename SupplementableTraits<T, true>::SupplementMap::iterator SupplementIterator;
227 for (SupplementIterator it = this->m_supplements.begin(); it != this->m_ supplements.end(); ++it)
228 it->value->persistentHostHasBeenDestroyed();
229 }
230
231 virtual void trace(Visitor* visitor)
232 {
233 visitor->trace(this->m_supplements);
234 SupplementableBase<T, true>::trace(visitor);
235 }
236
237 private:
238 class TraceDelegate : PersistentBase<ThreadLocalPersistents<AnyThread>, Trac eDelegate> {
239 public:
240 TraceDelegate(PersistentHeapSupplementable* owner) : m_owner(owner) { }
241 void trace(Visitor* visitor) { m_owner->trace(visitor); }
242 private:
243 PersistentHeapSupplementable* m_owner;
244 };
245
246 TraceDelegate m_root;
247 };
248
249 template<typename T> 215 template<typename T>
250 class Supplement : public SupplementBase<T, false> { }; 216 class Supplement : public SupplementBase<T, false> { };
251 217
252 // This class is used to make an off-heap class supplementable with off-heap 218 // This class is used to make an off-heap class supplementable with off-heap
253 // supplements (Supplement). 219 // supplements (Supplement).
254 template<typename T> 220 template<typename T>
255 class GC_PLUGIN_IGNORE("http://crbug.com/395036") Supplementable : public Supple mentableBase<T, false> { 221 class GC_PLUGIN_IGNORE("http://crbug.com/395036") Supplementable : public Supple mentableBase<T, false> {
256 public: 222 public:
257 virtual void trace(Visitor* visitor) 223 virtual void trace(Visitor* visitor)
258 { 224 {
259 } 225 }
260 }; 226 };
261 227
262 template<typename T> 228 template<typename T>
263 struct ThreadingTrait<SupplementBase<T, true> > { 229 struct ThreadingTrait<SupplementBase<T, true> > {
264 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 230 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
265 }; 231 };
266 232
267 template<typename T> 233 template<typename T>
268 struct ThreadingTrait<SupplementableBase<T, true> > { 234 struct ThreadingTrait<SupplementableBase<T, true> > {
269 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 235 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
270 }; 236 };
271 237
272 } // namespace blink 238 } // namespace blink
273 239
274 #endif // Supplementable_h 240 #endif // Supplementable_h
OLDNEW
« no previous file with comments | « sky/engine/core/loader/ImageLoader.cpp ('k') | sky/engine/platform/heap/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698