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

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: 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
« fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp ('K') | « fpdfsdk/src/jsapi/fxjs_v8.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..7943c68480f406ea9600f53c7969b5c23e589984 100644
--- a/xfa/src/fxjse/src/runtime.cpp
+++ b/xfa/src/fxjse/src/runtime.cpp
@@ -9,6 +9,9 @@
#include "runtime.h"
#include "scope_inline.h"
+// TODO(tsepez): unify embedder data slot usage.
+static const unsigned int kFXJSEEmbedderDataSlot = 1u;
+
// Duplicates fpdfsdk's JS_Runtime.h, but keeps XFA from depending on it.
// TODO(tsepez): make a single version of this.
class FXJSE_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
@@ -38,10 +41,10 @@ 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));
+ CFXJSE_RuntimeData* pRuntimeData = reinterpret_cast<CFXJSE_RuntimeData*>(
+ pIsolate->GetData(kFXJSEEmbedderDataSlot));
if (pRuntimeData) {
- pIsolate->SetData(0, NULL);
+ pIsolate->SetData(kFXJSEEmbedderDataSlot, NULL);
delete pRuntimeData;
}
}
@@ -73,7 +76,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,13 +87,12 @@ 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));
+ CFXJSE_RuntimeData* pRuntimeData = static_cast<CFXJSE_RuntimeData*>(
+ pIsolate->GetData(kFXJSEEmbedderDataSlot));
if (!pRuntimeData) {
pRuntimeData = CFXJSE_RuntimeData::Create(pIsolate);
ASSERT(pRuntimeData);
- pIsolate->SetData(0, pRuntimeData);
+ pIsolate->SetData(kFXJSEEmbedderDataSlot, pRuntimeData);
}
return pRuntimeData;
}
« fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp ('K') | « fpdfsdk/src/jsapi/fxjs_v8.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698