summaryrefslogtreecommitdiff
path: root/fxjs/cfxjs_engine.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-07-16 21:35:06 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-16 21:35:06 +0000
commit98b356a36bc9291a4f222d092afeeea0d5b5f379 (patch)
tree71fbda3964df30ef354afd36e3a9aba32978f762 /fxjs/cfxjs_engine.cpp
parent31781107f6bda92e732fed805f62e8512bc78149 (diff)
downloadpdfium-98b356a36bc9291a4f222d092afeeea0d5b5f379.tar.xz
Use UnownedPtr<> to v8::Isolates.
Isolates are long-lived, but this may catch a few things. Introduce CFX_V8IsolateDeleter for unique_ptr<v8::Isolate> usage. Fix Dispose()/SetIsolate(nullptr) ordering in cjs_runtime.cpp Remove one unused isolate member. Flip protected -> private in one place. Change-Id: I26cdd120f799192e93b0d9d04dcde8f348dc21f3 Reviewed-on: https://pdfium-review.googlesource.com/37931 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cfxjs_engine.cpp')
-rw-r--r--fxjs/cfxjs_engine.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
index 0978bee7c1..1a02ec9a78 100644
--- a/fxjs/cfxjs_engine.cpp
+++ b/fxjs/cfxjs_engine.cpp
@@ -10,6 +10,7 @@
#include <utility>
#include <vector>
+#include "core/fxcrt/unowned_ptr.h"
#include "fxjs/cfxjse_runtimedata.h"
#include "fxjs/cjs_object.h"
@@ -143,8 +144,10 @@ class CFXJS_ObjDefinition {
m_Signature.Reset(isolate, sig);
}
+ v8::Isolate* GetIsolate() const { return m_pIsolate.Get(); }
+
void DefineConst(const char* sConstName, v8::Local<v8::Value> pDefault) {
- GetInstanceTemplate()->Set(m_pIsolate, sConstName, pDefault);
+ GetInstanceTemplate()->Set(GetIsolate(), sConstName, pDefault);
}
void DefineProperty(v8::Local<v8::String> sPropName,
@@ -156,7 +159,7 @@ class CFXJS_ObjDefinition {
void DefineMethod(v8::Local<v8::String> sMethodName,
v8::FunctionCallback pMethodCall) {
v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
- m_pIsolate, pMethodCall, v8::Local<v8::Value>(), GetSignature());
+ GetIsolate(), pMethodCall, v8::Local<v8::Value>(), GetSignature());
fun->RemovePrototype();
GetInstanceTemplate()->Set(sMethodName, fun, v8::ReadOnly);
}
@@ -172,23 +175,22 @@ class CFXJS_ObjDefinition {
}
v8::Local<v8::ObjectTemplate> GetInstanceTemplate() {
- v8::EscapableHandleScope scope(m_pIsolate);
+ v8::EscapableHandleScope scope(GetIsolate());
v8::Local<v8::FunctionTemplate> function =
- m_FunctionTemplate.Get(m_pIsolate);
+ m_FunctionTemplate.Get(GetIsolate());
return scope.Escape(function->InstanceTemplate());
}
v8::Local<v8::Signature> GetSignature() {
- v8::EscapableHandleScope scope(m_pIsolate);
- return scope.Escape(m_Signature.Get(m_pIsolate));
+ v8::EscapableHandleScope scope(GetIsolate());
+ return scope.Escape(m_Signature.Get(GetIsolate()));
}
const char* const m_ObjName;
const FXJSOBJTYPE m_ObjType;
const CFXJS_Engine::Constructor m_pConstructor;
const CFXJS_Engine::Destructor m_pDestructor;
-
- v8::Isolate* m_pIsolate;
+ UnownedPtr<v8::Isolate> m_pIsolate;
v8::Global<v8::FunctionTemplate> m_FunctionTemplate;
v8::Global<v8::Signature> m_Signature;
};