diff options
author | Lei Zhang <thestig@chromium.org> | 2015-10-04 20:40:15 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-10-04 20:40:15 -0700 |
commit | 7dfe5929282cb6d78d7b5e32e1d72e9db99d3066 (patch) | |
tree | 0cfd7321bafd3bf377435f1c29f69fe254f09965 /fpdfsdk/src | |
parent | 794c9b67d3d519342aa7e15052766f7d4a99f551 (diff) | |
download | pdfium-7dfe5929282cb6d78d7b5e32e1d72e9db99d3066.tar.xz |
Only call DefineJSObjects() once for the global V8 isolate.
BUG=539106
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1386823002 .
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 3 | ||||
-rw-r--r-- | fpdfsdk/src/jsapi/fxjs_v8.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
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)) |