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

Side by Side Diff: Source/platform/Supplementable.h

Issue 323873007: Oilpan: Make LocalFrame PersistentHeapSupplementable and use transition types for its supplements. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: non-oilpan build Created 6 years, 6 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
« no previous file with comments | « Source/modules/webmidi/MIDIController.cpp ('k') | Source/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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 145
146 virtual void trace(Visitor*) { } 146 virtual void trace(Visitor*) { }
147 virtual void willBeDestroyed() { } 147 virtual void willBeDestroyed() { }
148 }; 148 };
149 149
150 template<typename T, bool> 150 template<typename T, bool>
151 class SupplementableTracing; 151 class SupplementableTracing;
152 152
153 template<typename T> 153 template<typename T>
154 class SupplementableTracing<T, true> : public GarbageCollectedMixin { }; 154 class SupplementableTracing<T, true> { };
155 155
156 template<typename T> 156 template<typename T>
157 class SupplementableTracing<T, false> { }; 157 class SupplementableTracing<T, false> { };
158 158
159 template<typename T, bool isGarbageCollected = false> 159 template<typename T, bool isGarbageCollected = false>
160 class SupplementableBase : public SupplementableTracing<T, isGarbageCollected> { 160 class SupplementableBase : public SupplementableTracing<T, isGarbageCollected> {
161 public: 161 public:
162 void provideSupplement(const char* key, typename SupplementableTraits<T, isG arbageCollected>::SupplementArgumentType supplement) 162 void provideSupplement(const char* key, typename SupplementableTraits<T, isG arbageCollected>::SupplementArgumentType supplement)
163 { 163 {
164 ASSERT(m_threadId == currentThread()); 164 ASSERT(m_threadId == currentThread());
(...skipping 23 matching lines...) Expand all
188 virtual void trace(Visitor* visitor) { visitor->trace(m_supplements); } 188 virtual void trace(Visitor* visitor) { visitor->trace(m_supplements); }
189 189
190 void willBeDestroyed() 190 void willBeDestroyed()
191 { 191 {
192 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement Map::iterator SupplementIterator; 192 typedef typename SupplementableTraits<T, isGarbageCollected>::Supplement Map::iterator SupplementIterator;
193 for (SupplementIterator it = m_supplements.begin(); it != m_supplements. end(); ++it) 193 for (SupplementIterator it = m_supplements.begin(); it != m_supplements. end(); ++it)
194 it->value->willBeDestroyed(); 194 it->value->willBeDestroyed();
195 } 195 }
196 196
197 private: 197 private:
198 // FIXME: Oilpan: Remove this ignore once PersistentHeapSupplementable is re moved again.
199 GC_PLUGIN_IGNORE("")
198 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple ments; 200 typename SupplementableTraits<T, isGarbageCollected>::SupplementMap m_supple ments;
199 201
200 #if !ASSERT_DISABLED 202 #if !ASSERT_DISABLED
201 protected: 203 protected:
202 SupplementableBase() : m_threadId(currentThread()) { } 204 SupplementableBase() : m_threadId(currentThread()) { }
203 205
204 private: 206 private:
205 ThreadIdentifier m_threadId; 207 ThreadIdentifier m_threadId;
206 #endif 208 #endif
207 }; 209 };
208 210
209 template<typename T> 211 template<typename T>
210 class HeapSupplement : public SupplementBase<T, true> { }; 212 class HeapSupplement : public SupplementBase<T, true> { };
211 213
214 // FIXME: Oilpan: Move GarbageCollectedMixin to SupplementableBase<T, true> once PersistentHeapSupplementable is removed again.
212 template<typename T> 215 template<typename T>
213 class HeapSupplementable : public SupplementableBase<T, true> { }; 216 class HeapSupplementable : public SupplementableBase<T, true>, public GarbageCol lectedMixin { };
217
218 template<typename T>
219 class PersistentHeapSupplementable : public SupplementableBase<T, true> {
220 public:
221 PersistentHeapSupplementable() : m_root(this) { }
222 private:
223 class TraceDelegate : PersistentBase<ThreadLocalPersistents<AnyThread>, Trac eDelegate> {
224 public:
225 TraceDelegate(PersistentHeapSupplementable* owner) : m_owner(owner) { }
226 void trace(Visitor* visitor) { m_owner->trace(visitor); }
227 private:
228 PersistentHeapSupplementable* m_owner;
229 };
230
231 TraceDelegate m_root;
232 };
214 233
215 template<typename T> 234 template<typename T>
216 class Supplement : public SupplementBase<T, false> { }; 235 class Supplement : public SupplementBase<T, false> { };
217 236
218 template<typename T> 237 template<typename T>
219 class Supplementable : public SupplementableBase<T, false> { }; 238 class Supplementable : public SupplementableBase<T, false> { };
220 239
221 template<typename T> 240 template<typename T>
222 struct ThreadingTrait<WebCore::SupplementBase<T, true> > { 241 struct ThreadingTrait<WebCore::SupplementBase<T, true> > {
223 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 242 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
224 }; 243 };
225 244
226 template<typename T> 245 template<typename T>
227 struct ThreadingTrait<WebCore::SupplementableBase<T, true> > { 246 struct ThreadingTrait<WebCore::SupplementableBase<T, true> > {
228 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 247 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
229 }; 248 };
230 249
231 } // namespace WebCore 250 } // namespace WebCore
232 251
233 #endif // Supplementable_h 252 #endif // Supplementable_h
OLDNEW
« no previous file with comments | « Source/modules/webmidi/MIDIController.cpp ('k') | Source/platform/heap/Handle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698