#ifndef CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_BASE_CAPI_H_
+#include <stdint.h>
+
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
#include "include/internal/cef_string_list.h"
#endif
///
-// Structure defining the reference count implementation functions. All
-// framework structures must include the cef_base_t structure first.
+// All ref-counted framework structures must include this structure first.
///
-typedef struct _cef_base_t {
+typedef struct _cef_base_ref_counted_t {
///
// Size of the data structure.
///
size_t size;
///
- // Increment the reference count.
+ // Called to increment the reference count for the object. Should be called
+ // for every new copy of a pointer to a given object.
///
- int (CEF_CALLBACK *add_ref)(struct _cef_base_t* self);
+ void (CEF_CALLBACK *add_ref)(struct _cef_base_ref_counted_t* self);
///
- // Decrement the reference count. Delete this object when no references
- // remain.
+ // Called to decrement the reference count for the object. If the reference
+ // count falls to 0 the object should self-delete. Returns true (1) if the
+ // resulting reference count is 0.
///
- int (CEF_CALLBACK *release)(struct _cef_base_t* self);
+ int (CEF_CALLBACK *release)(struct _cef_base_ref_counted_t* self);
///
- // Returns the current number of references.
+ // Returns true (1) if the current reference count is 1.
///
- int (CEF_CALLBACK *get_refct)(struct _cef_base_t* self);
-} cef_base_t;
+ int (CEF_CALLBACK *has_one_ref)(struct _cef_base_ref_counted_t* self);
+} cef_base_ref_counted_t;
+
+
+///
+// All scoped framework structures must include this structure first.
+///
+typedef struct _cef_base_scoped_t {
+ ///
+ // Size of the data structure.
+ ///
+ size_t size;
+
+ ///
+ // Called to delete this object. May be NULL if the object is not owned.
+ ///
+ void (CEF_CALLBACK *del)(struct _cef_base_scoped_t* self);
+
+} cef_base_scoped_t;
-// Check that the structure |s|, which is defined with a cef_base_t member named
-// |base|, is large enough to contain the specified member |f|.
+// Check that the structure |s|, which is defined with a size_t member at the
+// top, is large enough to contain the specified member |f|.
#define CEF_MEMBER_EXISTS(s, f) \
- ((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= (s)->base.size)
+ ((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= \
+ *reinterpret_cast<size_t*>(s))
#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))