OLD | NEW |
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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> { | 101 struct SupplementableTraits<T, true> { |
102 typedef RawPtr<SupplementBase<T, true> > SupplementArgumentType; | 102 typedef RawPtr<SupplementBase<T, true>> SupplementArgumentType; |
103 }; | 103 }; |
104 | 104 |
105 template<typename T> | 105 template<typename T> |
106 struct SupplementableTraits<T, false> { | 106 struct SupplementableTraits<T, false> { |
107 typedef PassOwnPtr<SupplementBase<T, false> > SupplementArgumentType; | 107 typedef PassOwnPtr<SupplementBase<T, false>> SupplementArgumentType; |
108 }; | 108 }; |
109 | 109 |
110 template<bool> | 110 template<bool> |
111 class SupplementTracing; | 111 class SupplementTracing; |
112 | 112 |
113 template<> | 113 template<> |
114 class SupplementTracing<true> : public GarbageCollectedMixin { }; | 114 class SupplementTracing<true> : public GarbageCollectedMixin { }; |
115 | 115 |
116 template<> | 116 template<> |
117 class SupplementTracing<false> { | 117 class SupplementTracing<false> { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 154 |
155 template<typename T> | 155 template<typename T> |
156 class SupplementableTracing<T, true> : public GarbageCollectedMixin { | 156 class SupplementableTracing<T, true> : public GarbageCollectedMixin { |
157 public: | 157 public: |
158 virtual void trace(Visitor* visitor) | 158 virtual void trace(Visitor* visitor) |
159 { | 159 { |
160 visitor->trace(m_supplements); | 160 visitor->trace(m_supplements); |
161 } | 161 } |
162 | 162 |
163 protected: | 163 protected: |
164 typedef HeapHashMap<const char*, Member<SupplementBase<T, true> >, PtrHash<c
onst char*> > SupplementMap; | 164 typedef HeapHashMap<const char*, Member<SupplementBase<T, true>>, PtrHash<co
nst char*>> SupplementMap; |
165 SupplementMap m_supplements; | 165 SupplementMap m_supplements; |
166 }; | 166 }; |
167 | 167 |
168 template<typename T> | 168 template<typename T> |
169 class SupplementableTracing<T, false> { | 169 class SupplementableTracing<T, false> { |
170 protected: | 170 protected: |
171 typedef HashMap<const char*, OwnPtr<SupplementBase<T, false> >, PtrHash<cons
t char*> > SupplementMap; | 171 typedef HashMap<const char*, OwnPtr<SupplementBase<T, false>>, PtrHash<const
char*>> SupplementMap; |
172 SupplementMap m_supplements; | 172 SupplementMap m_supplements; |
173 }; | 173 }; |
174 | 174 |
175 // Helper class for implementing Supplementable and HeapSupplementable. | 175 // Helper class for implementing Supplementable and HeapSupplementable. |
176 template<typename T, bool isGarbageCollected = false> | 176 template<typename T, bool isGarbageCollected = false> |
177 class SupplementableBase : public SupplementableTracing<T, isGarbageCollected> { | 177 class SupplementableBase : public SupplementableTracing<T, isGarbageCollected> { |
178 public: | 178 public: |
179 void provideSupplement(const char* key, typename SupplementableTraits<T, isG
arbageCollected>::SupplementArgumentType supplement) | 179 void provideSupplement(const char* key, typename SupplementableTraits<T, isG
arbageCollected>::SupplementArgumentType supplement) |
180 { | 180 { |
181 ASSERT(m_threadId == currentThread()); | 181 ASSERT(m_threadId == currentThread()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 template<typename T> | 217 template<typename T> |
218 class HeapSupplementable : public SupplementableBase<T, true> { }; | 218 class HeapSupplementable : public SupplementableBase<T, true> { }; |
219 | 219 |
220 template<typename T> | 220 template<typename T> |
221 class Supplement : public SupplementBase<T, false> { }; | 221 class Supplement : public SupplementBase<T, false> { }; |
222 | 222 |
223 template<typename T> | 223 template<typename T> |
224 class Supplementable : public SupplementableBase<T, false> { }; | 224 class Supplementable : public SupplementableBase<T, false> { }; |
225 | 225 |
226 template<typename T> | 226 template<typename T> |
227 struct ThreadingTrait<SupplementBase<T, true> > { | 227 struct ThreadingTrait<SupplementBase<T, true>> { |
228 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; | 228 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; |
229 }; | 229 }; |
230 | 230 |
231 template<typename T> | 231 template<typename T> |
232 struct ThreadingTrait<SupplementableBase<T, true> > { | 232 struct ThreadingTrait<SupplementableBase<T, true>> { |
233 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; | 233 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; |
234 }; | 234 }; |
235 | 235 |
236 } // namespace blink | 236 } // namespace blink |
237 | 237 |
238 #endif // Supplementable_h | 238 #endif // Supplementable_h |
OLD | NEW |