org.chromium.sdk/src/org/chromium/sdk/DebugContext.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  * An object that matches the execution state of the browser JavaScript VM while
       
    14  * suspended. It reconstructs and provides access to the current state of the
       
    15  * JavaScript VM.
       
    16  */
       
    17 public interface DebugContext {
       
    18 
       
    19   /**
       
    20    * JavaScript debugger step actions.
       
    21    */
       
    22   public enum StepAction {
       
    23     /**
       
    24      * Resume the JavaScript execution.
       
    25      */
       
    26     CONTINUE,
       
    27 
       
    28     /**
       
    29      * Step into the current statement.
       
    30      */
       
    31     IN,
       
    32 
       
    33     /**
       
    34      * Step over the current statement.
       
    35      */
       
    36     OVER,
       
    37 
       
    38     /**
       
    39      * Step out of the current function.
       
    40      */
       
    41     OUT
       
    42   }
       
    43 
       
    44   /**
       
    45    * The suspension state.
       
    46    */
       
    47   public enum State {
       
    48     /**
       
    49      * A normal suspension (a step end or a breakpoint).
       
    50      */
       
    51     NORMAL,
       
    52 
       
    53     /**
       
    54      * A suspension due to an exception.
       
    55      */
       
    56     EXCEPTION
       
    57   }
       
    58 
       
    59   /**
       
    60    * A callback for the "continue" request.
       
    61    */
       
    62   interface ContinueCallback {
       
    63     void success();
       
    64 
       
    65     void failure(String errorMessage);
       
    66   }
       
    67 
       
    68   /**
       
    69    * @return the JavaScript VM suspension state
       
    70    */
       
    71   State getState();
       
    72 
       
    73   /**
       
    74    * @return the current exception state, or {@code null} if current state is
       
    75    *         not {@code EXCEPTION}
       
    76    * @see #getState()
       
    77    */
       
    78   ExceptionData getExceptionData();
       
    79 
       
    80   /**
       
    81    * @return a list of call frames for the current JavaScript suspended state
       
    82    * @throws MethodIsBlockingException if called from a callback because it may
       
    83    *         need to load necessary scripts
       
    84    */
       
    85   List<? extends CallFrame> getCallFrames();
       
    86 
       
    87   /**
       
    88    * @return a set of the breakpoints hit on VM suspension with which this
       
    89    *         context is associated. An empty collection if the suspension was
       
    90    *         not related to hitting breakpoints (e.g. a step end)
       
    91    */
       
    92   Collection<? extends Breakpoint> getBreakpointsHit();
       
    93 
       
    94   /**
       
    95    * Resumes the JavaScript VM execution using a "continue" request. This
       
    96    * context becomes invalid until another context is supplied through the
       
    97    * {@link DebugEventListener#suspended(DebugContext)} event.
       
    98    *
       
    99    * @param stepAction to perform
       
   100    * @param stepCount steps to perform (not used if
       
   101    *        {@code stepAction == CONTINUE})
       
   102    * @param callback to invoke when the request result is ready
       
   103    */
       
   104   void continueVm(StepAction stepAction, int stepCount, ContinueCallback callback);
       
   105 
       
   106 }