summaryrefslogtreecommitdiff
path: root/fxjs/cfxjse_context.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/cfxjse_context.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/cfxjse_context.cpp')
-rw-r--r--fxjs/cfxjse_context.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp
index 7ee561095b..32fdd60cda 100644
--- a/fxjs/cfxjse_context.cpp
+++ b/fxjs/cfxjse_context.cpp
@@ -198,10 +198,10 @@ CFXJSE_Context::CFXJSE_Context(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {}
CFXJSE_Context::~CFXJSE_Context() {}
std::unique_ptr<CFXJSE_Value> CFXJSE_Context::GetGlobalObject() {
- auto pValue = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate);
+ auto pValue = pdfium::MakeUnique<CFXJSE_Value>(GetIsolate());
CFXJSE_ScopeUtil_IsolateHandleContext scope(this);
v8::Local<v8::Context> hContext =
- v8::Local<v8::Context>::New(m_pIsolate, m_hContext);
+ v8::Local<v8::Context>::New(GetIsolate(), m_hContext);
v8::Local<v8::Object> hGlobalObject =
hContext->Global()->GetPrototype().As<v8::Object>();
pValue->ForceSetValue(hGlobalObject);
@@ -209,7 +209,7 @@ std::unique_ptr<CFXJSE_Value> CFXJSE_Context::GetGlobalObject() {
}
v8::Local<v8::Context> CFXJSE_Context::GetContext() {
- return v8::Local<v8::Context>::New(m_pIsolate, m_hContext);
+ return v8::Local<v8::Context>::New(GetIsolate(), m_hContext);
}
void CFXJSE_Context::AddClass(std::unique_ptr<CFXJSE_Class> pClass) {
@@ -234,10 +234,10 @@ bool CFXJSE_Context::ExecuteScript(const char* szScript,
CFXJSE_Value* lpRetValue,
CFXJSE_Value* lpNewThisObject) {
CFXJSE_ScopeUtil_IsolateHandleContext scope(this);
- v8::Local<v8::Context> hContext = m_pIsolate->GetCurrentContext();
- v8::TryCatch trycatch(m_pIsolate);
+ v8::Local<v8::Context> hContext = GetIsolate()->GetCurrentContext();
+ v8::TryCatch trycatch(GetIsolate());
v8::Local<v8::String> hScriptString =
- v8::String::NewFromUtf8(m_pIsolate, szScript);
+ v8::String::NewFromUtf8(GetIsolate(), szScript);
if (!lpNewThisObject) {
v8::Local<v8::Script> hScript;
if (v8::Script::Compile(hContext, hScriptString).ToLocal(&hScript)) {
@@ -246,25 +246,25 @@ bool CFXJSE_Context::ExecuteScript(const char* szScript,
if (hScript->Run(hContext).ToLocal(&hValue)) {
ASSERT(!trycatch.HasCaught());
if (lpRetValue)
- lpRetValue->m_hValue.Reset(m_pIsolate, hValue);
+ lpRetValue->m_hValue.Reset(GetIsolate(), hValue);
return true;
}
}
if (lpRetValue) {
- lpRetValue->m_hValue.Reset(m_pIsolate,
- CreateReturnValue(m_pIsolate, trycatch));
+ lpRetValue->m_hValue.Reset(GetIsolate(),
+ CreateReturnValue(GetIsolate(), trycatch));
}
return false;
}
v8::Local<v8::Value> hNewThis =
- v8::Local<v8::Value>::New(m_pIsolate, lpNewThisObject->m_hValue);
+ v8::Local<v8::Value>::New(GetIsolate(), lpNewThisObject->m_hValue);
ASSERT(!hNewThis.IsEmpty());
v8::Local<v8::Script> hWrapper =
v8::Script::Compile(
hContext,
v8::String::NewFromUtf8(
- m_pIsolate, "(function () { return eval(arguments[0]); })"))
+ GetIsolate(), "(function () { return eval(arguments[0]); })"))
.ToLocalChecked();
v8::Local<v8::Value> hWrapperValue;
if (hWrapper->Run(hContext).ToLocal(&hWrapperValue)) {
@@ -276,7 +276,7 @@ bool CFXJSE_Context::ExecuteScript(const char* szScript,
.ToLocal(&hValue)) {
ASSERT(!trycatch.HasCaught());
if (lpRetValue)
- lpRetValue->m_hValue.Reset(m_pIsolate, hValue);
+ lpRetValue->m_hValue.Reset(GetIsolate(), hValue);
return true;
}
@@ -297,8 +297,8 @@ bool CFXJSE_Context::ExecuteScript(const char* szScript,
#endif // NDEBUG
if (lpRetValue) {
- lpRetValue->m_hValue.Reset(m_pIsolate,
- CreateReturnValue(m_pIsolate, trycatch));
+ lpRetValue->m_hValue.Reset(GetIsolate(),
+ CreateReturnValue(GetIsolate(), trycatch));
}
return false;
}