Reviewers: Sven Panne,

Message:
ptal

Description:
Add API for adding and removing CallCompletedCallbacks to Isolate

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=
[email protected]
LOG=n

Please review this at https://codereview.chromium.org/215893005/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+32, -0 lines):
  M include/v8.h
  M src/api.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index f0dd0e13488ed4d2fc602d50b43e0220f192da44..b1ec504031cdf0fdf2401734caedd6327044d6c1 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -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: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 34a431d9b748846dc38768cb2298e1b75b45e30c..1386a3a0a2b7787dbcf2c71e6ca0d49ffbe6faac 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -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();


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to