summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-06 16:46:14 -0700
committerLei Zhang <thestig@chromium.org>2015-10-06 16:46:14 -0700
commitc38cbe65e0d126f7f9800b6ef427af725d32fc6f (patch)
treeaad929e73d24da5adf2fdb0f34dcbc1c42ce323f
parent52475f51ecdb8dd29e69a3167853cc7d3e51cdad (diff)
downloadpdfium-c38cbe65e0d126f7f9800b6ef427af725d32fc6f.tar.xz
Merge to M47: Only call DefineJSObjects() once for the global V8 isolate.
BUG=539106 TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1386823002 . (cherry picked from commit 7dfe5929282cb6d78d7b5e32e1d72e9db99d3066) Review URL: https://codereview.chromium.org/1391753002 .
-rw-r--r--fpdfsdk/include/jsapi/fxjs_v8.h3
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp3
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp4
3 files changed, 9 insertions, 1 deletions
diff --git a/fpdfsdk/include/jsapi/fxjs_v8.h b/fpdfsdk/include/jsapi/fxjs_v8.h
index 1705b894cf..8b5c0b2dd0 100644
--- a/fpdfsdk/include/jsapi/fxjs_v8.h
+++ b/fpdfsdk/include/jsapi/fxjs_v8.h
@@ -70,6 +70,9 @@ void FXJS_Release();
// created.
bool FXJS_GetIsolate(v8::Isolate** pResultIsolate);
+// Get the global isolate's ref count.
+size_t FXJS_GlobalIsolateRefCount();
+
// Call before making FXJS_Define* calls. Resources allocated here are cleared
// as part of FXJS_ReleaseRuntime().
void FXJS_PrepareIsolate(v8::Isolate* pIsolate);
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 4c502a7b75..707551adbe 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -45,7 +45,8 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
FXJS_Initialize(embedderDataSlot, pExternalIsolate);
}
m_isolateManaged = FXJS_GetIsolate(&m_isolate);
- DefineJSObjects();
+ if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0)
+ DefineJSObjects();
CJS_Context* pContext = (CJS_Context*)NewContext();
FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context);
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index bea9f4c4d8..54044e2118 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -166,6 +166,10 @@ bool FXJS_GetIsolate(v8::Isolate** pResultIsolate) {
return true;
}
+size_t FXJS_GlobalIsolateRefCount() {
+ return g_isolate_ref_count;
+}
+
// static
void FXJS_PerIsolateData::SetUp(v8::Isolate* pIsolate) {
if (!pIsolate->GetData(g_embedderDataSlot))