diff --git a/include/wrapper/cef_helpers.h b/include/wrapper/cef_helpers.h index 93c4a513e..15489034d 100644 --- a/include/wrapper/cef_helpers.h +++ b/include/wrapper/cef_helpers.h @@ -89,6 +89,32 @@ struct CefDeleteOnIOThread : public CefDeleteOnThread {}; struct CefDeleteOnFileThread : public CefDeleteOnThread {}; struct CefDeleteOnRendererThread : public CefDeleteOnThread {}; +// Same as IMPLEMENT_REFCOUNTING() but using the specified Destructor. +#define IMPLEMENT_REFCOUNTING_EX(ClassName, Destructor) \ + public: \ + void AddRef() const OVERRIDE { ref_count_.AddRef(); } \ + bool Release() const OVERRIDE { \ + if (ref_count_.Release()) { \ + Destructor::Destruct(this); \ + return true; \ + } \ + return false; \ + } \ + bool HasOneRef() const OVERRIDE { return ref_count_.HasOneRef(); } \ + bool HasAtLeastOneRef() const OVERRIDE { \ + return ref_count_.HasAtLeastOneRef(); \ + } \ + \ + private: \ + CefRefCount ref_count_ + +#define IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(ClassName) \ + IMPLEMENT_REFCOUNTING_EX(ClassName, CefDeleteOnUIThread) + +#define IMPLEMENT_REFCOUNTING_DELETE_ON_IOT(ClassName) \ + IMPLEMENT_REFCOUNTING_EX(ClassName, CefDeleteOnIOThread) + + /// // Helper class to manage a scoped copy of |argv|. ///