Chromium Embedded Framework (CEF)  109.0.1+gcd5e37a+chromium-109.0.5414.8
base Namespace Reference

Namespaces

 cef_internal
 
 PlatformThread
 A namespace for low-level thread functions.
 

Classes

class  AtomicFlag
 A flag that can safely be set from one thread and read from other threads. More...
 
class  AtomicRefCount
 
class  AutoReset
 
class  OnceCallback< R(Args...)>
 
class  RepeatingCallback< R(Args...)>
 
class  OnceCallback
 
class  RepeatingCallback
 
class  ScopedClosureRunner
 ScopedClosureRunner is akin to std::unique_ptr<> for Closures. More...
 
class  NullCallback
 Creates a null callback. More...
 
class  DoNothing
 Creates a callback that does nothing when called. More...
 
class  OnceCallbackList
 
class  RepeatingCallbackList
 
class  CallbackListSubscription
 
class  PlatformThreadRef
 Used for thread checking and debugging. More...
 
class  RefCounted
 A base class for reference counted classes. More...
 
struct  DefaultRefCountedTraits
 Default traits for RefCounted<T>. More...
 
class  RefCountedThreadSafe
 A thread-safe variant of RefCounted<T> More...
 
struct  DefaultRefCountedThreadSafeTraits
 Default traits for RefCountedThreadSafe<T>. More...
 
class  RefCountedData
 A thread-safe wrapper for some piece of data so we can place other things in scoped_refptrs<>. More...
 
struct  ScopedTypeRefTraits
 
class  ScopedTypeRef
 ScopedTypeRef<> is patterned after std::unique_ptr<>, but maintains ownership of a reference to any type that is maintained by Retain and Release methods. More...
 
struct  is_non_const_reference
 
struct  is_non_const_reference< T & >
 
struct  is_non_const_reference< const T & >
 
struct  in_place_t
 
struct  in_place_type_t
 
struct  is_in_place_type_t
 
struct  is_in_place_type_t< in_place_type_t< Ts... > >
 
struct  conjunction
 
struct  conjunction< B1 >
 
struct  conjunction< B1, Bn... >
 
struct  disjunction
 
struct  disjunction< B1 >
 
struct  disjunction< B1, Bn... >
 
struct  negation
 
struct  is_invocable_r
 
struct  is_invocable
 
struct  is_scoped_enum
 
struct  remove_cvref
 
struct  projected
 
class  ThreadChecker
 ThreadChecker is a helper class used to help verify that some methods of a class are called from the same thread. More...
 
class  SupportsWeakPtr
 A class may extend from SupportsWeakPtr to let others take weak pointers to it. More...
 
class  WeakPtr
 The WeakPtr class holds a weak reference to |T*|. More...
 
class  WeakPtrFactory
 A class may be composed of a WeakPtrFactory and thereby control how it exposes weak pointers to itself. More...
 

Typedefs

using OnceClosure = OnceCallback< void()>
 Syntactic sugar to make OnceClosure<void()> and RepeatingClosure<void()> easier to declare since they will be used in a lot of APIs with delayed execution. More...
 
using RepeatingClosure = RepeatingCallback< void()>
 
template<typename T >
using IsBaseCallback = internal::IsBaseCallbackImpl< std::decay_t< T > >
 IsBaseCallback<T>::value is true when T is any of the Closure or Callback family of types. More...
 
template<typename T >
using IsOnceCallback = internal::IsOnceCallbackImpl< std::decay_t< T > >
 IsOnceCallback<T>::value is true when T is a OnceClosure or OnceCallback type. More...
 
template<template< typename > class CallbackType>
using EnableIfIsBaseCallback = std::enable_if_t< IsBaseCallback< CallbackType< void()> >::value >
 SFINAE friendly enabler allowing to overload methods for both Repeating and OnceCallbacks. More...
 
using OnceClosureList = OnceCallbackList< void()>
 Syntactic sugar to parallel that used for Callbacks. More...
 
using RepeatingClosureList = RepeatingCallbackList< void()>
 
