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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 205153002: Auto delete persistent weak handles during finalization after invoking the callback associated with… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
« no previous file with comments | « runtime/lib/typed_data.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 34115)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -371,6 +371,27 @@
}
+void FinalizablePersistentHandle::Finalize(Isolate* isolate,
+ FinalizablePersistentHandle* handle,
+ bool is_prologue_weak) {
+ Dart_WeakPersistentHandleFinalizer callback = handle->callback();
+ if (callback != NULL) {
Ivan Posva 2014/03/19 23:08:14 How can the callback be NULL, I thought it was a r
siva 2014/03/20 20:05:32 good point changed that to an assert ASSERT(callba
+ void* peer = handle->peer();
+ Dart_WeakPersistentHandle object = is_prologue_weak ?
+ handle->apiPrologueHandle() :
+ handle->apiHandle();
+ (*callback)(isolate->init_callback_data(), object, peer);
+ }
+ ApiState* state = isolate->api_state();
+ ASSERT(state != NULL);
+ if (is_prologue_weak) {
+ state->prologue_weak_persistent_handles().FreeHandle(handle);
+ } else {
+ state->weak_persistent_handles().FreeHandle(handle);
+ }
+}
+
+
// --- Handles ---
DART_EXPORT bool Dart_IsError(Dart_Handle handle) {
« no previous file with comments | « runtime/lib/typed_data.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698