Support implicit detachment of CEF V8 references when the associated context is released (issue #484).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@883 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-10-29 21:54:57 +00:00
parent 3ac5952636
commit 59fe4fbab3
25 changed files with 522 additions and 43 deletions

View File

@@ -114,6 +114,12 @@ typedef struct _cef_v8context_t {
///
cef_base_t base;
///
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
///
int (CEF_CALLBACK *is_valid)(struct _cef_v8context_t* self);
///
// Returns the browser for this context.
///
@@ -314,6 +320,12 @@ typedef struct _cef_v8value_t {
///
cef_base_t base;
///
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
///
int (CEF_CALLBACK *is_valid)(struct _cef_v8value_t* self);
///
// True if the value type is undefined.
///
@@ -708,6 +720,12 @@ typedef struct _cef_v8stack_trace_t {
///
cef_base_t base;
///
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
///
int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_trace_t* self);
///
// Returns the number of stack frames.
///
@@ -738,6 +756,12 @@ typedef struct _cef_v8stack_frame_t {
///
cef_base_t base;
///
// Returns true (1) if this object is valid. Do not call any other functions
// if this function returns false (0).
///
int (CEF_CALLBACK *is_valid)(struct _cef_v8stack_frame_t* self);
///
// Returns the name of the resource script that contains the function.
///

View File

@@ -140,6 +140,13 @@ class CefV8Context : public virtual CefBase {
/*--cef()--*/
static bool InContext();
///
// Returns true if this object is valid. Do not call any other methods if this
// method returns false.
///
/*--cef()--*/
virtual bool IsValid() =0;
///
// Returns the browser for this context.
///
@@ -407,6 +414,13 @@ class CefV8Value : public virtual CefBase {
static CefRefPtr<CefV8Value> CreateFunction(const CefString& name,
CefRefPtr<CefV8Handler> handler);
///
// Returns true if this object is valid. Do not call any other methods if this
// method returns false.
///
/*--cef()--*/
virtual bool IsValid() =0;
///
// True if the value type is undefined.
///
@@ -754,6 +768,13 @@ class CefV8StackTrace : public virtual CefBase {
/*--cef()--*/
static CefRefPtr<CefV8StackTrace> GetCurrent(int frame_limit);
///
// Returns true if this object is valid. Do not call any other methods if this
// method returns false.
///
/*--cef()--*/
virtual bool IsValid() =0;
///
// Returns the number of stack frames.
///
@@ -774,6 +795,13 @@ class CefV8StackTrace : public virtual CefBase {
/*--cef(source=library)--*/
class CefV8StackFrame : public virtual CefBase {
public:
///
// Returns true if this object is valid. Do not call any other methods if this
// method returns false.
///
/*--cef()--*/
virtual bool IsValid() =0;
///
// Returns the name of the resource script that contains the function.
///

View File

@@ -218,6 +218,25 @@ typedef struct _cef_settings_t {
// OnUncaughtException() will not be called.
///
int uncaught_exception_stack_size;
///
// By default CEF V8 references will be invalidated (the IsValid() method will
// return false) after the owning context has been released. This reduces the
// need for external record keeping and avoids crashes due to the use of V8
// references after the associated context has been released.
//
// CEF currently offers two context safety implementations with different
// performance characteristics. The default implementation (value of 0) uses a
// map of hash values and should provide better performance in situations with
// a small number contexts. The alternate implementation (value of 1) uses a
// hidden value attached to each context and should provide better performance
// in situations with a large number of contexts.
//
// If you need better performance in the creation of V8 references and you
// plan to manually track context lifespan you can disable context safety by
// specifying a value of -1.
///
int context_safety_implementation;
} cef_settings_t;
///

View File

@@ -300,6 +300,7 @@ struct CefSettingsTraits {
&target->locales_dir_path, copy);
target->pack_loading_disabled = src->pack_loading_disabled;
target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
target->context_safety_implementation = src->context_safety_implementation;
}
};