OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 protected: | 157 protected: |
158 #if ENABLE(INSTANCE_COUNTER) | 158 #if ENABLE(INSTANCE_COUNTER) |
159 RefCounted() { incrementInstanceCount<T>(static_cast<T*>(this)); } | 159 RefCounted() { incrementInstanceCount<T>(static_cast<T*>(this)); } |
160 | 160 |
161 ~RefCounted() { decrementInstanceCount<T>(static_cast<T*>(this)); } | 161 ~RefCounted() { decrementInstanceCount<T>(static_cast<T*>(this)); } |
162 #else | 162 #else |
163 RefCounted() {} | 163 RefCounted() {} |
164 #endif | 164 #endif |
165 }; | 165 }; |
166 | 166 |
| 167 // Allows subclasses to use the default copy constructor. |
| 168 template <typename T> |
| 169 class RefCountedCopyable : public RefCounted<T> { |
| 170 protected: |
| 171 RefCountedCopyable() = default; |
| 172 RefCountedCopyable(const RefCountedCopyable&) : RefCounted<T>() {} |
| 173 }; |
| 174 |
167 } // namespace WTF | 175 } // namespace WTF |
168 | 176 |
169 using WTF::RefCounted; | 177 using WTF::RefCounted; |
| 178 using WTF::RefCountedCopyable; |
170 | 179 |
171 #endif // RefCounted_h | 180 #endif // RefCounted_h |
OLD | NEW |