Add API for adding and removing CallCompletedCallbacks to Isolate
authorjochen@chromium.org <jochen@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 3 Apr 2014 07:51:27 +0000 (07:51 +0000)
committerjochen@chromium.org <jochen@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 3 Apr 2014 07:51:27 +0000 (07:51 +0000)
The API currently just forwards to the global methods. A follow-up
change will move the callback handling to the Isolate and deprecate the
global versions.

BUG=
R=dcarney@chromium.org, svenpanne@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/215893005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20463 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

include/v8.h
src/api.cc

index f0dd0e1..b1ec504 100644 (file)
@@ -4428,6 +4428,20 @@ class V8_EXPORT Isolate {
    */
   void SetEventLogger(LogEventCallback that);
 
+  /**
+   * Adds a callback to notify the host application when a script finished
+   * running.  If a script re-enters the runtime during executing, the
+   * CallCompletedCallback is only invoked when the outer-most script
+   * execution ends.  Executing scripts inside the callback do not trigger
+   * further callbacks.
+   */
+  void AddCallCompletedCallback(CallCompletedCallback callback);
+
+  /**
+   * Removes callback that was installed by AddCallCompletedCallback.
+   */
+  void RemoveCallCompletedCallback(CallCompletedCallback callback);
+
  private:
   template<class K, class V, class Traits> friend class PersistentValueMap;
 
@@ -4795,11 +4809,15 @@ class V8_EXPORT V8 {
    * CallCompletedCallback is only invoked when the outer-most script
    * execution ends.  Executing scripts inside the callback do not trigger
    * further callbacks.
+   *
+   * Will be deprecated soon. Use Isolate::AddCallCompletedCallback.
    */
   static void AddCallCompletedCallback(CallCompletedCallback callback);
 
   /**
    * Removes callback that was installed by AddCallCompletedCallback.
+   *
+   * Will be deprecated soon. Use Isolate::RemoveCallCompletedCallback.
    */
   static void RemoveCallCompletedCallback(CallCompletedCallback callback);
 
index 34a431d..1386a3a 100644 (file)
@@ -6684,6 +6684,20 @@ void Isolate::SetEventLogger(LogEventCallback that) {
   isolate->set_event_logger(that);
 }
 
+
+void Isolate::AddCallCompletedCallback(CallCompletedCallback callback) {
+  if (callback == NULL) return;
+  // TODO(jochen): Make this per isolate.
+  i::V8::AddCallCompletedCallback(callback);
+}
+
+
+void Isolate::RemoveCallCompletedCallback(CallCompletedCallback callback) {
+  // TODO(jochen): Make this per isolate.
+  i::V8::RemoveCallCompletedCallback(callback);
+}
+
+
 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
     : str_(NULL), length_(0) {
   i::Isolate* isolate = i::Isolate::Current();