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 auto ret = m_AllocatorMap.find(pIsolate); | |
Lei Zhang
2016/08/19 18:28:58
Just: m_AllocatorMap.erase(pIsolate);
Wei Li
2016/08/19 21:09:10
Done.
| |
32 if (ret != m_AllocatorMap.end()) | |
33 m_AllocatorMap.erase(ret); | |
27 } | 34 } |
28 | 35 |
29 void CFXJSE_IsolateTracker::RemoveAll( | 36 void CFXJSE_IsolateTracker::RemoveAll( |
30 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { | 37 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { |
31 for (v8::Isolate* pIsolate : m_OwnedIsolates) | 38 for (v8::Isolate* pIsolate : m_OwnedIsolates) |
32 lpfnDisposeCallback(pIsolate, true); | 39 lpfnDisposeCallback(pIsolate, true); |
33 | 40 |
34 m_OwnedIsolates.clear(); | 41 m_OwnedIsolates.clear(); |
42 m_AllocatorMap.clear(); | |
35 } | 43 } |
OLD | NEW |