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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.h

Issue 2035653006: [DevTools] Move Console to v8 inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improved api a bit Created 4 years, 5 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
1 /* 1 /*
2 * Copyright (c) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include <v8.h> 43 #include <v8.h>
44 44
45 #include <vector> 45 #include <vector>
46 46
47 namespace blink { 47 namespace blink {
48 48
49 using protocol::Maybe; 49 using protocol::Maybe;
50 50
51 struct ScriptBreakpoint; 51 struct ScriptBreakpoint;
52 class InspectedContext; 52 class InspectedContext;
53 class V8ConsoleMessageStorage;
53 class V8DebuggerAgentImpl; 54 class V8DebuggerAgentImpl;
54 class V8InspectorSessionImpl; 55 class V8InspectorSessionImpl;
55 class V8RuntimeAgentImpl; 56 class V8RuntimeAgentImpl;
56 class V8StackTraceImpl; 57 class V8StackTraceImpl;
57 58
58 class V8DebuggerImpl : public V8Debugger { 59 class V8DebuggerImpl : public V8Debugger {
59 PROTOCOL_DISALLOW_COPY(V8DebuggerImpl); 60 PROTOCOL_DISALLOW_COPY(V8DebuggerImpl);
60 public: 61 public:
61 V8DebuggerImpl(v8::Isolate*, V8DebuggerClient*); 62 V8DebuggerImpl(v8::Isolate*, V8DebuggerClient*);
62 ~V8DebuggerImpl() override; 63 ~V8DebuggerImpl() override;
63 64
65 static int contextId(v8::Local<v8::Context>);
66
64 bool enabled() const; 67 bool enabled() const;
65 68
66 String16 setBreakpoint(const String16& sourceID, const ScriptBreakpoint&, in t* actualLineNumber, int* actualColumnNumber, bool interstatementLocation); 69 String16 setBreakpoint(const String16& sourceID, const ScriptBreakpoint&, in t* actualLineNumber, int* actualColumnNumber, bool interstatementLocation);
67 void removeBreakpoint(const String16& breakpointId); 70 void removeBreakpoint(const String16& breakpointId);
68 void setBreakpointsActivated(bool); 71 void setBreakpointsActivated(bool);
69 bool breakpointsActivated() const { return m_breakpointsActivated; } 72 bool breakpointsActivated() const { return m_breakpointsActivated; }
70 73
71 enum PauseOnExceptionsState { 74 enum PauseOnExceptionsState {
72 DontPauseOnExceptions, 75 DontPauseOnExceptions,
73 PauseOnAllExceptions, 76 PauseOnAllExceptions,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 109
107 v8::Isolate* isolate() const { return m_isolate; } 110 v8::Isolate* isolate() const { return m_isolate; }
108 V8DebuggerClient* client() { return m_client; } 111 V8DebuggerClient* client() { return m_client; }
109 112
110 v8::MaybeLocal<v8::Value> runCompiledScript(v8::Local<v8::Context>, v8::Loca l<v8::Script>); 113 v8::MaybeLocal<v8::Value> runCompiledScript(v8::Local<v8::Context>, v8::Loca l<v8::Script>);
111 v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8 ::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[] ); 114 v8::MaybeLocal<v8::Value> callFunction(v8::Local<v8::Function>, v8::Local<v8 ::Context>, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[] );
112 v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::Context> , v8::Local<v8::String>); 115 v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Local<v8::Context> , v8::Local<v8::String>);
113 v8::Local<v8::Script> compileInternalScript(v8::Local<v8::Context>, v8::Loca l<v8::String>, const String16& fileName); 116 v8::Local<v8::Script> compileInternalScript(v8::Local<v8::Context>, v8::Loca l<v8::String>, const String16& fileName);
114 v8::Local<v8::Context> regexContext(); 117 v8::Local<v8::Context> regexContext();
115 118
119 void enableStackCapturingIfNeeded();
120 void disableStackCapturingIfNeeded();
121 V8ConsoleMessageStorage* ensureConsoleMessageStorage(int contextGroupId);
122
116 // V8Debugger implementation 123 // V8Debugger implementation
117 std::unique_ptr<V8InspectorSession> connect(int contextGroupId, protocol::Fr ontendChannel*, V8InspectorSessionClient*, const String16* state) override; 124 std::unique_ptr<V8InspectorSession> connect(int contextGroupId, protocol::Fr ontendChannel*, V8InspectorSessionClient*, const String16* state) override;
118 void contextCreated(const V8ContextInfo&) override; 125 void contextCreated(const V8ContextInfo&) override;
119 void contextDestroyed(v8::Local<v8::Context>) override; 126 void contextDestroyed(v8::Local<v8::Context>) override;
120 void resetContextGroup(int contextGroupId) override; 127 void resetContextGroup(int contextGroupId) override;
121 void willExecuteScript(v8::Local<v8::Context>, int scriptId) override; 128 void willExecuteScript(v8::Local<v8::Context>, int scriptId) override;
122 void didExecuteScript(v8::Local<v8::Context>) override; 129 void didExecuteScript(v8::Local<v8::Context>) override;
123 void idleStarted() override; 130 void idleStarted() override;
124 void idleFinished() override; 131 void idleFinished() override;
132 bool addConsoleMessage(int contextGroupId, MessageSource, MessageLevel, cons t String16& message, const String16& url, unsigned lineNumber, unsigned columnNu mber, std::unique_ptr<V8StackTrace>, int scriptId, const String16& requestIdenti fier) override;
133 void logToConsole(v8::Local<v8::Context>, const String16& message, v8::Local <v8::Value> arg1, v8::Local<v8::Value> arg2) override;
134 unsigned promiseRejected(v8::Local<v8::Context>, const String16& errorMessag e, v8::Local<v8::Value> reason, const String16& url, unsigned lineNumber, unsign ed columnNumber, std::unique_ptr<V8StackTrace>, int scriptId) override;
135 void promiseRejectionRevoked(v8::Local<v8::Context>, unsigned promiseRejecti onId) override;
136 void consoleMessagesCount(int contextGroupId, unsigned* total, unsigned* wit hArguments) override;
125 std::unique_ptr<V8StackTrace> createStackTrace(v8::Local<v8::StackTrace>) ov erride; 137 std::unique_ptr<V8StackTrace> createStackTrace(v8::Local<v8::StackTrace>) ov erride;
126 std::unique_ptr<V8StackTrace> captureStackTrace(size_t maxStackSize) overrid e; 138 std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) override;
127 void asyncTaskScheduled(const String16& taskName, void* task, bool recurring ) override; 139 void asyncTaskScheduled(const String16& taskName, void* task, bool recurring ) override;
128 void asyncTaskCanceled(void* task) override; 140 void asyncTaskCanceled(void* task) override;
129 void asyncTaskStarted(void* task) override; 141 void asyncTaskStarted(void* task) override;
130 void asyncTaskFinished(void* task) override; 142 void asyncTaskFinished(void* task) override;
131 void allAsyncTasksCanceled() override; 143 void allAsyncTasksCanceled() override;
144 void muteConsole() override { m_muteConsoleCount++; }
145 void unmuteConsole() override { m_muteConsoleCount--; }
132 146
133 using ContextByIdMap = protocol::HashMap<int, std::unique_ptr<InspectedConte xt>>; 147 using ContextByIdMap = protocol::HashMap<int, std::unique_ptr<InspectedConte xt>>;
134 void discardInspectedContext(int contextGroupId, int contextId); 148 void discardInspectedContext(int contextGroupId, int contextId);
135 const ContextByIdMap* contextGroup(int contextGroupId); 149 const ContextByIdMap* contextGroup(int contextGroupId);
136 void disconnect(V8InspectorSessionImpl*); 150 void disconnect(V8InspectorSessionImpl*);
137 V8InspectorSessionImpl* sessionForContextGroup(int contextGroupId); 151 V8InspectorSessionImpl* sessionForContextGroup(int contextGroupId);
152 InspectedContext* getContext(int groupId, int contextId) const;
138 153
139 private: 154 private:
140 void enable(); 155 void enable();
141 void disable(); 156 void disable();
142 V8DebuggerAgentImpl* findEnabledDebuggerAgent(int contextGroupId); 157 V8DebuggerAgentImpl* findEnabledDebuggerAgent(int contextGroupId);
143 V8DebuggerAgentImpl* findEnabledDebuggerAgent(v8::Local<v8::Context>); 158 V8DebuggerAgentImpl* findEnabledDebuggerAgent(v8::Local<v8::Context>);
144 159
145 void compileDebuggerScript(); 160 void compileDebuggerScript();
146 v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName, int a rgc, v8::Local<v8::Value> argv[]); 161 v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName, int a rgc, v8::Local<v8::Value> argv[]);
147 v8::Local<v8::Context> debuggerContext() const; 162 v8::Local<v8::Context> debuggerContext() const;
148 void clearBreakpoints(); 163 void clearBreakpoints();
149 164
150 V8DebuggerParsedScript createParsedScript(v8::Local<v8::Object> sourceObject , bool success); 165 V8DebuggerParsedScript createParsedScript(v8::Local<v8::Object> sourceObject , bool success);
151 166
152 static void breakProgramCallback(const v8::FunctionCallbackInfo<v8::Value>&) ; 167 static void breakProgramCallback(const v8::FunctionCallbackInfo<v8::Value>&) ;
153 void handleProgramBreak(v8::Local<v8::Context> pausedContext, v8::Local<v8:: Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::Array> hit Breakpoints, bool isPromiseRejection = false); 168 void handleProgramBreak(v8::Local<v8::Context> pausedContext, v8::Local<v8:: Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::Array> hit Breakpoints, bool isPromiseRejection = false);
154 static void v8DebugEventCallback(const v8::Debug::EventDetails&); 169 static void v8DebugEventCallback(const v8::Debug::EventDetails&);
155 v8::Local<v8::Value> callInternalGetterFunction(v8::Local<v8::Object>, const char* functionName); 170 v8::Local<v8::Value> callInternalGetterFunction(v8::Local<v8::Object>, const char* functionName);
156 void handleV8DebugEvent(const v8::Debug::EventDetails&); 171 void handleV8DebugEvent(const v8::Debug::EventDetails&);
157 172
158 v8::Local<v8::String> v8InternalizedString(const char*) const; 173 v8::Local<v8::String> v8InternalizedString(const char*) const;
159 174
160 void handleV8AsyncTaskEvent(v8::Local<v8::Context>, v8::Local<v8::Object> ex ecutionState, v8::Local<v8::Object> eventData); 175 void handleV8AsyncTaskEvent(v8::Local<v8::Context>, v8::Local<v8::Object> ex ecutionState, v8::Local<v8::Object> eventData);
161 InspectedContext* getContext(int groupId, int contextId) const;
162 176
163 using ContextsByGroupMap = protocol::HashMap<int, std::unique_ptr<ContextByI dMap>>; 177 using ContextsByGroupMap = protocol::HashMap<int, std::unique_ptr<ContextByI dMap>>;
164 178
165 v8::Local<v8::Value> collectionEntries(v8::Local<v8::Context>, v8::Local<v8: :Object>); 179 v8::Local<v8::Value> collectionEntries(v8::Local<v8::Context>, v8::Local<v8: :Object>);
166 180
167 v8::Isolate* m_isolate; 181 v8::Isolate* m_isolate;
168 V8DebuggerClient* m_client; 182 V8DebuggerClient* m_client;
169 ContextsByGroupMap m_contexts; 183 ContextsByGroupMap m_contexts;
170 using SessionMap = protocol::HashMap<int, V8InspectorSessionImpl*>; 184 using SessionMap = protocol::HashMap<int, V8InspectorSessionImpl*>;
171 SessionMap m_sessions; 185 SessionMap m_sessions;
186 using ConsoleStorageMap = protocol::HashMap<int, std::unique_ptr<V8ConsoleMe ssageStorage>>;
187 ConsoleStorageMap m_consoleStorageMap;
188 int m_capturingStackTracesCount;
189 int m_muteConsoleCount;
190 unsigned m_lastConsoleMessageId;
172 int m_enabledAgentsCount; 191 int m_enabledAgentsCount;
173 bool m_breakpointsActivated; 192 bool m_breakpointsActivated;
174 v8::Global<v8::Object> m_debuggerScript; 193 v8::Global<v8::Object> m_debuggerScript;
175 v8::Global<v8::Context> m_debuggerContext; 194 v8::Global<v8::Context> m_debuggerContext;
176 v8::Local<v8::Object> m_executionState; 195 v8::Local<v8::Object> m_executionState;
177 v8::Local<v8::Context> m_pausedContext; 196 v8::Local<v8::Context> m_pausedContext;
178 bool m_runningNestedMessageLoop; 197 bool m_runningNestedMessageLoop;
179 v8::Global<v8::Context> m_regexContext; 198 v8::Global<v8::Context> m_regexContext;
180 199
181 using AsyncTaskToStackTrace = protocol::HashMap<void*, std::unique_ptr<V8Sta ckTraceImpl>>; 200 using AsyncTaskToStackTrace = protocol::HashMap<void*, std::unique_ptr<V8Sta ckTraceImpl>>;
182 AsyncTaskToStackTrace m_asyncTaskStacks; 201 AsyncTaskToStackTrace m_asyncTaskStacks;
183 protocol::HashSet<void*> m_recurringTasks; 202 protocol::HashSet<void*> m_recurringTasks;
184 int m_maxAsyncCallStackDepth; 203 int m_maxAsyncCallStackDepth;
185 std::vector<void*> m_currentTasks; 204 std::vector<void*> m_currentTasks;
186 std::vector<std::unique_ptr<V8StackTraceImpl>> m_currentStacks; 205 std::vector<std::unique_ptr<V8StackTraceImpl>> m_currentStacks;
187 protocol::HashMap<V8DebuggerAgentImpl*, int> m_maxAsyncCallStackDepthMap; 206 protocol::HashMap<V8DebuggerAgentImpl*, int> m_maxAsyncCallStackDepthMap;
188 }; 207 };
189 208
190 } // namespace blink 209 } // namespace blink
191 210
192 211
193 #endif // V8DebuggerImpl_h 212 #endif // V8DebuggerImpl_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698