Chromium Embedded Framework (CEF)  130.1.2+g48f3ef6+chromium-130.0.6723.44
cef_ref_counted.h File Reference

Classes

struct  base::DefaultRefCountedTraits< T >
 Default traits for RefCounted<T>. More...
 
class  base::RefCounted< T, Traits >
 A base class for reference counted classes. More...
 
struct  base::DefaultRefCountedThreadSafeTraits< T >
 Default traits for RefCountedThreadSafe<T>. More...
 
class  base::RefCountedThreadSafe< T, Traits >
 A thread-safe variant of RefCounted<T> More...
 
class  base::RefCountedData< T >
 A thread-safe wrapper for some piece of data so we can place other things in scoped_refptrs<>. More...
 

Namespaces

 base
 

Macros

#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE()
 The reference count starts from zero by default, and we intended to migrate to start-from-one ref count. More...
 

Typedefs

using base::ScopedAllowCrossThreadRefCountAccess = cef_subtle::ScopedAllowCrossThreadRefCountAccess
 

Functions

template<typename T >
bool base::operator== (const RefCountedData< T > &lhs, const RefCountedData< T > &rhs)
 
template<typename T >
bool base::operator!= (const RefCountedData< T > &lhs, const RefCountedData< T > &rhs)
 

Macro Definition Documentation

◆ REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE

#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE ( )
Value:
static constexpr ::base::cef_subtle::StartRefCountFromOneTag \
kRefCountPreference = ::base::cef_subtle::kStartRefCountFromOneTag

The reference count starts from zero by default, and we intended to migrate to start-from-one ref count.

Put REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() to the ref counted class to opt-in.

If an object has start-from-one ref count, the first scoped_refptr need to be created by base::AdoptRef() or base::MakeRefCounted(). We can use base::MakeRefCounted() to create create both type of ref counted object.

The motivations to use start-from-one ref count are:

  • Start-from-one ref count doesn't need the ref count increment for the first reference.
  • It can detect an invalid object acquisition for a being-deleted object that has zero ref count. That tends to happen on custom deleter that delays the deletion. TODO(tzik): Implement invalid acquisition detection.
  • Behavior parity to Blink's WTF::RefCounted, whose count starts from one. And start-from-one ref count is a step to merge WTF::RefCounted into base::RefCounted.