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

Side by Side Diff: runtime/vm/dart_api_state.h

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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_DART_API_STATE_H_ 5 #ifndef VM_DART_API_STATE_H_
6 #define VM_DART_API_STATE_H_ 6 #define VM_DART_API_STATE_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 9
10 #include "platform/thread.h" 10 #include "platform/thread.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 273
274 FinalizablePersistentHandle() 274 FinalizablePersistentHandle()
275 : raw_(NULL), 275 : raw_(NULL),
276 peer_(NULL), 276 peer_(NULL),
277 external_data_(0), 277 external_data_(0),
278 callback_(NULL) { } 278 callback_(NULL) { }
279 ~FinalizablePersistentHandle() { } 279 ~FinalizablePersistentHandle() { }
280 280
281 static void Finalize(Isolate* isolate, 281 static void Finalize(Isolate* isolate,
282 FinalizablePersistentHandle* handle, 282 FinalizablePersistentHandle* handle,
283 bool is_prologue_weak) { 283 bool is_prologue_weak);
284 Dart_WeakPersistentHandleFinalizer callback = handle->callback();
285 if (callback != NULL) {
286 void* peer = handle->peer();
287 handle->Clear();
288 Dart_WeakPersistentHandle object = is_prologue_weak ?
289 handle->apiPrologueHandle() :
290 handle->apiHandle();
291 (*callback)(reinterpret_cast<Dart_Isolate>(isolate), object, peer);
292 } else {
293 handle->Clear();
294 }
295 }
296 284
297 // Overload the raw_ field as a next pointer when adding freed 285 // Overload the raw_ field as a next pointer when adding freed
298 // handles to the free list. 286 // handles to the free list.
299 FinalizablePersistentHandle* Next() { 287 FinalizablePersistentHandle* Next() {
300 return reinterpret_cast<FinalizablePersistentHandle*>(raw_); 288 return reinterpret_cast<FinalizablePersistentHandle*>(raw_);
301 } 289 }
302 void SetNext(FinalizablePersistentHandle* free_list) { 290 void SetNext(FinalizablePersistentHandle* free_list) {
303 raw_ = reinterpret_cast<RawObject*>(free_list); 291 raw_ = reinterpret_cast<RawObject*>(free_list);
304 ASSERT(!raw_->IsHeapObject()); 292 ASSERT(!raw_->IsHeapObject());
305 } 293 }
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 ApiNativeScope::Current()->zone()) {} 881 ApiNativeScope::Current()->zone()) {}
894 ApiGrowableArray() 882 ApiGrowableArray()
895 : BaseGrowableArray<T, ValueObject>( 883 : BaseGrowableArray<T, ValueObject>(
896 ApiNativeScope::Current()->zone()) {} 884 ApiNativeScope::Current()->zone()) {}
897 }; 885 };
898 886
899 887
900 } // namespace dart 888 } // namespace dart
901 889
902 #endif // VM_DART_API_STATE_H_ 890 #endif // VM_DART_API_STATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698