mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update include/ comments to Doxygen formatting (see issue #3384)
See related guidelines in the issue.
This commit is contained in:
@ -37,130 +37,138 @@
|
||||
#include "include/base/cef_ref_counted.h"
|
||||
|
||||
///
|
||||
// Smart pointer implementation that is an alias of scoped_refptr from
|
||||
// include/base/cef_ref_counted.h.
|
||||
// <p>
|
||||
// A smart pointer class for reference counted objects. Use this class instead
|
||||
// of calling AddRef and Release manually on a reference counted object to
|
||||
// avoid common memory leaks caused by forgetting to Release an object
|
||||
// reference. Sample usage:
|
||||
// <pre>
|
||||
// class MyFoo : public CefBaseRefCounted {
|
||||
// ...
|
||||
// };
|
||||
//
|
||||
// void some_function() {
|
||||
// // The MyFoo object that |foo| represents starts with a single
|
||||
// // reference.
|
||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
// foo->Method(param);
|
||||
// // |foo| is released when this function returns
|
||||
// }
|
||||
//
|
||||
// void some_other_function() {
|
||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
// ...
|
||||
// foo = NULL; // explicitly releases |foo|
|
||||
// ...
|
||||
// if (foo)
|
||||
// foo->Method(param);
|
||||
// }
|
||||
// </pre>
|
||||
// The above examples show how CefRefPtr<T> acts like a pointer to T.
|
||||
// Given two CefRefPtr<T> classes, it is also possible to exchange
|
||||
// references between the two objects, like so:
|
||||
// <pre>
|
||||
// {
|
||||
// CefRefPtr<MyFoo> a = new MyFoo();
|
||||
// CefRefPtr<MyFoo> b;
|
||||
//
|
||||
// b.swap(a);
|
||||
// // now, |b| references the MyFoo object, and |a| references NULL.
|
||||
// }
|
||||
// </pre>
|
||||
// To make both |a| and |b| in the above example reference the same MyFoo
|
||||
// object, simply use the assignment operator:
|
||||
// <pre>
|
||||
// {
|
||||
// CefRefPtr<MyFoo> a = new MyFoo();
|
||||
// CefRefPtr<MyFoo> b;
|
||||
//
|
||||
// b = a;
|
||||
// // now, |a| and |b| each own a reference to the same MyFoo object.
|
||||
// // the reference count of the underlying MyFoo object will be 2.
|
||||
// }
|
||||
// </pre>
|
||||
// Reference counted objects can also be passed as function parameters and
|
||||
// used as function return values:
|
||||
// <pre>
|
||||
// void some_func_with_param(CefRefPtr<MyFoo> param) {
|
||||
// // A reference is added to the MyFoo object that |param| represents
|
||||
// // during the scope of some_func_with_param() and released when
|
||||
// // some_func_with_param() goes out of scope.
|
||||
// }
|
||||
//
|
||||
// CefRefPtr<MyFoo> some_func_with_retval() {
|
||||
// // The MyFoo object that |foox| represents starts with a single
|
||||
// // reference.
|
||||
// CefRefPtr<MyFoo> foox = new MyFoo();
|
||||
//
|
||||
// // Creating the return value adds an additional reference.
|
||||
// return foox;
|
||||
//
|
||||
// // When some_func_with_retval() goes out of scope the original |foox|
|
||||
// // reference is released.
|
||||
// }
|
||||
//
|
||||
// void and_another_function() {
|
||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
//
|
||||
// // pass |foo| as a parameter.
|
||||
// some_function(foo);
|
||||
//
|
||||
// CefRefPtr<MyFoo> foo2 = some_func_with_retval();
|
||||
// // Now, since we kept a reference to the some_func_with_retval() return
|
||||
// // value, |foo2| is the only class pointing to the MyFoo object created
|
||||
// in some_func_with_retval(), and it has a reference count of 1.
|
||||
//
|
||||
// some_func_with_retval();
|
||||
// // Now, since we didn't keep a reference to the some_func_with_retval()
|
||||
// // return value, the MyFoo object created in some_func_with_retval()
|
||||
// // will automatically be released.
|
||||
// }
|
||||
// </pre>
|
||||
// And in standard containers:
|
||||
// <pre>
|
||||
// {
|
||||
// // Create a vector that holds MyFoo objects.
|
||||
// std::vector<CefRefPtr<MyFoo> > MyFooVec;
|
||||
//
|
||||
// // The MyFoo object that |foo| represents starts with a single
|
||||
// // reference.
|
||||
// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
//
|
||||
// // When the MyFoo object is added to |MyFooVec| the reference count
|
||||
// // is increased to 2.
|
||||
// MyFooVec.push_back(foo);
|
||||
// }
|
||||
// </pre>
|
||||
// </p>
|
||||
/// Smart pointer implementation that is an alias of scoped_refptr from
|
||||
/// include/base/cef_ref_counted.h.
|
||||
///
|
||||
/// A smart pointer class for reference counted objects. Use this class instead
|
||||
/// of calling AddRef and Release manually on a reference counted object to
|
||||
/// avoid common memory leaks caused by forgetting to Release an object
|
||||
/// reference. Sample usage:
|
||||
///
|
||||
/// <pre>
|
||||
/// class MyFoo : public CefBaseRefCounted {
|
||||
/// ...
|
||||
/// };
|
||||
///
|
||||
/// void some_function() {
|
||||
/// // The MyFoo object that |foo| represents starts with a single
|
||||
/// // reference.
|
||||
/// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
/// foo->Method(param);
|
||||
/// // |foo| is released when this function returns
|
||||
/// }
|
||||
///
|
||||
/// void some_other_function() {
|
||||
/// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
/// ...
|
||||
/// foo = NULL; /// explicitly releases |foo|
|
||||
/// ...
|
||||
/// if (foo)
|
||||
/// foo->Method(param);
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// The above examples show how CefRefPtr<T> acts like a pointer to T.
|
||||
/// Given two CefRefPtr<T> classes, it is also possible to exchange
|
||||
/// references between the two objects, like so:
|
||||
///
|
||||
/// <pre>
|
||||
/// {
|
||||
/// CefRefPtr<MyFoo> a = new MyFoo();
|
||||
/// CefRefPtr<MyFoo> b;
|
||||
///
|
||||
/// b.swap(a);
|
||||
/// // now, |b| references the MyFoo object, and |a| references NULL.
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// To make both |a| and |b| in the above example reference the same MyFoo
|
||||
/// object, simply use the assignment operator:
|
||||
///
|
||||
/// <pre>
|
||||
/// {
|
||||
/// CefRefPtr<MyFoo> a = new MyFoo();
|
||||
/// CefRefPtr<MyFoo> b;
|
||||
///
|
||||
/// b = a;
|
||||
/// // now, |a| and |b| each own a reference to the same MyFoo object.
|
||||
/// // the reference count of the underlying MyFoo object will be 2.
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// Reference counted objects can also be passed as function parameters and
|
||||
/// used as function return values:
|
||||
///
|
||||
/// <pre>
|
||||
/// void some_func_with_param(CefRefPtr<MyFoo> param) {
|
||||
/// // A reference is added to the MyFoo object that |param| represents
|
||||
/// // during the scope of some_func_with_param() and released when
|
||||
/// // some_func_with_param() goes out of scope.
|
||||
/// }
|
||||
///
|
||||
/// CefRefPtr<MyFoo> some_func_with_retval() {
|
||||
/// // The MyFoo object that |foox| represents starts with a single
|
||||
/// // reference.
|
||||
/// CefRefPtr<MyFoo> foox = new MyFoo();
|
||||
///
|
||||
/// // Creating the return value adds an additional reference.
|
||||
/// return foox;
|
||||
///
|
||||
/// // When some_func_with_retval() goes out of scope the original |foox|
|
||||
/// // reference is released.
|
||||
/// }
|
||||
///
|
||||
/// void and_another_function() {
|
||||
/// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
///
|
||||
/// // pass |foo| as a parameter.
|
||||
/// some_function(foo);
|
||||
///
|
||||
/// CefRefPtr<MyFoo> foo2 = some_func_with_retval();
|
||||
/// // Now, since we kept a reference to the some_func_with_retval() return
|
||||
/// // value, |foo2| is the only class pointing to the MyFoo object created
|
||||
/// in some_func_with_retval(), and it has a reference count of 1.
|
||||
///
|
||||
/// some_func_with_retval();
|
||||
/// // Now, since we didn't keep a reference to the some_func_with_retval()
|
||||
/// // return value, the MyFoo object created in some_func_with_retval()
|
||||
/// // will automatically be released.
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
/// And in standard containers:
|
||||
///
|
||||
/// <pre>
|
||||
/// {
|
||||
/// // Create a vector that holds MyFoo objects.
|
||||
/// std::vector<CefRefPtr<MyFoo> > MyFooVec;
|
||||
///
|
||||
/// // The MyFoo object that |foo| represents starts with a single
|
||||
/// // reference.
|
||||
/// CefRefPtr<MyFoo> foo = new MyFoo();
|
||||
///
|
||||
/// // When the MyFoo object is added to |MyFooVec| the reference count
|
||||
/// // is increased to 2.
|
||||
/// MyFooVec.push_back(foo);
|
||||
/// }
|
||||
/// </pre>
|
||||
///
|
||||
template <class T>
|
||||
using CefRefPtr = scoped_refptr<T>;
|
||||
|
||||
///
|
||||
// A CefOwnPtr<T> is like a T*, except that the destructor of CefOwnPtr<T>
|
||||
// automatically deletes the pointer it holds (if any). That is, CefOwnPtr<T>
|
||||
// owns the T object that it points to. Like a T*, a CefOwnPtr<T> may hold
|
||||
// either NULL or a pointer to a T object. Also like T*, CefOwnPtr<T> is
|
||||
// thread-compatible, and once you dereference it, you get the thread safety
|
||||
// guarantees of T.
|
||||
/// A CefOwnPtr<T> is like a T*, except that the destructor of CefOwnPtr<T>
|
||||
/// automatically deletes the pointer it holds (if any). That is, CefOwnPtr<T>
|
||||
/// owns the T object that it points to. Like a T*, a CefOwnPtr<T> may hold
|
||||
/// either NULL or a pointer to a T object. Also like T*, CefOwnPtr<T> is
|
||||
/// thread-compatible, and once you dereference it, you get the thread safety
|
||||
/// guarantees of T.
|
||||
///
|
||||
template <class T, class D = std::default_delete<T>>
|
||||
using CefOwnPtr = std::unique_ptr<T, D>;
|
||||
|
||||
///
|
||||
// A CefRawPtr<T> is the same as T*
|
||||
/// A CefRawPtr<T> is the same as T*
|
||||
///
|
||||
template <class T>
|
||||
using CefRawPtr = T*;
|
||||
|
Reference in New Issue
Block a user