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

Unified Diff: Source/wtf/PassRefPtr.h

Issue 25589003: Bootstrap to extend WTF:RefPtr's run-time adoption checking to skia's SkRefCnt (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PassRefPtr.h
diff --git a/Source/wtf/PassRefPtr.h b/Source/wtf/PassRefPtr.h
index 84f228f8b659612557801c399b616053d2d312a0..4e9b79fa60113d57ea62b4861b86e32ac1294612 100644
--- a/Source/wtf/PassRefPtr.h
+++ b/Source/wtf/PassRefPtr.h
@@ -33,10 +33,21 @@ namespace WTF {
inline void adopted(const void*) { }
+ // adoptionRequired() is not overloaded for WTF::RefCounted, which has a
+ // built-in assumption that adoption is required. adoptionRequired() is
+ // for bootstrapping alternate reference count classes that are compatible
+ // with ReftPtr/PassRefPtr but cannot have adoption checks enabled
+ // by default, such as skia's SkRefCnt. The purpose of adoptionRequired()
+ // is to enable adoption checks only once it is known that the object will
+ // be used with RefPtr/PassRefPtr.
+ inline void adoptionRequired(const void*) { }
abarth-chromium 2013/10/04 20:37:58 adoptionRequired -> requireAdoption ? setAdoption
+
template<typename T> ALWAYS_INLINE void refIfNotNull(T* ptr)
{
- if (LIKELY(ptr != 0))
+ if (LIKELY(ptr != 0)) {
+ adoptionRequired(ptr);
ptr->ref();
+ }
}
template<typename T> ALWAYS_INLINE void derefIfNotNull(T* ptr)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698