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

Unified Diff: runtime/vm/dart_api_state.h

Issue 9368049: Add external byte array API and finalize external strings and byte arrays. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address review comments Created 8 years, 10 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/vm/dart_api_impl_test.cc ('k') | runtime/vm/gc_marker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_state.h
diff --git a/runtime/vm/dart_api_state.h b/runtime/vm/dart_api_state.h
index 9badcc4fb9447228d1ad0ca6c148d081686b6f06..132077baaf6ad8a0dcd5e2aca891c4306461d61f 100644
--- a/runtime/vm/dart_api_state.h
+++ b/runtime/vm/dart_api_state.h
@@ -124,14 +124,20 @@ class WeakPersistentHandle {
static intptr_t raw_offset() { return OFFSET_OF(WeakPersistentHandle, raw_); }
void* peer() const { return peer_; }
void set_peer(void* peer) { peer_ = peer; }
- Dart_PeerFinalizer callback() const { return callback_; }
- void set_callback(Dart_PeerFinalizer callback) { callback_ = callback; }
+ Dart_WeakPersistentHandleFinalizer callback() const { return callback_; }
+ void set_callback(Dart_WeakPersistentHandleFinalizer callback) {
+ callback_ = callback;
+ }
- void Finalize() {
- if (callback_ != NULL) {
- (*callback_)(peer_);
+ static void Finalize(WeakPersistentHandle* handle) {
+ if (handle->callback() != NULL) {
+ Dart_WeakPersistentHandleFinalizer callback = handle->callback();
+ void* peer = handle->peer();
+ handle->Clear();
+ (*callback)(reinterpret_cast<Dart_Handle>(handle), peer);
+ } else {
+ handle->Clear();
}
- Clear();
}
private:
@@ -146,7 +152,7 @@ class WeakPersistentHandle {
return reinterpret_cast<WeakPersistentHandle*>(callback_);
}
void SetNext(WeakPersistentHandle* free_list) {
- callback_ = reinterpret_cast<Dart_PeerFinalizer>(free_list);
+ callback_ = reinterpret_cast<Dart_WeakPersistentHandleFinalizer>(free_list);
}
void FreeHandle(WeakPersistentHandle* free_list) {
raw_ = NULL;
@@ -161,7 +167,7 @@ class WeakPersistentHandle {
RawObject* raw_;
void* peer_;
- Dart_PeerFinalizer callback_;
+ Dart_WeakPersistentHandleFinalizer callback_;
DISALLOW_ALLOCATION(); // Allocated through AllocateHandle methods.
DISALLOW_COPY_AND_ASSIGN(WeakPersistentHandle);
};
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/gc_marker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698