Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Unified Diff: xfa/src/fxjse/src/runtime.cpp

Issue 1351173002: XFA: contention between FXJSE and FXJS over isolate data slots (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/src/fxjse/src/runtime.cpp
diff --git a/xfa/src/fxjse/src/runtime.cpp b/xfa/src/fxjse/src/runtime.cpp
index a7ee67bc2a7d1978ae2914584c4c0d15cd85622d..4a77b4f165c718cdb788a917f1193e8609c1eaa9 100644
--- a/xfa/src/fxjse/src/runtime.cpp
+++ b/xfa/src/fxjse/src/runtime.cpp
@@ -4,6 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "../../../../fpdfsdk/include/jsapi/fxjs_v8.h" // For per-isolate data.
#include "../../foxitlib.h"
#include "fxv8.h"
#include "runtime.h"
@@ -38,11 +39,9 @@ void FXJSE_Initialize() {
static void FXJSE_Runtime_DisposeCallback(v8::Isolate* pIsolate) {
{
v8::Locker locker(pIsolate);
- CFXJSE_RuntimeData* pRuntimeData =
- reinterpret_cast<CFXJSE_RuntimeData*>(pIsolate->GetData(0));
- if (pRuntimeData) {
- pIsolate->SetData(0, NULL);
- delete pRuntimeData;
+ if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) {
+ delete pData->m_pFXJSERuntimeData;
+ pData->m_pFXJSERuntimeData = nullptr;
}
}
pIsolate->Dispose();
@@ -73,7 +72,6 @@ void FXJSE_Runtime_Release(FXJSE_HRUNTIME hRuntime) {
}
CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) {
CFXJSE_RuntimeData* pRuntimeData = new CFXJSE_RuntimeData(pIsolate);
- ASSERT(pRuntimeData);
CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate);
v8::Local<v8::FunctionTemplate> hFuncTemplate =
v8::FunctionTemplate::New(pIsolate);
@@ -85,15 +83,10 @@ CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) {
return pRuntimeData;
}
CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) {
- ASSERT(pIsolate);
- CFXJSE_RuntimeData* pRuntimeData =
- static_cast<CFXJSE_RuntimeData*>(pIsolate->GetData(0));
- if (!pRuntimeData) {
jun_fang 2015/10/28 16:19:26 When pRuntimeData is nullptr, it calls CFXJSE_Runt
Tom Sepez 2015/10/28 16:55:29 Ok, please file a bug for this in the issue tracke
- pRuntimeData = CFXJSE_RuntimeData::Create(pIsolate);
- ASSERT(pRuntimeData);
- pIsolate->SetData(0, pRuntimeData);
- }
- return pRuntimeData;
+ FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate);
+ if (!pData->m_pFXJSERuntimeData)
+ pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate);
+ return pData->m_pFXJSERuntimeData;
}
CFXJSE_RuntimeList* CFXJSE_RuntimeData::g_RuntimeList = NULL;
void CFXJSE_RuntimeList::AppendRuntime(v8::Isolate* pIsolate) {
« no previous file with comments | « fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698