Index: src/isolate.cc |
diff --git a/src/isolate.cc b/src/isolate.cc |
index 9a5bc5ad43b16e9bc7fabb2fe07cf06bee7b858c..bb15243496db2991dc293de1778cb81cb3402d8c 100644 |
--- a/src/isolate.cc |
+++ b/src/isolate.cc |
@@ -2256,4 +2256,37 @@ Handle<JSObject> Isolate::GetSymbolRegistry() { |
} |
+void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) { |
+ for (int i = 0; i < call_completed_callbacks_.length(); i++) { |
+ if (callback == call_completed_callbacks_.at(i)) return; |
+ } |
+ call_completed_callbacks_.Add(callback); |
+} |
+ |
+ |
+void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) { |
+ for (int i = 0; i < call_completed_callbacks_.length(); i++) { |
+ if (callback == call_completed_callbacks_.at(i)) { |
+ call_completed_callbacks_.Remove(i); |
+ } |
+ } |
+} |
+ |
+ |
+void Isolate::FireCallCompletedCallback() { |
+ bool has_call_completed_callbacks = !call_completed_callbacks_.is_empty(); |
+ bool run_microtasks = autorun_microtasks() && microtask_pending(); |
+ if (!has_call_completed_callbacks && !run_microtasks) return; |
+ |
+ if (!handle_scope_implementer()->CallDepthIsZero()) return; |
Sven Panne
2014/04/24 07:08:21
This code has just moved, but nevertheless: I don'
Yang
2014/04/24 07:16:38
Agree. This should just be moved into the isolate.
|
+ // Fire callbacks. Increase call depth to prevent recursive callbacks. |
+ handle_scope_implementer()->IncrementCallDepth(); |
+ if (run_microtasks) Execution::RunMicrotasks(this); |
+ for (int i = 0; i < call_completed_callbacks_.length(); i++) { |
+ call_completed_callbacks_.at(i)(); |
+ } |
+ handle_scope_implementer()->DecrementCallDepth(); |
+} |
+ |
+ |
} } // namespace v8::internal |