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

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

Issue 463543002: Oilpan: Ensure that classes with virtual trace methods always have vtables for their left-most base… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/LifecycleContext.h ('k') | no next file » | 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 template<bool> 112 template<bool>
113 class SupplementTracing; 113 class SupplementTracing;
114 114
115 template<> 115 template<>
116 class SupplementTracing<true> : public GarbageCollectedMixin { }; 116 class SupplementTracing<true> : public GarbageCollectedMixin { };
117 117
118 template<> 118 template<>
119 class SupplementTracing<false> { 119 class SupplementTracing<false> {
120 public: 120 public:
121 virtual ~SupplementTracing() { } 121 virtual ~SupplementTracing() { }
122 virtual void trace(Visitor*) { }
122 }; 123 };
123 124
124 template<typename T, bool isGarbageCollected = false> 125 template<typename T, bool isGarbageCollected = false>
125 class SupplementBase : public SupplementTracing<isGarbageCollected> { 126 class SupplementBase : public SupplementTracing<isGarbageCollected> {
126 public: 127 public:
127 #if ENABLE(SECURITY_ASSERT) 128 #if ENABLE(SECURITY_ASSERT)
128 virtual bool isRefCountedWrapper() const { return false; } 129 virtual bool isRefCountedWrapper() const { return false; }
129 #endif 130 #endif
130 131
131 static void provideTo(SupplementableBase<T, isGarbageCollected>& host, const char* key, typename SupplementableTraits<T, isGarbageCollected>::SupplementArgu mentType supplement) 132 static void provideTo(SupplementableBase<T, isGarbageCollected>& host, const char* key, typename SupplementableTraits<T, isGarbageCollected>::SupplementArgu mentType supplement)
132 { 133 {
133 host.provideSupplement(key, supplement); 134 host.provideSupplement(key, supplement);
134 } 135 }
135 136
136 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)
137 { 138 {
138 return host.requireSupplement(key); 139 return host.requireSupplement(key);
139 } 140 }
140 141
141 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)
142 { 143 {
143 return host ? host->requireSupplement(key) : 0; 144 return host ? host->requireSupplement(key) : 0;
144 } 145 }
145 146
146 virtual void trace(Visitor*) { }
147 virtual void willBeDestroyed() { } 147 virtual void willBeDestroyed() { }
148 148
149 // FIXME: Oilpan: Remove this callback once PersistentHeapSupplementable is removed again. 149 // FIXME: Oilpan: Remove this callback once PersistentHeapSupplementable is removed again.
150 virtual void persistentHostHasBeenDestroyed() { } 150 virtual void persistentHostHasBeenDestroyed() { }
151 }; 151 };
152 152
153 template<typename T, bool>
154 class SupplementableTracing;
155
156 template<typename T>
157 class SupplementableTracing<T, true> { };
158
159 template<typename T>
160 class SupplementableTracing<T, false> { };
161
162 // Helper class for implementing Supplementable, HeapSupplementable, and 153 // Helper class for implementing Supplementable, HeapSupplementable, and
163 // PersistentHeapSupplementable. 154 // PersistentHeapSupplementable.
164 template<typename T, bool isGarbageCollected = false> 155 template<typename T, bool isGarbageCollected = false>
165 class SupplementableBase : public SupplementableTracing<T, isGarbageCollected> { 156 class SupplementableBase {
166 public: 157 public:
167 void provideSupplement(const char* key, typename SupplementableTraits<T, isG arbageCollected>::SupplementArgumentType supplement) 158 void provideSupplement(const char* key, typename SupplementableTraits<T, isG arbageCollected>::SupplementArgumentType supplement)
168 { 159 {
169 ASSERT(m_threadId == currentThread()); 160 ASSERT(m_threadId == currentThread());
170 ASSERT(!this->m_supplements.get(key)); 161 ASSERT(!this->m_supplements.get(key));
171 this->m_supplements.set(key, supplement); 162 this->m_supplements.set(key, supplement);
172 } 163 }
173 164
174 void removeSupplement(const char* key) 165 void removeSupplement(const char* key)
175 { 166 {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 }; 280 };
290 281
291 template<typename T> 282 template<typename T>
292 struct ThreadingTrait<SupplementableBase<T, true> > { 283 struct ThreadingTrait<SupplementableBase<T, true> > {
293 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 284 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
294 }; 285 };
295 286
296 } // namespace blink 287 } // namespace blink
297 288
298 #endif // Supplementable_h 289 #endif // Supplementable_h
OLDNEW
« no previous file with comments | « Source/platform/LifecycleContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698