Chromium Code Reviews| Index: Source/WebCore/bindings/dart/DartIsolate.cpp |
| diff --git a/Source/WebCore/bindings/dart/DartIsolate.cpp b/Source/WebCore/bindings/dart/DartIsolate.cpp |
| index 190ce1bed2935212e56b8d46f9522bd9e61de322..7609f032b9bab80034e92f9987a2f23b469e7ce5 100644 |
| --- a/Source/WebCore/bindings/dart/DartIsolate.cpp |
| +++ b/Source/WebCore/bindings/dart/DartIsolate.cpp |
| @@ -30,7 +30,8 @@ |
| #include "config.h" |
| #include "DartIsolate.h" |
| -#include "DartController.h" |
| +#include "DartDebugServer.h" |
| +#include "DartUtilities.h" |
| namespace WebCore { |
| @@ -80,9 +81,24 @@ DartIsolate::DartIsolate(Dart_Isolate isolate) |
| DartIsolate::~DartIsolate() |
| { |
| - DartController::shutdownIsolate(this); |
| + Dart_Isolate currentIsolate = Dart_CurrentIsolate(); |
| + if (currentIsolate) |
| + Dart_ExitIsolate(); |
| + |
| + Dart_EnterIsolate(m_isolate); |
| + for (WeakCallbackMap::iterator it = m_weakCallbackMap.begin(); it != m_weakCallbackMap.end(); ++it) |
| + (*it->second.weakCallback)(it->first, it->second.peer); |
| + Dart_ShutdownIsolate(); |
| + |
| + *DartUtilities::recursionForIsolate(m_isolate) = 0; |
| + DartUtilities::unregisterIsolate(m_isolate); |
| + DartDebugServer::shared().unregisterIsolate(this); |
| + |
| isolateMap().remove(m_isolate); |
| m_isolate = 0; |
| + |
| + if (currentIsolate) |
| + Dart_EnterIsolate(currentIsolate); |
| } |
| PassRefPtr<DartIsolate> DartIsolate::current() |
| @@ -119,4 +135,21 @@ void DartIsolate::exit() |
| Dart_EnterIsolate(previous->m_isolate); |
| } |
| +Dart_Handle DartIsolate::createWeakPersistentHandle(Dart_Handle object, void* peer, Dart_WeakPersistentHandleFinalizer weakCallback) |
| +{ |
| + Dart_Handle persistentHandle = Dart_NewWeakPersistentHandle(object, peer, &DartIsolate::weakCallbackWrapper); |
|
Anton Muhin
2012/03/28 18:03:23
as another option which might be more natural: as
podivilov
2012/03/28 18:20:05
That would require creating the Peer in the heap a
Anton Muhin
2012/03/28 18:25:54
What's the problem w/ it? Allocating small object
|
| + ASSERT(!m_weakCallbackMap.contains(persistentHandle)); |
| + m_weakCallbackMap.set(persistentHandle, WeakCallbackData(peer, weakCallback)); |
| + return persistentHandle; |
| +} |
| + |
| +void DartIsolate::weakCallbackWrapper(Dart_Handle persistentHandle, void* peer) |
| +{ |
| + DartIsolate* isolate = current().get(); |
| + ASSERT(isolate->m_weakCallbackMap.contains(persistentHandle)); |
| + WeakCallbackData weakCallbackData = isolate->m_weakCallbackMap.take(persistentHandle); |
| + ASSERT(weakCallbackData.peer == peer); |
| + (*weakCallbackData.weakCallback)(persistentHandle, peer); |
|
Anton Muhin
2012/03/28 18:03:23
you allow 0 weak callback in ctor, so check here a
podivilov
2012/03/28 18:20:05
0 is not allowed. Default ctor is used for denotin
|
| +} |
| + |
| } |