Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: fpdfsdk/src/javascript/JS_Object.cpp

Issue 1129253004: Use phantom handles instead of weak handles (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/include/jsapi/fxjs_v8.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/javascript/JS_Object.cpp
diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp
index 6c0c868e4c27adde4a98c0e7139cf88cc9bd77e9..66fd2b682fe3444fe26fc5fbbfc5973c2fcf7ec8 100644
--- a/fpdfsdk/src/javascript/JS_Object.cpp
+++ b/fpdfsdk/src/javascript/JS_Object.cpp
@@ -88,16 +88,19 @@ void CJS_EmbedObj::EndTimer(CJS_Timer* pTimer)
}
/* --------------------------------- CJS_Object --------------------------------- */
-void FreeObject(const v8::WeakCallbackData<v8::Object, CJS_Object>& data)
+void FreeObject(const v8::WeakCallbackInfo<CJS_Object>& data)
{
CJS_Object* pJSObj = data.GetParameter();
- if(pJSObj)
- {
- pJSObj->ExitInstance();
- delete pJSObj;
- }
- v8::Local<v8::Object> obj = data.GetValue();
- JS_FreePrivate(obj);
+ pJSObj->ExitInstance();
+ delete pJSObj;
+ JS_FreePrivate(data.GetInternalField(0));
+}
+
+void DisposeObject(const v8::WeakCallbackInfo<CJS_Object>& data)
+{
+ CJS_Object* pJSObj = data.GetParameter();
+ pJSObj->Dispose();
+ data.SetSecondPassCallback(FreeObject);
}
CJS_Object::CJS_Object(JSFXObject pObject) :m_pEmbedObj(NULL)
@@ -117,7 +120,13 @@ CJS_Object::~CJS_Object(void)
void CJS_Object::MakeWeak()
{
- m_pObject.SetWeak(this, FreeObject);
+ m_pObject.SetWeak(
+ this, DisposeObject, v8::WeakCallbackType::kInternalFields);
+}
+
+void CJS_Object::Dispose()
+{
+ m_pObject.Reset();
}
CPDFSDK_PageView* CJS_Object::JSGetPageView(IFXJS_Context* cc)
« no previous file with comments | « fpdfsdk/include/jsapi/fxjs_v8.h ('k') | fpdfsdk/src/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698