Chromium Code Reviews| 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 // Unlike subclasses of RefCounted where the copy constructor must be | |
| 168 // handwritten, subclasses of RefCountedCopyable can use the default | |
| 169 // compiler-generated copy constructor. | |
|
alancutter (OOO until 2018)
2017/04/03 12:07:45
This wording is a bit too fancy. For speed of read
| |
| 170 template <typename T> | |
| 171 class RefCountedCopyable : public RefCounted<T> { | |
| 172 protected: | |
| 173 RefCountedCopyable() = default; | |
| 174 RefCountedCopyable(const RefCountedCopyable&) : RefCounted<T>() {} | |
| 175 }; | |
| 176 | |
| 167 } // namespace WTF | 177 } // namespace WTF |
| 168 | 178 |
| 169 using WTF::RefCounted; | 179 using WTF::RefCounted; |
| 180 using WTF::RefCountedCopyable; | |
| 170 | 181 |
| 171 #endif // RefCounted_h | 182 #endif // RefCounted_h |
| OLD | NEW |