Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: sky/engine/bindings-dart/core/dart/DartScriptDebugServer.h

Issue 918273002: Remove bindings-dart (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef DartScriptDebugServer_h
32 #define DartScriptDebugServer_h
33
34 #include "bindings/core/dart/DartScriptDebugListener.h"
35 #include "bindings/core/v8/PageScriptDebugServer.h"
36 #include "core/inspector/ScriptBreakpoint.h"
37
38 #include "wtf/Forward.h"
39 #include "wtf/HashSet.h"
40 #include "wtf/RefCounted.h"
41 #include <dart_api.h>
42 #include <dart_debugger_api.h>
43 #include <v8.h>
44
45 namespace blink {
46
47 class DartInjectedScriptManager;
48 class Page;
49 template<typename T>
50 class HandleMap {
51 public:
52 HandleMap() : m_lastHandle(0)
53 {
54 }
55
56 int add(T value)
57 {
58 ASSERT(!m_valueToHandleMap.contains(value));
59 int handle = ++m_lastHandle;
60 m_handleToValueMap.set(handle, value);
61 m_valueToHandleMap.set(value, handle);
62 return handle;
63 }
64
65 T get(int handle)
66 {
67 return m_handleToValueMap.get(handle);
68 }
69
70 bool containsValue(T value)
71 {
72 return m_valueToHandleMap.contains(value);
73 }
74
75 int getByValue(T value)
76 {
77 ASSERT(m_valueToHandleMap.contains(value));
78 return m_valueToHandleMap.get(value);
79 }
80
81 T remove(int handle)
82 {
83 T value = m_handleToValueMap.take(handle);
84 m_valueToHandleMap.remove(value);
85 return value;
86 }
87
88 int removeByValue(T value)
89 {
90 int handle = m_valueToHandleMap.take(value);
91 m_handleToValueMap.remove(handle);
92 return handle;
93 }
94
95 void copyValues(Vector<T>& values)
96 {
97 copyKeysToVector(m_valueToHandleMap, values);
98 }
99
100 private:
101 int m_lastHandle;
102 HashMap<int, T> m_handleToValueMap;
103 HashMap<T, int> m_valueToHandleMap;
104 };
105
106 struct DartBreakpoint {
107 DartBreakpoint(intptr_t breakpointId, Dart_Isolate);
108
109 intptr_t m_breakpointId;
110 Dart_Isolate m_isolate;
111 };
112
113
114 struct DartBreakpointInfo {
115 DartBreakpointInfo(const String& scriptUrl, const ScriptBreakpoint&);
116 String m_scriptUrl;
117 ScriptBreakpoint m_scriptBreakpoint;
118 Vector<DartBreakpoint> m_breakpoints;
119 };
120
121 class DartPageDebug {
122 public:
123 DartPageDebug(Page*, int pageId);
124 ~DartPageDebug();
125
126 String setBreakpoint(const String& sourceID, const ScriptBreakpoint&, int* a ctualLineNumber, int* actualColumnNumber, bool interstatementLocation);
127
128 void registerIsolate(Dart_Isolate);
129 void unregisterIsolate(Dart_Isolate);
130
131 intptr_t setBreakpointHelper(DartBreakpointInfo*, const String& breakpointId String, Dart_Isolate, Dart_Handle& exception);
132
133 void removeBreakpoint(const String& breakpointId);
134 void removeBreakpointHelper(DartBreakpointInfo*);
135 void clearBreakpointsForIsolate(Dart_Isolate);
136 void clearBreakpoints();
137 void isolateLoaded();
138 void addListener(DartScriptDebugListener*);
139 void removeListener();
140 DartScriptDebugListener* listener() { return m_listener; }
141 String getScriptId(const String& url);
142 String lookupBreakpointId(intptr_t dartBreakpointId);
143
144 Vector<Dart_Isolate> isolates();
145 bool containsIsolate(Dart_Isolate isolate) { return m_isolateMap.containsVal ue(isolate); }
146 Page* page() { return m_page; }
147 private:
148 void registerIsolateScripts(Dart_Isolate);
149 void dispatchDidParseSource(intptr_t libraryId, Dart_Handle scriptURL, Dart_ Isolate);
150
151 HandleMap<Dart_Isolate> m_isolateMap;
152
153 Page* m_page;
154 DartScriptDebugListener* m_listener;
155 int m_pageId;
156 HashMap<String, String> m_idToScriptUrlMap;
157 HashMap<String, String> m_scriptUrlToIdMap;
158
159 typedef HashMap<String, DartBreakpointInfo* > BreakpointMap;
160 BreakpointMap m_breakpoints;
161 typedef HashMap<intptr_t, String> BreakpointIdMap;
162 BreakpointIdMap m_breakpointIdMap;
163 int m_nextBreakpointId;
164 int m_nextScriptId;
165 };
166
167 class DartScriptDebugServer {
168 WTF_MAKE_NONCOPYABLE(DartScriptDebugServer);
169 public:
170 static DartScriptDebugServer& shared();
171
172 void addListener(DartScriptDebugListener*, Page*);
173 void removeListener(DartScriptDebugListener*, Page*);
174
175 void setClientMessageLoop(PageScriptDebugServer::ClientMessageLoop*);
176
177 String setBreakpoint(const String& sourceID, const ScriptBreakpoint&, int* a ctualLineNumber, int* actualColumnNumber, bool interstatementLocation);
178 void removeBreakpoint(const String& breakpointId);
179 void clearBreakpoints();
180 void setBreakpointsActivated(bool);
181
182 ScriptDebugServer::PauseOnExceptionsState pauseOnExceptionsState();
183 void setPauseOnExceptionsState(ScriptDebugServer::PauseOnExceptionsState);
184
185 void setPauseOnNextStatement(bool);
186 bool canBreakProgram();
187 void breakProgram();
188 void continueProgram();
189 void stepIntoStatement();
190 void stepOverStatement();
191 void stepOutOfFunction();
192
193 bool setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, RefPtr<TypeBuilder::Debugger::SetScriptSourceError>&, Da rt_StackTrace newCallFrames, RefPtr<JSONObject>* result);
194 ScriptCallFrame callFrameNoScopes(int index);
195
196 int frameCount();
197 Dart_StackTrace currentCallFrames();
198
199 bool isPaused();
200 bool runningNestedMessageLoop() { return m_runningNestedMessageLoop; }
201
202 void runScript(ScriptState*, const String& scriptId, ScriptValue* result, bo ol* wasThrown, String* exceptionDetailsText, int* lineNumber, int* columnNumber, RefPtrWillBeRawPtr<ScriptCallStack>* stackTrace);
203
204 static void pausedEventHandler(Dart_IsolateId, intptr_t breakpointId, const Dart_CodeLocation&);
205 static void exceptionHandler(Dart_IsolateId, Dart_Handle, Dart_StackTrace);
206 void handleException(Dart_IsolateId, Dart_Handle, Dart_StackTrace);
207
208 static void isolateEventHandler(Dart_IsolateId, Dart_IsolateEvent kind);
209 void handleInterrupted(Dart_IsolateId);
210 static void interruptAndRunAllTasks();
211 void runPendingTasks();
212
213 void registerIsolate(Dart_Isolate, Page*);
214 void unregisterIsolate(Dart_Isolate, Page*);
215 void isolateLoaded();
216
217 bool resolveCodeLocation(const Dart_CodeLocation&, int* line, int* column);
218
219 String getScriptId(const String& url, Dart_Isolate);
220 void clearWindowShell(Page*);
221
222 ScriptDebugServer::PauseOnExceptionsState pauseOnExceptionState() { return m _pauseOnExceptionState; }
223
224 void setInjectedScriptManager(DartInjectedScriptManager* manager) { m_inject edScriptManager = manager; }
225 DartInjectedScriptManager* injectedScriptManager() { return m_injectedScript Manager; }
226 protected:
227 explicit DartScriptDebugServer();
228 ~DartScriptDebugServer();
229
230 bool isAnyScriptPaused();
231
232 DartPageDebug* lookupPageDebugForId(const String& id);
233 DartPageDebug* lookupPageDebug(Page*);
234 DartPageDebug* lookupPageDebugForCurrentIsolate();
235 void runMessageLoopOnPause(Dart_Isolate);
236 void quitMessageLoopOnPause();
237 bool executeSkipPauseRequest(DartScriptDebugListener::SkipPauseRequest, Dart _StackTrace);
238 void handleProgramBreak(Dart_Isolate, Dart_StackTrace, intptr_t dartBreakpoi ntId, Dart_Handle exception, const Dart_CodeLocation&);
239 void handleDartDebugEvent(Dart_IsolateId, intptr_t breakpointId, Dart_Handle exception, const Dart_CodeLocation&);
240
241 ScriptCallFrame getScriptCallFrameHelper(int frameIndex);
242
243 void debugBreak();
244 void cancelDebugBreak();
245 Page* inferPage(Dart_Isolate);
246
247 Vector<Dart_Isolate> isolates();
248 Vector<DartPageDebug*> pages();
249
250 ScriptDebugServer::PauseOnExceptionsState m_pauseOnExceptionState;
251 bool m_breakpointsActivated;
252 bool m_runningNestedMessageLoop;
253 Dart_StackTrace m_executionState;
254 Dart_Isolate m_pausedIsolate;
255 Page* m_pausedPage;
256 HashSet<Dart_Isolate> m_interruptCalled;
257 HashSet<Dart_Isolate> m_interruptCancelled;
258
259 typedef HashMap<int, DartPageDebug*> DebugDataMap;
260 DebugDataMap m_pageIdToDebugDataMap;
261 typedef HashMap<Page*, int> PageToIdMap;
262 PageToIdMap m_pageToIdMap;
263
264 PageScriptDebugServer::ClientMessageLoop* m_clientMessageLoop;
265
266 DartInjectedScriptManager* m_injectedScriptManager;
267
268 int m_nextPageId;
269 };
270
271 }
272
273 #endif // DartScriptDebugServer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698