summaryrefslogtreecommitdiff
path: root/fxjs/fxjs_v8.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-02-01 20:24:43 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-01 20:24:43 +0000
commite99ee7f3e550f7706a3e2d8105ccc55553a9badb (patch)
tree253acd8343f135a7bbeef9d80c71564fca6f1a69 /fxjs/fxjs_v8.cpp
parentfb25606e584e14d60fc243e8b56eef399a4a54bd (diff)
downloadpdfium-e99ee7f3e550f7706a3e2d8105ccc55553a9badb.tar.xz
Introduce CXFJS_Engine::EngineFromContext/SetEngineInContext helpers
No functional change, but expose helpers likely to be needed by next steps. Rename CXFJS_Engine::CurrentEngineFromIsolate to be more accurately named along the way. Change-Id: Iaf2d15a09cfed85705d24ee056e78edf0660ce59 Reviewed-on: https://pdfium-review.googlesource.com/25090 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/fxjs_v8.cpp')
-rw-r--r--fxjs/fxjs_v8.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp
index 50345cfcd1..e73ab0a8f0 100644
--- a/fxjs/fxjs_v8.cpp
+++ b/fxjs/fxjs_v8.cpp
@@ -177,8 +177,8 @@ void V8TemplateMapTraits::Dispose(v8::Isolate* isolate,
if (!pObjDef)
return;
if (pObjDef->m_pDestructor) {
- pObjDef->m_pDestructor(CFXJS_Engine::CurrentEngineFromIsolate(isolate),
- obj);
+ pObjDef->m_pDestructor(
+ CFXJS_Engine::EngineFromIsolateCurrentContext(isolate), obj);
}
CFXJS_Engine::FreeObjectPrivate(obj);
}
@@ -261,10 +261,19 @@ CFXJS_Engine::CFXJS_Engine(v8::Isolate* pIsolate) : CJS_V8(pIsolate) {}
CFXJS_Engine::~CFXJS_Engine() = default;
// static
-CFXJS_Engine* CFXJS_Engine::CurrentEngineFromIsolate(v8::Isolate* pIsolate) {
+CFXJS_Engine* CFXJS_Engine::EngineFromIsolateCurrentContext(
+ v8::Isolate* pIsolate) {
+ return EngineFromContext(pIsolate->GetCurrentContext());
+}
+
+CFXJS_Engine* CFXJS_Engine::EngineFromContext(v8::Local<v8::Context> pContext) {
return static_cast<CFXJS_Engine*>(
- pIsolate->GetCurrentContext()->GetAlignedPointerFromEmbedderData(
- kPerContextDataIndex));
+ pContext->GetAlignedPointerFromEmbedderData(kPerContextDataIndex));
+}
+
+void CFXJS_Engine::SetEngineInContext(CFXJS_Engine* pEngine,
+ v8::Local<v8::Context> pContext) {
+ pContext->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pEngine);
}
// static
@@ -385,8 +394,7 @@ void CFXJS_Engine::InitializeEngine() {
v8::Local<v8::Context> v8Context = v8::Context::New(
GetIsolate(), nullptr, GetGlobalObjectTemplate(GetIsolate()));
v8::Context::Scope context_scope(v8Context);
-
- v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, this);
+ SetEngineInContext(this, v8Context);
int maxID = CFXJS_ObjDefinition::MaxID(GetIsolate());
m_StaticObjects.resize(maxID + 1);