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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 197963002: Remove the ability to allow multiple gc prologue and gc epilogue callbacks (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/include/dart_api.h ('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 33620)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -768,14 +768,14 @@
Dart_GcPrologueCallback callback) {
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
- GcPrologueCallbacks& callbacks = isolate->gc_prologue_callbacks();
- if (callbacks.Contains(callback)) {
+ if (isolate->gc_prologue_callback() != NULL) {
return Api::NewError(
- "%s permits only one instance of 'callback' to be present in the "
- "prologue callback list.",
+ "%s permits only one gc prologue callback to be registered, please "
+ "remove the existing callback using Dart_RemoveGcPrologueCallback "
+ "and then add this callback",
CURRENT_FUNC);
}
- callbacks.Add(callback);
+ isolate->set_gc_prologue_callback(callback);
return Api::Success();
}
@@ -784,13 +784,13 @@
Dart_GcPrologueCallback callback) {
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
- GcPrologueCallbacks& callbacks = isolate->gc_prologue_callbacks();
- if (!callbacks.Contains(callback)) {
+ if (isolate->gc_prologue_callback() != callback) {
return Api::NewError(
- "%s expects 'callback' to be present in the prologue callback list.",
+ "%s expects 'callback' to be the currently registered gc prologue "
+ "callback.",
CURRENT_FUNC);
}
- callbacks.Remove(callback);
+ isolate->set_gc_prologue_callback(NULL);
return Api::Success();
}
@@ -799,14 +799,14 @@
Dart_GcEpilogueCallback callback) {
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
- GcEpilogueCallbacks& callbacks = isolate->gc_epilogue_callbacks();
- if (callbacks.Contains(callback)) {
+ if (isolate->gc_epilogue_callback() != NULL) {
return Api::NewError(
- "%s permits only one instance of 'callback' to be present in the "
- "epilogue callback list.",
+ "%s permits only one gc epilogue callback to be registered, please "
+ "remove the existing callback using Dart_RemoveGcEpilogueCallback "
+ "and then add this callback",
CURRENT_FUNC);
}
- callbacks.Add(callback);
+ isolate->set_gc_epilogue_callback(callback);
return Api::Success();
}
@@ -815,17 +815,56 @@
Dart_GcEpilogueCallback callback) {
Isolate* isolate = Isolate::Current();
CHECK_ISOLATE(isolate);
- GcEpilogueCallbacks& callbacks = isolate->gc_epilogue_callbacks();
- if (!callbacks.Contains(callback)) {
+ if (isolate->gc_epilogue_callback() != callback) {
return Api::NewError(
- "%s expects 'callback' to be present in the epilogue callback list.",
+ "%s expects 'callback' to be the currently registered gc epilogue "
+ " callback.",
CURRENT_FUNC);
}
- callbacks.Remove(callback);
+ isolate->set_gc_epilogue_callback(NULL);
return Api::Success();
}
+DART_EXPORT Dart_Handle Dart_SetGcCallbacks(
+ Dart_GcPrologueCallback prologue_callback,
+ Dart_GcEpilogueCallback epilogue_callback) {
+ Isolate* isolate = Isolate::Current();
+ CHECK_ISOLATE(isolate);
+ if (prologue_callback != NULL) {
+ if (isolate->gc_prologue_callback() != NULL) {
+ return Api::NewError(
+ "%s permits only one gc prologue callback to be registered, please "
+ "remove the existing callback and then add this callback",
+ CURRENT_FUNC);
+ }
+ } else {
+ if (isolate->gc_prologue_callback() == NULL) {
+ return Api::NewError(
+ "%s expects 'prologue_callback' to be present in the callback set.",
+ CURRENT_FUNC);
+ }
+ }
+ if (epilogue_callback != NULL) {
+ if (isolate->gc_epilogue_callback() != NULL) {
+ return Api::NewError(
+ "%s permits only one gc epilogue callback to be registered, please "
+ "remove the existing callback and then add this callback",
+ CURRENT_FUNC);
+ }
+ } else {
+ if (isolate->gc_epilogue_callback() == NULL) {
+ return Api::NewError(
+ "%s expects 'epilogue_callback' to be present in the callback set.",
+ CURRENT_FUNC);
+ }
+ }
+ isolate->set_gc_prologue_callback(prologue_callback);
+ isolate->set_gc_epilogue_callback(epilogue_callback);
+ return Api::Success();
+}
+
+
// --- Initialization and Globals ---
DART_EXPORT const char* Dart_VersionString() {
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698