thanks for reply.
use the user_data as a object is a good idea, since user_data is a CefBase, i think it adjust the RefCount of user_data is helpful.
for example
- Code: Select all
var a = new SomeObject();
var b = a;
if it can AddRef of user_data when do a object copy, it will be fine for |a| |b| share some resource such as db connection or file handle. but when need a deepcopy, this will not enough, so
- Code: Select all
class CefUserData : public CefBase
{
public:
// CefBase methods
virtual int AddRef() =0;
virtual int Release() =0;
virtual int GetRefCt() = 0;
// CefUserData methods
virtual CefRefPtr<CefBase> Clone(){
if (this is a shared user data){
this->AddRef();
return this;
}
else{
return new CefUserData(*this);
}
}
virtual void Gc(){
}
};
call |Clone| when do JS assignmetn, call |AddRef| when CefV8ValueImpl create and call |Release| when CefV8ValueImpl destory.
i'm not sure whether should has a Gc method, if the object should to delete itself when RefCount == 0, the Gc method can be move to the implement of Release.
i'm not sure whether has other events that fired by framework used control object life circle, if has this events, it will be helpful to add to CefUserData.
thanks.