template<typename Signature >
using CancelableOnceCallback = internal::CancelableCallbackImpl< OnceCallback< Signature > >
 Consider using base::WeakPtr directly instead of base::CancelableCallback for the task cancellation. More...
 
using CancelableOnceClosure = CancelableOnceCallback< void()>
 
template<typename Signature >
using CancelableRepeatingCallback = internal::CancelableCallbackImpl< RepeatingCallback< Signature > >
 
using CancelableRepeatingClosure = CancelableRepeatingCallback< void()>
 
typedef cef_platform_thread_id_t PlatformThreadId
 Used for logging. More...
 
using ScopedAllowCrossThreadRefCountAccess = cef_subtle::ScopedAllowCrossThreadRefCountAccess
 
template<typename... Ts>
using void_t = typename ::base::internal::make_void< Ts... >::type
 
template<class T >
using is_trivially_copyable = std::is_trivially_copyable< T >
 
template<typename T >
using is_trivially_copy_constructible = std::is_trivially_copy_constructible< T >
 
template<bool B>
using bool_constant = std::integral_constant< bool, B >
 
template<typename Functor , typename... Args>
using invoke_result = std::result_of< Functor &&(Args &&...)>
 
template<typename Functor , typename... Args>
using invoke_result_t = typename invoke_result< Functor, Args... >::type
 
template<typename T >
using remove_cvref_t = typename remove_cvref< T >::type
 
template<typename Iter >
using iter_value_t = typename std::iterator_traits< remove_cvref_t< Iter > >::value_type
 
template<typename Iter >
using iter_reference_t = decltype(*std::declval< Iter & >())
 
template<typename Func , typename... Iters>
using indirect_result_t = invoke_result_t< Func, iter_reference_t< Iters >... >
 

Functions

template<typename Functor , typename... Args>
OnceCallback< internal::MakeUnboundRunType< Functor, Args... > > BindOnce (Functor &&functor, Args &&... args)
 Bind as OnceCallback. More...
 
template<typename Functor , typename... Args>
RepeatingCallback< internal::MakeUnboundRunType< Functor, Args... > > BindRepeating (Functor &&functor, Args &&... args)
 Bind as RepeatingCallback. More...
 
template<typename Signature >
OnceCallback< Signature > BindOnce (OnceCallback< Signature > callback)
 Special cases for binding to a base::Callback without extra bound arguments. More...
 
template<typename Signature >
OnceCallback< Signature > BindOnce (RepeatingCallback< Signature > callback)
 
template<typename Signature >
RepeatingCallback< Signature > BindRepeating (RepeatingCallback< Signature > callback)
 
template<typename T >
internal::UnretainedWrapper< T > Unretained (T *o)
 Unretained() allows binding a non-refcounted class, and to disable refcounting on arguments that are refcounted objects. More...
 
template<typename T >
internal::RetainedRefWrapper< T > RetainedRef (T *o)
 RetainedRef() accepts a ref counted object and retains a reference to it. More...
 
template<typename T >
internal::RetainedRefWrapper< T > RetainedRef (scoped_refptr< T > o)
 
template<typename T >
internal::OwnedWrapper< T > Owned (T *o)
 Owned() transfers ownership of an object to the callback resulting from bind; the object will be deleted when the callback is deleted. More...
 
template<typename T , typename Deleter >
internal::OwnedWrapper< T, Deleter > Owned (std::unique_ptr< T, Deleter > &&ptr)
 
template<typename T >
internal::OwnedRefWrapper< std::decay_t< T > > OwnedRef (T &&t)
 OwnedRef() stores an object in the callback resulting from bind and passes a reference to the object to the bound function. More...
 
