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

Unified Diff: Source/WebCore/bindings/dart/DartIsolate.cpp

Issue 9837116: DOM wrappers that are not retained from Dart should be collected. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
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
+}
+
}

Powered by Google App Engine
This is Rietveld 408576698