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

Side by Side Diff: fpdfsdk/src/jsapi/fxjs_v8.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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../core/include/fxcrt/fx_basic.h" 7 #include "../../../core/include/fxcrt/fx_basic.h"
8 #include "../../../core/include/fxcrt/fx_ext.h" 8 #include "../../../core/include/fxcrt/fx_ext.h"
9 #include "../../include/jsapi/fxjs_v8.h" 9 #include "../../include/jsapi/fxjs_v8.h"
10 #include "../../include/fsdk_define.h" 10 #include "../../include/fsdk_define.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 v8::Locker locker(pIsolate); 266 v8::Locker locker(pIsolate);
267 v8::HandleScope handle_scope(pIsolate); 267 v8::HandleScope handle_scope(pIsolate);
268 268
269 v8::Global<v8::ObjectTemplate>& globalObjTemp = 269 v8::Global<v8::ObjectTemplate>& globalObjTemp =
270 _getGlobalObjectTemplate(pIsolate); 270 _getGlobalObjectTemplate(pIsolate);
271 v8::Local<v8::Context> v8Context = v8::Context::New( 271 v8::Local<v8::Context> v8Context = v8::Context::New(
272 pIsolate, NULL, 272 pIsolate, NULL,
273 v8::Local<v8::ObjectTemplate>::New(pIsolate, globalObjTemp)); 273 v8::Local<v8::ObjectTemplate>::New(pIsolate, globalObjTemp));
274 v8::Context::Scope context_scope(v8Context); 274 v8::Context::Scope context_scope(v8Context);
275 275
276 // v8::Local<External> ptr = External::New(isolate, pFXRuntime);
277 // v8Context->SetEmbedderData(1, ptr);
278 // TODO(tsepez): Don't use more than one embedder data slot. 276 // TODO(tsepez): Don't use more than one embedder data slot.
279 pIsolate->SetData(2, pFXRuntime); 277 pIsolate->SetData(2, pFXRuntime);
280 278
281 CFX_PtrArray* pArray = (CFX_PtrArray*)pIsolate->GetData(g_embedderDataSlot); 279 CFX_PtrArray* pArray = (CFX_PtrArray*)pIsolate->GetData(g_embedderDataSlot);
282 if (!pArray) 280 if (!pArray)
283 return; 281 return;
284 282
285 for (int i = 0; i < pArray->GetSize(); i++) { 283 for (int i = 0; i < pArray->GetSize(); i++) {
286 CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i); 284 CJS_ObjDefintion* pObjDef = (CJS_ObjDefintion*)pArray->GetAt(i);
287 CFX_WideString ws = CFX_WideString(pObjDef->objName); 285 CFX_WideString ws = CFX_WideString(pObjDef->objName);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 v8::Local<v8::Object> pObj = 340 v8::Local<v8::Object> pObj =
343 v8::Local<v8::Object>::New(pIsolate, pObjDef->m_StaticObj); 341 v8::Local<v8::Object>::New(pIsolate, pObjDef->m_StaticObj);
344 if (pObjDef->m_pDestructor) 342 if (pObjDef->m_pDestructor)
345 pObjDef->m_pDestructor(pObj); 343 pObjDef->m_pDestructor(pObj);
346 JS_FreePrivate(pObj); 344 JS_FreePrivate(pObj);
347 } 345 }
348 delete pObjDef; 346 delete pObjDef;
349 } 347 }
350 delete pArray; 348 delete pArray;
351 349
352 pIsolate->SetData(1, NULL);
353 pIsolate->SetData(g_embedderDataSlot, NULL); 350 pIsolate->SetData(g_embedderDataSlot, NULL);
354 // TODO(tsepez): Don't use more than one embedder data slot. 351 // TODO(tsepez): Don't use more than one embedder data slot.
355 pIsolate->SetData(2, NULL); 352 pIsolate->SetData(2, NULL);
356 } 353 }
357 354
358 void JS_Initialize(unsigned int embedderDataSlot) { 355 void JS_Initialize(unsigned int embedderDataSlot) {
359 g_embedderDataSlot = embedderDataSlot; 356 g_embedderDataSlot = embedderDataSlot;
360 } 357 }
361 358
362 void JS_Release() { 359 void JS_Release() {
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 1107
1111 bool JS_PortIsNan(double d) { 1108 bool JS_PortIsNan(double d) {
1112 return d != d; 1109 return d != d;
1113 } 1110 }
1114 1111
1115 double JS_LocalTime(double d) { 1112 double JS_LocalTime(double d) {
1116 return JS_GetDateTime() + _getDaylightSavingTA(d); 1113 return JS_GetDateTime() + _getDaylightSavingTA(d);
1117 } 1114 }
1118 1115
1119 // JavaScript time implement End. 1116 // JavaScript time implement End.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698