template<typename T , std::enable_if_t<!std::is_lvalue_reference< T >::value > * = nullptr>
internal::PassedWrapper< T > Passed (T &&scoper)
 Passed() is for transferring movable-but-not-copyable types (eg. More...
 
template<typename T >
internal::PassedWrapper< T > Passed (T *scoper)
 
template<typename T >
internal::IgnoreResultHelper< T > IgnoreResult (T data)
 IgnoreResult() is used to adapt a function or callback with a return type to one with a void return. More...
 
template<typename... Args>
RepeatingCallback< void(Args...)> AdaptCallbackForRepeating (OnceCallback< void(Args...)> callback)
 Wraps the given OnceCallback into a RepeatingCallback that relays its invocation to the original OnceCallback on the first invocation. More...
 
template<typename... Args>
std::pair< OnceCallback< void(Args...)>, OnceCallback< void(Args...)> > SplitOnceCallback (OnceCallback< void(Args...)> callback)
 Wraps the given OnceCallback and returns two OnceCallbacks with an identical signature. More...
 
template<typename T >
void DeletePointer (T *obj)
 Useful for creating a Closure that will delete a pointer when invoked. More...
 
template<typename T >
std::unique_ptr< T > WrapUnique (T *ptr)
 Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>. More...
 
template<typename T >
bool operator== (const RefCountedData< T > &lhs, const RefCountedData< T > &rhs)
 
template<typename T >
bool operator!= (const RefCountedData< T > &lhs, const RefCountedData< T > &rhs)
 
template<typename T >
scoped_refptr< T > AdoptRef (T *t)
 
template<typename T , typename... Args>
scoped_refptr< T > MakeRefCounted (Args &&... args)
 
template<typename T >
scoped_refptr< T > WrapRefCounted (T *t)
 
template<typename ObjT , typename Method , typename Tuple , size_t... Ns>
void DispatchToMethodImpl (const ObjT &obj, Method method, Tuple &&args, std::index_sequence< Ns... >)
 
template<typename ObjT , typename Method , typename Tuple >
void DispatchToMethod (const ObjT &obj, Method method, Tuple &&args)
 
template<typename Function , typename Tuple , size_t... Ns>
void DispatchToFunctionImpl (Function function, Tuple &&args, std::index_sequence< Ns... >)
 
template<typename Function , typename Tuple >
void DispatchToFunction (Function function, Tuple &&args)
 
template<typename ObjT , typename Method , typename InTuple , typename OutTuple , size_t... InNs, size_t... OutNs>
void DispatchToMethodImpl (const ObjT &obj, Method method, InTuple &&in, OutTuple *out, std::index_sequence< InNs... >, std::index_sequence< OutNs... >)
 
template<typename ObjT , typename Method , typename InTuple , typename OutTuple >
void DispatchToMethod (const ObjT &obj, Method method, InTuple &&in, OutTuple *out)
 
template<class T >
bool operator!= (const WeakPtr< T > &weak_ptr, std::nullptr_t)
 Allow callers to compare WeakPtrs against nullptr to test validity. More...
 
template<class T >
bool operator!= (std::nullptr_t, const WeakPtr< T > &weak_ptr)
 
template<class T >
bool operator== (const WeakPtr< T > &weak_ptr, std::nullptr_t)
 
template<class T >
bool operator== (std::nullptr_t, const WeakPtr< T > &weak_ptr)
 
template<typename Derived >
WeakPtr< Derived > AsWeakPtr (Derived *t)
 Helper function that uses type deduction to safely return a WeakPtr<Derived> when Derived doesn't directly extend SupportsWeakPtr<Derived>, instead it extends a Base that extends SupportsWeakPtr<Base>. More...
 

Variables

constexpr in_place_t in_place = {}
 

Typedef Documentation

◆ bool_constant

template<bool B>
using base::bool_constant = typedef std::integral_constant<bool, B>

◆ CancelableOnceCallback

template<typename Signature >
using base::CancelableOnceCallback = typedef internal::CancelableCallbackImpl<OnceCallback<Signature> >

Consider using base::WeakPtr directly instead of base::CancelableCallback for the task cancellation.

◆ CancelableOnceClosure

◆ CancelableRepeatingCallback

template<typename Signature >
using base::CancelableRepeatingCallback = typedef internal::CancelableCallbackImpl<RepeatingCallback<Signature> >

◆ CancelableRepeatingClosure

◆ EnableIfIsBaseCallback

template<template< typename > class CallbackType>
using base::EnableIfIsBaseCallback = typedef std::enable_if_t<IsBaseCallback<CallbackType<void()> >::value>

SFINAE friendly enabler allowing to overload methods for both Repeating and OnceCallbacks.

Usage:

  template <template <typename> class CallbackType,
            ... other template args ...,
            typename = EnableIfIsBaseCallback<CallbackType>>
  void DoStuff(CallbackType<...> cb, ...);

◆ indirect_result_t

template<typename Func , typename... Iters>
using base::indirect_result_t = typedef invoke_result_t<Func, iter_reference_t<Iters>...>

◆ invoke_result

template<typename Functor , typename... Args>
using base::invoke_result = typedef std::result_of<Functor && (Args && ...)>

◆ invoke_result_t

template<typename Functor , typename... Args>
using base::invoke_result_t = typedef typename invoke_result<Functor, Args...>::type

◆ is_trivially_copy_constructible

template<typename T >
using base::is_trivially_copy_constructible = typedef std::is_trivially_copy_constructible<T>

◆ is_trivially_copyable

template<class T >
using base::is_trivially_copyable = typedef std::is_trivially_copyable<T>

◆ IsBaseCallback

template<typename T >
using base::IsBaseCallback = typedef internal::IsBaseCallbackImpl<std::decay_t<T> >

IsBaseCallback<T>::value is true when T is any of the Closure or Callback family of types.

◆ IsOnceCallback

template<typename T >
using base::IsOnceCallback = typedef internal::IsOnceCallbackImpl<std::decay_t<T> >

IsOnceCallback<T>::value is true when T is a OnceClosure or OnceCallback type.

◆ iter_reference_t

template<typename Iter >
using base::iter_reference_t = typedef decltype(*std::declval<Iter&>())

◆ iter_value_t

template<typename Iter >
using base::iter_value_t = typedef typename std::iterator_traits<remove_cvref_t<Iter> >::value_type

◆ OnceClosure

using base::OnceClosure = typedef OnceCallback<void()>

Syntactic sugar to make OnceClosure<void()> and RepeatingClosure<void()> easier to declare since they will be used in a lot of APIs with delayed execution.

◆ OnceClosureList

using base::OnceClosureList = typedef OnceCallbackList<void()>

Syntactic sugar to parallel that used for Callbacks.

◆ PlatformThreadId

typedef cef_platform_thread_id_t base::PlatformThreadId

Used for logging.

Always an integer value.

◆ remove_cvref_t

template<typename T >
using base::remove_cvref_t = typedef typename remove_cvref<T>::type

◆ RepeatingClosure

using base::RepeatingClosure = typedef RepeatingCallback<void()>

◆ RepeatingClosureList

◆ ScopedAllowCrossThreadRefCountAccess

using base::ScopedAllowCrossThreadRefCountAccess = typedef cef_subtle::ScopedAllowCrossThreadRefCountAccess

◆ void_t

template<typename... Ts>
using base::void_t = typedef typename ::base::internal::make_void<Ts...>::type

Function Documentation

◆ AdaptCallbackForRepeating()

template<typename... Args>
RepeatingCallback<void(Args...)> base::AdaptCallbackForRepeating ( OnceCallback< void(Args...)>  callback)

Wraps the given OnceCallback into a RepeatingCallback that relays its invocation to the original OnceCallback on the first invocation.

The following invocations are just ignored.

Note that this deliberately subverts the Once/Repeating paradigm of Callbacks but helps ease the migration from old-style Callbacks. Avoid if possible; use if necessary for migration.

◆ AdoptRef()

template<typename T >
scoped_refptr< T > base::AdoptRef ( T *  t)

◆ AsWeakPtr()

template<typename Derived >
WeakPtr<Derived> base::AsWeakPtr ( Derived *  t)

Helper function that uses type deduction to safely return a WeakPtr<Derived> when Derived doesn't directly extend SupportsWeakPtr<Derived>, instead it extends a Base that extends SupportsWeakPtr<Base>.

EXAMPLE:

  class Base : public base::SupportsWeakPtr<Producer> {};
  class Derived : public Base {};

  Derived derived;
  base::WeakPtr<Derived> ptr = base::AsWeakPtr(&derived);

Note that the following doesn't work (invalid type conversion) since Derived::AsWeakPtr() is WeakPtr<Base> SupportsWeakPtr<Base>::AsWeakPtr(), and there's no way to safely cast WeakPtr<Base> to WeakPtr<Derived> at the caller.

  base::WeakPtr<Derived> ptr = derived.AsWeakPtr();  // Fails.

◆ BindOnce() [1/3]

template<typename Functor , typename... Args>
OnceCallback<internal::MakeUnboundRunType<Functor, Args...> > base::BindOnce ( Functor &&  functor,
Args &&...  args 
)
inline

Bind as OnceCallback.

◆ BindOnce() [2/3]

template<typename Signature >
OnceCallback<Signature> base::BindOnce ( OnceCallback< Signature >  callback)

Special cases for binding to a base::Callback without extra bound arguments.

We CHECK() the validity of callback to guard against null pointers accidentally ending up in posted tasks, causing hard-to-debug crashes.

◆ BindOnce() [3/3]

template<typename Signature >
OnceCallback<Signature> base::BindOnce ( RepeatingCallback< Signature >  callback)

◆ BindRepeating() [1/2]

template<typename Functor , typename... Args>
RepeatingCallback<internal::MakeUnboundRunType<Functor, Args...> > base::BindRepeating ( Functor &&  functor,
Args &&...  args 
)
inline

◆ BindRepeating() [2/2]

template<typename Signature >
RepeatingCallback<Signature> base::BindRepeating ( RepeatingCallback< Signature >  callback)

◆ DeletePointer()

template<typename T >
void base::DeletePointer ( T *  obj)

Useful for creating a Closure that will delete a pointer when invoked.

Only use this when necessary. In most cases MessageLoop::DeleteSoon() is a better fit.

◆ DispatchToFunction()

template<typename Function , typename Tuple >
void base::DispatchToFunction ( Function  function,
Tuple &&  args 
)
inline

◆ DispatchToFunctionImpl()

template<typename Function , typename Tuple , size_t... Ns>
void base::DispatchToFunctionImpl ( Function  function,
Tuple &&  args,
std::index_sequence< Ns... >   
)
inline

◆ DispatchToMethod() [1/2]

template<typename ObjT , typename Method , typename InTuple , typename OutTuple >
void base::DispatchToMethod ( const ObjT &  obj,
Method  method,
InTuple &&  in,
OutTuple *  out 
)
inline

◆ DispatchToMethod() [2/2]

template<typename ObjT , typename Method , typename Tuple >
void base::DispatchToMethod ( const ObjT &  obj,
Method  method,
Tuple &&  args 
)
inline

◆ DispatchToMethodImpl() [1/2]

template<typename ObjT , typename Method , typename InTuple , typename OutTuple , size_t... InNs, size_t... OutNs>
void base::DispatchToMethodImpl ( const ObjT &  obj,
Method  method,
InTuple &&  in,
OutTuple *  out,
std::index_sequence< InNs... >  ,
std::index_sequence< OutNs... >   
)
inline

◆ DispatchToMethodImpl() [2/2]

template<typename ObjT , typename Method , typename Tuple , size_t... Ns>
void base::DispatchToMethodImpl ( const ObjT &  obj,
Method  method,
Tuple &&  args,
std::index_sequence< Ns... >   
)
inline

◆ IgnoreResult()

template<typename T >
internal::IgnoreResultHelper<T> base::IgnoreResult ( data)
inline

IgnoreResult() is used to adapt a function or callback with a return type to one with a void return.

This is most useful if you have a function with, say, a pesky ignorable bool return that you want to use with PostTask or something else that expect a callback with a void return.

EXAMPLE OF IgnoreResult():

  int DoSomething(int arg) { cout << arg << endl; }

  // Assign to a callback with a void return type.
  OnceCallback<void(int)> cb = BindOnce(IgnoreResult(&DoSomething));
  std::move(cb).Run(1);  // Prints "1".

  // Prints "2" on |ml|.
  ml->PostTask(FROM_HERE, BindOnce(IgnoreResult(&DoSomething), 2);

◆ MakeRefCounted()

template<typename T , typename... Args>
scoped_refptr<T> base::MakeRefCounted ( Args &&...  args)

◆ operator!=() [1/3]

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

◆ operator!=() [2/3]

template<class T >
bool base::operator!= ( const WeakPtr< T > &  weak_ptr,
std::nullptr_t   
)

Allow callers to compare WeakPtrs against nullptr to test validity.

◆ operator!=() [3/3]

template<class T >
bool base::operator!= ( std::nullptr_t  ,
const WeakPtr< T > &  weak_ptr 
)

◆ operator==() [1/3]

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

◆ operator==() [2/3]

template<class T >
bool base::operator== ( const WeakPtr< T > &  weak_ptr,
std::nullptr_t   
)

◆ operator==() [3/3]

template<class T >
bool base::operator== ( std::nullptr_t  ,
const WeakPtr< T > &  weak_ptr 
)

◆ Owned() [1/2]

template<typename T , typename Deleter >
internal::OwnedWrapper<T, Deleter> base::Owned ( std::unique_ptr< T, Deleter > &&  ptr)
inline

◆ Owned() [2/2]

template<typename T >
internal::OwnedWrapper<T> base::Owned ( T *  o)
inline

Owned() transfers ownership of an object to the callback resulting from bind; the object will be deleted when the callback is deleted.

EXAMPLE OF Owned():

  void foo(int* arg) { cout << *arg << endl }

  int* pn = new int(1);
  RepeatingClosure foo_callback = BindRepeating(&foo, Owned(pn));

  foo_callback.Run();  // Prints "1"
  foo_callback.Run();  // Prints "1"
  *pn = 2;
  foo_callback.Run();  // Prints "2"

  foo_callback.Reset();  // |pn| is deleted.  Also will happen when
                         // |foo_callback| goes out of scope.

Without Owned(), someone would have to know to delete |pn| when the last reference to the callback is deleted.

◆ OwnedRef()

template<typename T >
internal::OwnedRefWrapper<std::decay_t<T> > base::OwnedRef ( T &&  t)

OwnedRef() stores an object in the callback resulting from bind and passes a reference to the object to the bound function.

EXAMPLE OF OwnedRef():

  void foo(int& arg) { cout << ++arg << endl }

  int counter = 0;
  RepeatingClosure foo_callback = BindRepeating(&foo, OwnedRef(counter));

  foo_callback.Run();  // Prints "1"
  foo_callback.Run();  // Prints "2"
  foo_callback.Run();  // Prints "3"

  cout << counter;     // Prints "0", OwnedRef creates a copy of counter.

Supports OnceCallbacks as well, useful to pass placeholder arguments:

  void bar(int& ignore, const std::string& s) { cout << s << endl }

  OnceClosure bar_callback = BindOnce(&bar, OwnedRef(0), "Hello");

  std::move(bar_callback).Run(); // Prints "Hello"

Without OwnedRef() it would not be possible to pass a mutable reference to an object owned by the callback.

◆ Passed() [1/2]

template<typename T , std::enable_if_t<!std::is_lvalue_reference< T >::value > * = nullptr>
internal::PassedWrapper<T> base::Passed ( T &&  scoper)
inline

Passed() is for transferring movable-but-not-copyable types (eg.

unique_ptr) through a RepeatingCallback. Logically, this signifies a destructive transfer of the state of the argument into the target function. Invoking RepeatingCallback::Run() twice on a callback that was created with a Passed() argument will CHECK() because the first invocation would have already transferred ownership to the target function.

Note that Passed() is not necessary with BindOnce(), as std::move() does the same thing. Avoid Passed() in favor of std::move() with BindOnce().

EXAMPLE OF Passed():

  void TakesOwnership(std::unique_ptr<Foo> arg) { }
  std::unique_ptr<Foo> CreateFoo() { return std::make_unique<Foo>();
  }

  auto f = std::make_unique<Foo>();

  // |cb| is given ownership of Foo(). |f| is now NULL.
  // You can use std::move(f) in place of &f, but it's more verbose.
  RepeatingClosure cb = BindRepeating(&TakesOwnership, Passed(&f));

  // Run was never called so |cb| still owns Foo() and deletes
  // it on Reset().
  cb.Reset();

  // |cb| is given a new Foo created by CreateFoo().
  cb = BindRepeating(&TakesOwnership, Passed(CreateFoo()));

  // |arg| in TakesOwnership() is given ownership of Foo(). |cb|
  // no longer owns Foo() and, if reset, would not delete Foo().
  cb.Run();  // Foo() is now transferred to |arg| and deleted.
  cb.Run();  // This CHECK()s since Foo() already been used once.

We offer 2 syntaxes for calling Passed(). The first takes an rvalue and is best suited for use with the return value of a function or other temporary rvalues. The second takes a pointer to the scoper and is just syntactic sugar to avoid having to write Passed(std::move(scoper)).

Both versions of Passed() prevent T from being an lvalue reference. The first via use of enable_if, and the second takes a T* which will not bind to T&.

◆ Passed() [2/2]

template<typename T >
internal::PassedWrapper<T> base::Passed ( T *  scoper)
inline

◆ RetainedRef() [1/2]

template<typename T >
internal::RetainedRefWrapper<T> base::RetainedRef ( scoped_refptr< T >  o)
inline

◆ RetainedRef() [2/2]

template<typename T >
internal::RetainedRefWrapper<T> base::RetainedRef ( T *  o)
inline

RetainedRef() accepts a ref counted object and retains a reference to it.

When the callback is called, the object is passed as a raw pointer.

EXAMPLE OF RetainedRef():

   void foo(RefCountedBytes* bytes) {}

   scoped_refptr<RefCountedBytes> bytes = ...;
   OnceClosure callback = BindOnce(&foo, base::RetainedRef(bytes));
   std::move(callback).Run();

Without RetainedRef, the scoped_refptr would try to implicitly convert to a raw pointer and fail compilation:

   OnceClosure callback = BindOnce(&foo, bytes); // ERROR!

◆ SplitOnceCallback()

template<typename... Args>
std::pair<OnceCallback<void(Args...)>, OnceCallback<void(Args...)> > base::SplitOnceCallback ( OnceCallback< void(Args...)>  callback)

Wraps the given OnceCallback and returns two OnceCallbacks with an identical signature.

On first invokation of either returned callbacks, the original callback is invoked. Invoking the remaining callback results in a crash.

◆ Unretained()

template<typename T >
internal::UnretainedWrapper<T> base::Unretained ( T *  o)
inline

Unretained() allows binding a non-refcounted class, and to disable refcounting on arguments that are refcounted objects.

EXAMPLE OF Unretained():

  class Foo {
   public:
    void func() { cout << "Foo:f" << endl; }
  };

  // In some function somewhere.
  Foo foo;
  OnceClosure foo_callback =
      BindOnce(&Foo::func, Unretained(&foo));
  std::move(foo_callback).Run();  // Prints "Foo:f".

Without the Unretained() wrapper on |&foo|, the above call would fail to compile because Foo does not support the AddRef() and Release() methods.

◆ WrapRefCounted()

template<typename T >
scoped_refptr<T> base::WrapRefCounted ( T *  t)

◆ WrapUnique()

template<typename T >
std::unique_ptr<T> base::WrapUnique ( T *  ptr)

Helper to transfer ownership of a raw pointer to a std::unique_ptr<T>.

Note that std::unique_ptr<T> has very different semantics from std::unique_ptr<T[]>: do not use this helper for array allocations.

Variable Documentation

◆ in_place

constexpr in_place_t base::in_place = {}
constexpr