OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2010-2014 Google Inc. All rights reserved. |
| 4 * |
| 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions |
| 7 * are met: |
| 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. |
| 11 * 2. Redistributions in binary form must reproduce the above copyright |
| 12 * notice, this list of conditions and the following disclaimer in the |
| 13 * documentation and/or other materials provided with the distribution. |
| 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of |
| 15 * its contributors may be used to endorse or promote products derived |
| 16 * from this software without specific prior written permission. |
| 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ |
| 29 |
| 30 #ifndef DartInspectorDebuggerAgent_h |
| 31 #define DartInspectorDebuggerAgent_h |
| 32 |
| 33 #include "bindings/common/ScriptState.h" |
| 34 #include "bindings/core/dart/DartInjectedScript.h" |
| 35 #include "bindings/core/dart/DartInjectedScriptManager.h" |
| 36 #include "bindings/core/dart/DartScriptDebugListener.h" |
| 37 #include "core/InspectorFrontend.h" |
| 38 #include "core/frame/ConsoleTypes.h" |
| 39 #include "core/inspector/ConsoleAPITypes.h" |
| 40 #include "core/inspector/InspectorBaseAgent.h" |
| 41 #include "core/inspector/ScriptBreakpoint.h" |
| 42 #include "wtf/Forward.h" |
| 43 #include "wtf/HashMap.h" |
| 44 #include "wtf/PassRefPtr.h" |
| 45 #include "wtf/Vector.h" |
| 46 #include "wtf/text/StringHash.h" |
| 47 |
| 48 namespace blink { |
| 49 |
| 50 class Document; |
| 51 class Event; |
| 52 class EventListener; |
| 53 class EventTarget; |
| 54 class ExecutionContextTask; |
| 55 class FormData; |
| 56 class HTTPHeaderMap; |
| 57 class InspectorFrontend; |
| 58 class InstrumentingAgents; |
| 59 class JavaScriptCallFrame; |
| 60 class JSONObject; |
| 61 class KURL; |
| 62 class MutationObserver; |
| 63 class ScriptArguments; |
| 64 class ScriptAsyncCallStack; |
| 65 class ScriptCallStack; |
| 66 class ScriptCallFrame; |
| 67 class DartScriptDebugServer; |
| 68 class ScriptRegexp; |
| 69 class ScriptSourceCode; |
| 70 class ScriptValue; |
| 71 class ThreadableLoaderClient; |
| 72 class XMLHttpRequest; |
| 73 class InspectorDebuggerAgent; |
| 74 |
| 75 typedef String ErrorString; |
| 76 |
| 77 class DartInspectorDebuggerAgent : public DartScriptDebugListener { |
| 78 WTF_MAKE_NONCOPYABLE(DartInspectorDebuggerAgent); |
| 79 public: |
| 80 enum BreakpointSource { |
| 81 UserBreakpointSource, |
| 82 DebugCommandBreakpointSource, |
| 83 MonitorCommandBreakpointSource |
| 84 }; |
| 85 explicit DartInspectorDebuggerAgent(DartInjectedScriptManager*, InspectorDeb
uggerAgent*, InspectorPageAgent*); |
| 86 |
| 87 static const char backtraceObjectGroup[]; |
| 88 |
| 89 ~DartInspectorDebuggerAgent(); |
| 90 virtual void canSetScriptSource(ErrorString*, bool* result) FINAL { *result
= true; } |
| 91 |
| 92 virtual void init() FINAL; |
| 93 virtual void setFrontend(InspectorFrontend*) FINAL; |
| 94 virtual void clearFrontend() FINAL; |
| 95 virtual void restore() FINAL; |
| 96 |
| 97 bool isPaused(); |
| 98 bool runningNestedMessageLoop(); |
| 99 |
| 100 // Part of the protocol. |
| 101 virtual void enable(ErrorString*) FINAL; |
| 102 virtual void disable(ErrorString*) FINAL; |
| 103 virtual void setBreakpointsActive(ErrorString*, bool active) FINAL; |
| 104 virtual void setSkipAllPauses(ErrorString*, bool skipped, const bool* untilR
eload) FINAL; |
| 105 |
| 106 virtual void setBreakpointByUrl(ErrorString*, int lineNumber, const String*
optionalURL, const String* optionalURLRegex, const int* optionalColumnNumber, co
nst String* optionalCondition, const bool* isAntiBreakpoint, TypeBuilder::Debugg
er::BreakpointId*, RefPtr<TypeBuilder::Array<TypeBuilder::Debugger::Location> >&
locations) FINAL; |
| 107 virtual void setBreakpoint(ErrorString*, const RefPtr<JSONObject>& location,
const String* optionalCondition, TypeBuilder::Debugger::BreakpointId*, RefPtr<T
ypeBuilder::Debugger::Location>& actualLocation) FINAL; |
| 108 virtual void removeBreakpoint(ErrorString*, const String& breakpointId) FINA
L; |
| 109 virtual void continueToLocation(ErrorString*, const RefPtr<JSONObject>& loca
tion, const bool* interstateLocationOpt) FINAL; |
| 110 virtual void getBacktrace(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilde
r::Debugger::CallFrame> >&, RefPtr<TypeBuilder::Debugger::StackTrace>&) FINAL; |
| 111 |
| 112 virtual void searchInContent(ErrorString*, const String& scriptId, const Str
ing& query, const bool* optionalCaseSensitive, const bool* optionalIsRegex, RefP
tr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> >&) FINAL; |
| 113 virtual void getScriptSource(ErrorString*, const String& scriptId, String* s
criptSource) FINAL; |
| 114 virtual void getFunctionDetails(ErrorString*, const String& functionId, RefP
tr<TypeBuilder::Debugger::FunctionDetails>&) FINAL; |
| 115 virtual void pause(ErrorString*) FINAL; |
| 116 virtual void resume(ErrorString*) FINAL; |
| 117 virtual void stepOver(ErrorString*) FINAL; |
| 118 virtual void stepInto(ErrorString*) FINAL; |
| 119 virtual void stepOut(ErrorString*) FINAL; |
| 120 virtual void setPauseOnExceptions(ErrorString*, const String& pauseState) FI
NAL; |
| 121 virtual void evaluateOnCallFrame(ErrorString*, |
| 122 const String& callFrameId, |
| 123 const String& expression, |
| 124 const String* objectGroup, |
| 125 const bool* includeCommandLineAPI, |
| 126 const bool* doNotPauseOnExceptionsAndMuteConsole, |
| 127 const bool* returnByValue, |
| 128 const bool* generatePreview, |
| 129 RefPtr<TypeBuilder::Runtime::RemoteObject>& result, |
| 130 TypeBuilder::OptOutput<bool>* wasThrown, |
| 131 RefPtr<TypeBuilder::Debugger::ExceptionDetails>&) FINAL; |
| 132 virtual void getCompletionsOnCallFrame(ErrorString*, |
| 133 const String& callFrameId, |
| 134 const String& expression, |
| 135 RefPtr<TypeBuilder::Array<String> >& result) FINAL; |
| 136 virtual void setOverlayMessage(ErrorString*, const String*); |
| 137 virtual void setVariableValue(ErrorString*, int in_scopeNumber, const String
& in_variableName, const RefPtr<JSONObject>& in_newValue, const String* in_callF
rame, const String* in_functionObjectId) FINAL; |
| 138 virtual void skipStackFrames(ErrorString*, const String* pattern) FINAL; |
| 139 |
| 140 void schedulePauseOnNextStatement(InspectorFrontend::Debugger::Reason::Enum
breakReason, PassRefPtr<JSONObject> data); |
| 141 bool canBreakProgram(); |
| 142 void breakProgram(InspectorFrontend::Debugger::Reason::Enum breakReason, Pas
sRefPtr<JSONObject> data); |
| 143 void scriptExecutionBlockedByCSP(const String& directiveText); |
| 144 |
| 145 class Listener : public WillBeGarbageCollectedMixin { |
| 146 public: |
| 147 virtual ~Listener() { } |
| 148 virtual void debuggerWasEnabled() = 0; |
| 149 virtual void debuggerWasDisabled() = 0; |
| 150 virtual void stepInto() = 0; |
| 151 virtual void didPause() = 0; |
| 152 }; |
| 153 void setListener(Listener* listener) { m_listener = listener; } |
| 154 |
| 155 bool enabled(); |
| 156 |
| 157 virtual DartScriptDebugServer& scriptDebugServer() = 0; |
| 158 |
| 159 void setBreakpoint(const String& scriptId, int lineNumber, int columnNumber,
BreakpointSource, const String& condition = String()); |
| 160 void removeBreakpoint(const String& scriptId, int lineNumber, int columnNumb
er, BreakpointSource); |
| 161 |
| 162 PassRefPtrWillBeRawPtr<ScriptAsyncCallStack> currentAsyncStackTraceForConsol
e(); |
| 163 |
| 164 bool isDartScriptId(const String& scriptId); |
| 165 bool isDartURL(const String* const optionalURL, const String* const optional
URLRegex); |
| 166 |
| 167 void pageDidCommitLoad(); |
| 168 |
| 169 protected: |
| 170 |
| 171 virtual void startListeningScriptDebugServer() = 0; |
| 172 virtual void stopListeningScriptDebugServer() = 0; |
| 173 virtual void muteConsole() = 0; |
| 174 virtual void unmuteConsole() = 0; |
| 175 DartInjectedScriptManager* injectedScriptManager() { return m_injectedScript
Manager; } |
| 176 virtual DartInjectedScript* injectedScriptForEval(ErrorString*, const int* e
xecutionContextId) = 0; |
| 177 |
| 178 virtual void enable(); |
| 179 virtual void disable(); |
| 180 virtual SkipPauseRequest didPause(ScriptState*, Dart_StackTrace callFrames,
const ScriptValue& exception, const Vector<String>& hitBreakpoints) FINAL; |
| 181 virtual void didContinue() FINAL; |
| 182 void reset(); |
| 183 |
| 184 protected: |
| 185 SkipPauseRequest shouldSkipExceptionPause(); |
| 186 SkipPauseRequest shouldSkipStepPause(); |
| 187 bool isTopCallFrameInFramework(); |
| 188 |
| 189 void cancelPauseOnNextStatement(); |
| 190 void addMessageToConsole(MessageSource, MessageType); |
| 191 |
| 192 PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> > currentCal
lFrames(); |
| 193 |
| 194 virtual void didParseSource(const String& scriptId, const Script&, CompileRe
sult) FINAL; |
| 195 |
| 196 void setPauseOnExceptionsImpl(ErrorString*, int); |
| 197 |
| 198 PassRefPtr<TypeBuilder::Debugger::Location> resolveBreakpoint(const String&
breakpointId, const String& scriptId, const ScriptBreakpoint&, BreakpointSource)
; |
| 199 void removeBreakpoint(const String& breakpointId); |
| 200 void clear(); |
| 201 bool assertPaused(ErrorString*); |
| 202 void clearBreakDetails(); |
| 203 |
| 204 String sourceMapURLForScript(const Script&, CompileResult); |
| 205 |
| 206 ScriptCallFrame topCallFrameSkipUnknownSources(); |
| 207 |
| 208 InspectorState* state(); |
| 209 |
| 210 typedef HashMap<String, Script> ScriptsMap; |
| 211 typedef HashMap<String, Vector<String> > BreakpointIdToDebugServerBreakpoint
IdsMap; |
| 212 typedef HashMap<String, std::pair<String, BreakpointSource> > DebugServerBre
akpointToBreakpointIdAndSourceMap; |
| 213 |
| 214 DartInjectedScriptManager* m_injectedScriptManager; |
| 215 InspectorFrontend::Debugger* m_frontend; |
| 216 RefPtr<ScriptState> m_pausedScriptState; |
| 217 Dart_StackTrace m_currentCallStack; |
| 218 ScriptsMap m_scripts; |
| 219 BreakpointIdToDebugServerBreakpointIdsMap m_breakpointIdToDebugServerBreakpo
intIds; |
| 220 DebugServerBreakpointToBreakpointIdAndSourceMap m_serverBreakpoints; |
| 221 String m_continueToLocationBreakpointId; |
| 222 InspectorFrontend::Debugger::Reason::Enum m_breakReason; |
| 223 RefPtr<JSONObject> m_breakAuxData; |
| 224 bool m_javaScriptPauseScheduled; |
| 225 bool m_debuggerStepScheduled; |
| 226 bool m_steppingFromFramework; |
| 227 bool m_pausingOnNativeEvent; |
| 228 RawPtrWillBeMember<Listener> m_listener; |
| 229 |
| 230 int m_skippedStepInCount; |
| 231 int m_minFrameCountForSkip; |
| 232 bool m_skipAllPauses; |
| 233 OwnPtr<ScriptRegexp> m_cachedSkipStackRegExp; |
| 234 InspectorDebuggerAgent* m_inspectorDebuggerAgent; |
| 235 InspectorPageAgent* m_pageAgent; |
| 236 }; |
| 237 |
| 238 } // namespace blink |
| 239 |
| 240 |
| 241 #endif // !defined(DartInspectorDebuggerAgent_h) |
OLD | NEW |