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

Side by Side Diff: fpdfsdk/jsapi/fxjs_v8.cpp

Issue 1826223002: Revert "Preserve m_pDynamicObjsMap until FXJS_PerIsolateData is destroyed." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "fpdfsdk/include/jsapi/fxjs_v8.h" 7 #include "fpdfsdk/include/jsapi/fxjs_v8.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { 364 std::vector<v8::Global<v8::Object>*>* pStaticObjects) {
365 v8::Isolate::Scope isolate_scope(pIsolate); 365 v8::Isolate::Scope isolate_scope(pIsolate);
366 #ifdef PDF_ENABLE_XFA 366 #ifdef PDF_ENABLE_XFA
367 v8::Locker locker(pIsolate); 367 v8::Locker locker(pIsolate);
368 #endif // PDF_ENABLE_XFA 368 #endif // PDF_ENABLE_XFA
369 v8::HandleScope handle_scope(pIsolate); 369 v8::HandleScope handle_scope(pIsolate);
370 v8::Local<v8::Context> context = 370 v8::Local<v8::Context> context =
371 v8::Local<v8::Context>::New(pIsolate, *pV8PersistentContext); 371 v8::Local<v8::Context>::New(pIsolate, *pV8PersistentContext);
372 v8::Context::Scope context_scope(context); 372 v8::Context::Scope context_scope(context);
373 373
374 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate);
375 if (!pData)
376 return;
377 pData->ReleaseDynamicObjsMap();
378
374 int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); 379 int maxID = CFXJS_ObjDefinition::MaxID(pIsolate);
375 for (int i = 0; i < maxID; ++i) { 380 for (int i = 0; i < maxID; ++i) {
376 CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i); 381 CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i);
377 v8::Local<v8::Object> pObj; 382 v8::Local<v8::Object> pObj;
378 if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) { 383 if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) {
379 pObj = 384 pObj =
380 context->Global()->GetPrototype()->ToObject(context).ToLocalChecked(); 385 context->Global()->GetPrototype()->ToObject(context).ToLocalChecked();
381 } else if (pStaticObjects->at(i) && !pStaticObjects->at(i)->IsEmpty()) { 386 } else if (pStaticObjects->at(i) && !pStaticObjects->at(i)->IsEmpty()) {
382 pObj = v8::Local<v8::Object>::New(pIsolate, *pStaticObjects->at(i)); 387 pObj = v8::Local<v8::Object>::New(pIsolate, *pStaticObjects->at(i));
383 delete pStaticObjects->at(i); 388 delete pStaticObjects->at(i);
384 pStaticObjects->at(i) = nullptr; 389 pStaticObjects->at(i) = nullptr;
385 } 390 }
386 391
387 if (!pObj.IsEmpty()) { 392 if (!pObj.IsEmpty()) {
388 if (pObjDef->m_pDestructor) 393 if (pObjDef->m_pDestructor)
389 pObjDef->m_pDestructor(pObj); 394 pObjDef->m_pDestructor(pObj);
390 FXJS_FreePrivate(pObj); 395 FXJS_FreePrivate(pObj);
391 } 396 }
392 } 397 }
393 398
394 if (pIsolate == g_isolate && --g_isolate_ref_count > 0) 399 if (pIsolate == g_isolate && --g_isolate_ref_count > 0)
395 return; 400 return;
396 401
397 for (int i = 0; i < maxID; ++i) 402 for (int i = 0; i < maxID; ++i)
398 delete CFXJS_ObjDefinition::ForID(pIsolate, i); 403 delete CFXJS_ObjDefinition::ForID(pIsolate, i);
399 404
400 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); 405 pIsolate->SetData(g_embedderDataSlot, nullptr);
401 if (pData) { 406 delete pData;
402 pData->ReleaseDynamicObjsMap();
403 pIsolate->SetData(g_embedderDataSlot, nullptr);
404 delete pData;
405 }
406 } 407 }
407 408
408 IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate) { 409 IJS_Runtime* FXJS_GetRuntimeFromIsolate(v8::Isolate* pIsolate) {
409 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 410 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
410 return static_cast<IJS_Runtime*>( 411 return static_cast<IJS_Runtime*>(
411 context->GetAlignedPointerFromEmbedderData(kPerContextDataIndex)); 412 context->GetAlignedPointerFromEmbedderData(kPerContextDataIndex));
412 } 413 }
413 414
414 #ifdef PDF_ENABLE_XFA 415 #ifdef PDF_ENABLE_XFA
415 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, 416 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context,
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 v8::Local<v8::Value> pValue) { 814 v8::Local<v8::Value> pValue) {
814 if (pValue.IsEmpty()) 815 if (pValue.IsEmpty())
815 return v8::Local<v8::Array>(); 816 return v8::Local<v8::Array>();
816 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 817 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
817 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 818 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
818 } 819 }
819 820
820 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 821 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
821 pTo = pFrom; 822 pTo = pFrom;
822 } 823 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698