Chromium Embedded Framework (CEF)  145.0.1+g472e75d+chromium-145.0.7632.5
cef_ref_counted.h File Reference
#include <stddef.h>
#include <concepts>
#include <limits>
#include <utility>
#include "include/base/cef_atomic_ref_count.h"
#include "include/base/cef_build.h"
#include "include/base/cef_compiler_specific.h"
#include "include/base/cef_logging.h"
#include "include/base/cef_scoped_refptr.h"
#include "include/base/cef_thread_checker.h"

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()    using RefCountPreferenceTag = ::base::cef_subtle::StartRefCountFromOneTag
 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)
 

Variables

template<typename T >
concept base::IsRefCountedType
 

Macro Definition Documentation

◆ REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE

#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE ( )     using RefCountPreferenceTag = ::base::cef_subtle::StartRefCountFromOneTag

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 blink::RefCounted, whose count starts from one. And start-from-one ref count is a step to merge blink::RefCounted into base::RefCounted.