| 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_isolatetracker.h" | 7 #include "fxjs/cfxjse_isolatetracker.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 CFXJSE_IsolateTracker::CFXJSE_IsolateTracker() {} | 11 CFXJSE_IsolateTracker::CFXJSE_IsolateTracker() {} |
| 12 | 12 |
| 13 CFXJSE_IsolateTracker::~CFXJSE_IsolateTracker() {} | 13 CFXJSE_IsolateTracker::~CFXJSE_IsolateTracker() {} |
| 14 | 14 |
| 15 void CFXJSE_IsolateTracker::Append(v8::Isolate* pIsolate) { | 15 void CFXJSE_IsolateTracker::Append( |
| 16 v8::Isolate* pIsolate, |
| 17 std::unique_ptr<v8::ArrayBuffer::Allocator> alloc) { |
| 16 m_OwnedIsolates.push_back(pIsolate); | 18 m_OwnedIsolates.push_back(pIsolate); |
| 19 m_AllocatorMap[pIsolate] = std::move(alloc); |
| 17 } | 20 } |
| 18 | 21 |
| 19 void CFXJSE_IsolateTracker::Remove( | 22 void CFXJSE_IsolateTracker::Remove( |
| 20 v8::Isolate* pIsolate, | 23 v8::Isolate* pIsolate, |
| 21 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { | 24 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { |
| 22 auto it = std::find(m_OwnedIsolates.begin(), m_OwnedIsolates.end(), pIsolate); | 25 auto it = std::find(m_OwnedIsolates.begin(), m_OwnedIsolates.end(), pIsolate); |
| 23 bool bFound = it != m_OwnedIsolates.end(); | 26 bool bFound = it != m_OwnedIsolates.end(); |
| 24 if (bFound) | 27 if (bFound) |
| 25 m_OwnedIsolates.erase(it); | 28 m_OwnedIsolates.erase(it); |
| 26 lpfnDisposeCallback(pIsolate, bFound); | 29 lpfnDisposeCallback(pIsolate, bFound); |
| 30 |
| 31 m_AllocatorMap.erase(pIsolate); |
| 27 } | 32 } |
| 28 | 33 |
| 29 void CFXJSE_IsolateTracker::RemoveAll( | 34 void CFXJSE_IsolateTracker::RemoveAll( |
| 30 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { | 35 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { |
| 31 for (v8::Isolate* pIsolate : m_OwnedIsolates) | 36 for (v8::Isolate* pIsolate : m_OwnedIsolates) |
| 32 lpfnDisposeCallback(pIsolate, true); | 37 lpfnDisposeCallback(pIsolate, true); |
| 33 | 38 |
| 34 m_OwnedIsolates.clear(); | 39 m_OwnedIsolates.clear(); |
| 40 m_AllocatorMap.clear(); |
| 35 } | 41 } |
| OLD | NEW |