org.chromium.sdk/src/org/chromium/sdk/CallFrame.java
changeset 2 e4420d2515f1
child 52 f577ea64429e
equal deleted inserted replaced
1:ef76fc2ac88c 2:e4420d2515f1
       
     1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
       
     2 // Use of this source code is governed by a BSD-style license that can be
       
     3 // found in the LICENSE file.
       
     4 
       
     5 package org.chromium.sdk;
       
     6 
       
     7 import java.util.Collection;
       
     8 import java.util.List;
       
     9 
       
    10 import org.chromium.sdk.internal.tools.v8.MethodIsBlockingException;
       
    11 
       
    12 
       
    13 /**
       
    14  * An object that represents a browser JavaScript VM call frame.
       
    15  */
       
    16 public interface CallFrame {
       
    17 
       
    18   /**
       
    19    * A callback for the "evaluate" request.
       
    20    */
       
    21   interface EvaluateCallback {
       
    22     void success(JsVariable variable);
       
    23 
       
    24     void failure(String errorMessage);
       
    25   }
       
    26 
       
    27   /**
       
    28    * @return the variables known in this frame, including the receiver variable
       
    29    * @deprecated in favor of {@link #getVariableScopes()}
       
    30    */
       
    31   @Deprecated
       
    32   Collection<? extends JsVariable> getVariables();
       
    33 
       
    34   /**
       
    35    * @return the scopes known in this frame; ordered, innermost first, global scope last
       
    36    */
       
    37   List<? extends JsScope> getVariableScopes();
       
    38 
       
    39   /**
       
    40    * @return the receiver variable known in this frame
       
    41    */
       
    42   JsVariable getReceiverVariable();
       
    43 
       
    44   /**
       
    45    * @return the current line number in the Script corresponding to this frame
       
    46    *         (0-based) or {@code -1} if unknown
       
    47    */
       
    48   int getLineNumber();
       
    49 
       
    50   /**
       
    51    * @return the start character position in the line corresponding to the
       
    52    *         current statement of this frame or {@code -1} if unknown
       
    53    */
       
    54   int getCharStart();
       
    55 
       
    56   /**
       
    57    * @return the end character position in the line corresponding to the current
       
    58    *         statement of this frame or {@code -1} if unknown
       
    59    */
       
    60   int getCharEnd();
       
    61 
       
    62   /**
       
    63    * @return the source script this call frame is associated with. {@code null}
       
    64    *         if no script is associated with the call frame (e.g. an exception
       
    65    *         could have been thrown in a native script)
       
    66    */
       
    67   Script getScript();
       
    68 
       
    69   /**
       
    70    * @return the name of the current function of this frame
       
    71    */
       
    72   String getFunctionName();
       
    73 
       
    74   /**
       
    75    * Synchronously evaluates an arbitrary JavaScript {@code expression} in
       
    76    * the context of the call frame. The evaluation result is reported to
       
    77    * the specified {@code evaluateCallback}. The method will block until the evaluation
       
    78    * result is available.
       
    79    *
       
    80    * @param expression to evaluate
       
    81    * @param evaluateCallback to report the evaluation result to
       
    82    * @throws MethodIsBlockingException if called from a callback because it blocks
       
    83    *         until remote VM returns result
       
    84    */
       
    85   void evaluateSync(String expression, EvaluateCallback evaluateCallback)
       
    86       throws MethodIsBlockingException;
       
    87 
       
    88   /**
       
    89    * Asynchronously evaluates an arbitrary JavaScript {@code expression} in
       
    90    * the context of the call frame. The evaluation result is reported to
       
    91    * the specified {@code evaluateCallback} and right after this to syncCallback.
       
    92    * The method doesn't block.
       
    93    *
       
    94    * @param expression to evaluate
       
    95    * @param evaluateCallback to report the evaluation result to
       
    96    * @param syncCallback to report the end of any processing
       
    97    */
       
    98   void evaluateAsync(String expression, EvaluateCallback evaluateCallback,
       
    99       SyncCallback syncCallback);
       
   100 }