| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "fxjs/cfxjse_runtimedata.h" | 7 #include "fxjs/cfxjse_runtimedata.h" |
| 8 | 8 |
| 9 #include "fxjs/cfxjse_isolatetracker.h" | 9 #include "fxjs/cfxjse_isolatetracker.h" |
| 10 #include "fxjs/include/fxjs_v8.h" | 10 #include "fxjs/include/fxjs_v8.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 void FXJSE_Finalize() { | 49 void FXJSE_Finalize() { |
| 50 if (!CFXJSE_IsolateTracker::g_pInstance) | 50 if (!CFXJSE_IsolateTracker::g_pInstance) |
| 51 return; | 51 return; |
| 52 | 52 |
| 53 CFXJSE_IsolateTracker::g_pInstance->RemoveAll(Runtime_DisposeCallback); | 53 CFXJSE_IsolateTracker::g_pInstance->RemoveAll(Runtime_DisposeCallback); |
| 54 delete CFXJSE_IsolateTracker::g_pInstance; | 54 delete CFXJSE_IsolateTracker::g_pInstance; |
| 55 CFXJSE_IsolateTracker::g_pInstance = nullptr; | 55 CFXJSE_IsolateTracker::g_pInstance = nullptr; |
| 56 } | 56 } |
| 57 | 57 |
| 58 v8::Isolate* FXJSE_Runtime_Create_Own() { | 58 v8::Isolate* FXJSE_Runtime_Create_Own() { |
| 59 std::unique_ptr<v8::ArrayBuffer::Allocator> allocator( |
| 60 new FXJSE_ArrayBufferAllocator()); |
| 59 v8::Isolate::CreateParams params; | 61 v8::Isolate::CreateParams params; |
| 60 params.array_buffer_allocator = new FXJSE_ArrayBufferAllocator(); | 62 params.array_buffer_allocator = allocator.get(); |
| 61 v8::Isolate* pIsolate = v8::Isolate::New(params); | 63 v8::Isolate* pIsolate = v8::Isolate::New(params); |
| 62 ASSERT(pIsolate && CFXJSE_IsolateTracker::g_pInstance); | 64 ASSERT(pIsolate && CFXJSE_IsolateTracker::g_pInstance); |
| 63 CFXJSE_IsolateTracker::g_pInstance->Append(pIsolate); | 65 CFXJSE_IsolateTracker::g_pInstance->Append(pIsolate, std::move(allocator)); |
| 64 return pIsolate; | 66 return pIsolate; |
| 65 } | 67 } |
| 66 | 68 |
| 67 void FXJSE_Runtime_Release(v8::Isolate* pIsolate) { | 69 void FXJSE_Runtime_Release(v8::Isolate* pIsolate) { |
| 68 if (!pIsolate) | 70 if (!pIsolate) |
| 69 return; | 71 return; |
| 70 CFXJSE_IsolateTracker::g_pInstance->Remove(pIsolate, Runtime_DisposeCallback); | 72 CFXJSE_IsolateTracker::g_pInstance->Remove(pIsolate, Runtime_DisposeCallback); |
| 71 } | 73 } |
| 72 | 74 |
| 73 CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate) | 75 CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 96 | 98 |
| 97 CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) { | 99 CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) { |
| 98 FXJS_PerIsolateData::SetUp(pIsolate); | 100 FXJS_PerIsolateData::SetUp(pIsolate); |
| 99 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); | 101 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); |
| 100 if (!pData->m_pFXJSERuntimeData) | 102 if (!pData->m_pFXJSERuntimeData) |
| 101 pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate); | 103 pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate); |
| 102 return pData->m_pFXJSERuntimeData; | 104 return pData->m_pFXJSERuntimeData; |
| 103 } | 105 } |
| 104 | 106 |
| 105 CFXJSE_IsolateTracker* CFXJSE_IsolateTracker::g_pInstance = nullptr; | 107 CFXJSE_IsolateTracker* CFXJSE_IsolateTracker::g_pInstance = nullptr; |
| OLD | NEW |