diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-11-10 15:07:08 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-11-10 15:07:08 -0800 |
commit | 7d4c74d1b96d82681d49519c129262a1568e87d4 (patch) | |
tree | f1417bd69f8960f072b3fef8309ff092a8380605 /fpdfsdk/src/javascript | |
parent | 46960a43145ab978ca3c90cb6133bb3d5600ad1d (diff) | |
download | pdfium-7d4c74d1b96d82681d49519c129262a1568e87d4.tar.xz |
Keep "static" objects per-context rather than per isolate.
Every time we initialize a new v8::Context, we make a new set of
pre-existing native objects, and overwrite the v8::Global
handles to those in the previous set. Thus, we may be
theoretically releasing some v8::Globals early.
R=jochen@chromium.org
Review URL: https://codereview.chromium.org/1424933013 .
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.h | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index 34a18dc385..74d9a44a1c 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -64,7 +64,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) DefineJSObjects(); CJS_Context* pContext = (CJS_Context*)NewContext(); - FXJS_InitializeRuntime(GetIsolate(), this, m_context); + FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects); ReleaseContext(pContext); } @@ -76,7 +76,7 @@ CJS_Runtime::~CJS_Runtime() { delete m_ContextArray.GetAt(i); m_ContextArray.RemoveAll(); - FXJS_ReleaseRuntime(GetIsolate(), m_context); + FXJS_ReleaseRuntime(GetIsolate(), &m_context, &m_StaticObjects); m_pApp = NULL; m_pDocument = NULL; diff --git a/fpdfsdk/src/javascript/JS_Runtime.h b/fpdfsdk/src/javascript/JS_Runtime.h index 4a55c2e9e6..1bdd8e6fdd 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.h +++ b/fpdfsdk/src/javascript/JS_Runtime.h @@ -9,6 +9,7 @@ #include <set> #include <utility> +#include <vector> #include "../../include/javascript/IJavaScript.h" #include "../../include/jsapi/fxjs_v8.h" @@ -71,6 +72,7 @@ class CJS_Runtime : public IJS_Runtime { v8::Isolate* m_isolate; bool m_isolateManaged; v8::Global<v8::Context> m_context; + std::vector<v8::Global<v8::Object>*> m_StaticObjects; std::set<Observer*> m_observers; }; |