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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp

Issue 2012753003: DevTools: consolidate protocol generators for front-end, backend and type builder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/inspector_protocol/Values.h" 8 #include "platform/inspector_protocol/Values.h"
9 #include "platform/v8_inspector/InjectedScript.h" 9 #include "platform/v8_inspector/InjectedScript.h"
10 #include "platform/v8_inspector/InspectedContext.h" 10 #include "platform/v8_inspector/InspectedContext.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation(const String16& scriptId, int lineNumber, int columnNumber) 150 static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation(const String16& scriptId, int lineNumber, int columnNumber)
151 { 151 {
152 return protocol::Debugger::Location::create() 152 return protocol::Debugger::Location::create()
153 .setScriptId(scriptId) 153 .setScriptId(scriptId)
154 .setLineNumber(lineNumber) 154 .setLineNumber(lineNumber)
155 .setColumnNumber(columnNumber).build(); 155 .setColumnNumber(columnNumber).build();
156 } 156 }
157 157
158 V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protoc ol::Debugger::Frontend* frontend, protocol::DictionaryValue* state) 158 V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protoc ol::FrontendChannel* frontendChannel, protocol::DictionaryValue* state)
159 : m_debugger(session->debugger()) 159 : m_debugger(session->debugger())
160 , m_session(session) 160 , m_session(session)
161 , m_enabled(false) 161 , m_enabled(false)
162 , m_state(state) 162 , m_state(state)
163 , m_frontend(frontend) 163 , m_frontend(frontendChannel)
164 , m_isolate(m_debugger->isolate()) 164 , m_isolate(m_debugger->isolate())
165 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other) 165 , m_breakReason(protocol::Debugger::Paused::ReasonEnum::Other)
166 , m_scheduledDebuggerStep(NoStep) 166 , m_scheduledDebuggerStep(NoStep)
167 , m_skipNextDebuggerStepOut(false) 167 , m_skipNextDebuggerStepOut(false)
168 , m_javaScriptPauseScheduled(false) 168 , m_javaScriptPauseScheduled(false)
169 , m_steppingFromFramework(false) 169 , m_steppingFromFramework(false)
170 , m_pausingOnNativeEvent(false) 170 , m_pausingOnNativeEvent(false)
171 , m_skippedStepFrameCount(0) 171 , m_skippedStepFrameCount(0)
172 , m_recursionLevelForStepOut(0) 172 , m_recursionLevelForStepOut(0)
173 , m_recursionLevelForStepFrame(0) 173 , m_recursionLevelForStepFrame(0)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 { 216 {
217 if (enabled()) 217 if (enabled())
218 return; 218 return;
219 219
220 if (!m_session->client()->canExecuteScripts()) { 220 if (!m_session->client()->canExecuteScripts()) {
221 *errorString = "Script execution is prohibited"; 221 *errorString = "Script execution is prohibited";
222 return; 222 return;
223 } 223 }
224 224
225 enable(); 225 enable();
226 DCHECK(m_frontend);
227 } 226 }
228 227
229 void V8DebuggerAgentImpl::disable(ErrorString*) 228 void V8DebuggerAgentImpl::disable(ErrorString*)
230 { 229 {
231 if (!enabled()) 230 if (!enabled())
232 return; 231 return;
233 m_session->changeInstrumentationCounter(-1); 232 m_session->changeInstrumentationCounter(-1);
234 233
235 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict ionaryValue::create()); 234 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, protocol::Dict ionaryValue::create());
236 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImp l::DontPauseOnExceptions); 235 m_state->setNumber(DebuggerAgentState::pauseOnExceptionsState, V8DebuggerImp l::DontPauseOnExceptions);
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 String16 sourceMapURL = script.sourceMappingURL(); 1267 String16 sourceMapURL = script.sourceMappingURL();
1269 bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceM appingURL; 1268 bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceM appingURL;
1270 1269
1271 const Maybe<String16>& sourceMapURLParam = sourceMapURL; 1270 const Maybe<String16>& sourceMapURLParam = sourceMapURL;
1272 const bool* isContentScriptParam = isContentScript ? &isContentScript : null ptr; 1271 const bool* isContentScriptParam = isContentScript ? &isContentScript : null ptr;
1273 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n ullptr; 1272 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n ullptr;
1274 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; 1273 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr;
1275 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; 1274 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
1276 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr ecatedCommentWasUsed : nullptr; 1275 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr ecatedCommentWasUsed : nullptr;
1277 if (parsedScript.success) 1276 if (parsedScript.success)
1278 m_frontend->scriptParsed(parsedScript.scriptId, scriptURL, script.startL ine(), script.startColumn(), script.endLine(), script.endColumn(), executionCont extId, script.hash(), isContentScriptParam, isInternalScriptParam, isLiveEditPar am, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); 1277 m_frontend.scriptParsed(parsedScript.scriptId, scriptURL, script.startLi ne(), script.startColumn(), script.endLine(), script.endColumn(), executionConte xtId, script.hash(), isContentScriptParam, isInternalScriptParam, isLiveEditPara m, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
1279 else 1278 else
1280 m_frontend->scriptFailedToParse(parsedScript.scriptId, scriptURL, script .startLine(), script.startColumn(), script.endLine(), script.endColumn(), execut ionContextId, script.hash(), isContentScriptParam, isInternalScriptParam, source MapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); 1279 m_frontend.scriptFailedToParse(parsedScript.scriptId, scriptURL, script. startLine(), script.startColumn(), script.endLine(), script.endColumn(), executi onContextId, script.hash(), isContentScriptParam, isInternalScriptParam, sourceM apURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
1281 1280
1282 m_scripts.set(parsedScript.scriptId, script); 1281 m_scripts.set(parsedScript.scriptId, script);
1283 1282
1284 if (scriptURL.isEmpty() || !parsedScript.success) 1283 if (scriptURL.isEmpty() || !parsedScript.success)
1285 return; 1284 return;
1286 1285
1287 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints); 1286 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints);
1288 if (!breakpointsCookie) 1287 if (!breakpointsCookie)
1289 return; 1288 return;
1290 1289
1291 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { 1290 for (size_t i = 0; i < breakpointsCookie->size(); ++i) {
1292 auto cookie = breakpointsCookie->at(i); 1291 auto cookie = breakpointsCookie->at(i);
1293 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue: :cast(cookie.second); 1292 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue: :cast(cookie.second);
1294 bool isRegex; 1293 bool isRegex;
1295 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); 1294 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex);
1296 String16 url; 1295 String16 url;
1297 breakpointObject->getString(DebuggerAgentState::url, &url); 1296 breakpointObject->getString(DebuggerAgentState::url, &url);
1298 if (!matches(m_debugger, scriptURL, url, isRegex)) 1297 if (!matches(m_debugger, scriptURL, url, isRegex))
1299 continue; 1298 continue;
1300 ScriptBreakpoint breakpoint; 1299 ScriptBreakpoint breakpoint;
1301 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber); 1300 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber);
1302 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber); 1301 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber);
1303 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition); 1302 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition);
1304 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi nt(cookie.first, parsedScript.scriptId, breakpoint, UserBreakpointSource); 1303 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi nt(cookie.first, parsedScript.scriptId, breakpoint, UserBreakpointSource);
1305 if (location) 1304 if (location)
1306 m_frontend->breakpointResolved(cookie.first, std::move(location)); 1305 m_frontend.breakpointResolved(cookie.first, std::move(location));
1307 } 1306 }
1308 } 1307 }
1309 1308
1310 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const protocol::Vector<Strin g16>& hitBreakpoints, bool isPromiseRejection) 1309 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const protocol::Vector<Strin g16>& hitBreakpoints, bool isPromiseRejection)
1311 { 1310 {
1312 JavaScriptCallFrames callFrames = debugger().currentCallFrames(1); 1311 JavaScriptCallFrames callFrames = debugger().currentCallFrames(1);
1313 JavaScriptCallFrame* topCallFrame = callFrames.size() > 0 ? callFrames[0] : nullptr; 1312 JavaScriptCallFrame* topCallFrame = callFrames.size() > 0 ? callFrames[0] : nullptr;
1314 1313
1315 V8DebuggerAgentImpl::SkipPauseRequest result; 1314 V8DebuggerAgentImpl::SkipPauseRequest result;
1316 if (m_skipAllPauses) 1315 if (m_skipAllPauses)
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 const String16& localId = breakpointIterator->second->first; 1355 const String16& localId = breakpointIterator->second->first;
1357 hitBreakpointIds->addItem(localId); 1356 hitBreakpointIds->addItem(localId);
1358 1357
1359 BreakpointSource source = breakpointIterator->second->second; 1358 BreakpointSource source = breakpointIterator->second->second;
1360 if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other & & source == DebugCommandBreakpointSource) 1359 if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other & & source == DebugCommandBreakpointSource)
1361 m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCom mand; 1360 m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCom mand;
1362 } 1361 }
1363 } 1362 }
1364 1363
1365 ErrorString errorString; 1364 ErrorString errorString;
1366 m_frontend->paused(currentCallFrames(&errorString), m_breakReason, std::move (m_breakAuxData), std::move(hitBreakpointIds), currentAsyncStackTrace()); 1365 m_frontend.paused(currentCallFrames(&errorString), m_breakReason, std::move( m_breakAuxData), std::move(hitBreakpointIds), currentAsyncStackTrace());
1367 m_scheduledDebuggerStep = NoStep; 1366 m_scheduledDebuggerStep = NoStep;
1368 m_javaScriptPauseScheduled = false; 1367 m_javaScriptPauseScheduled = false;
1369 m_steppingFromFramework = false; 1368 m_steppingFromFramework = false;
1370 m_pausingOnNativeEvent = false; 1369 m_pausingOnNativeEvent = false;
1371 m_skippedStepFrameCount = 0; 1370 m_skippedStepFrameCount = 0;
1372 m_recursionLevelForStepFrame = 0; 1371 m_recursionLevelForStepFrame = 0;
1373 1372
1374 if (!m_continueToLocationBreakpointId.isEmpty()) { 1373 if (!m_continueToLocationBreakpointId.isEmpty()) {
1375 debugger().removeBreakpoint(m_continueToLocationBreakpointId); 1374 debugger().removeBreakpoint(m_continueToLocationBreakpointId);
1376 m_continueToLocationBreakpointId = ""; 1375 m_continueToLocationBreakpointId = "";
1377 } 1376 }
1378 return result; 1377 return result;
1379 } 1378 }
1380 1379
1381 void V8DebuggerAgentImpl::didContinue() 1380 void V8DebuggerAgentImpl::didContinue()
1382 { 1381 {
1383 m_pausedContext.Reset(); 1382 m_pausedContext.Reset();
1384 JavaScriptCallFrames emptyCallFrames; 1383 JavaScriptCallFrames emptyCallFrames;
1385 m_pausedCallFrames.swap(emptyCallFrames); 1384 m_pausedCallFrames.swap(emptyCallFrames);
1386 clearBreakDetails(); 1385 clearBreakDetails();
1387 m_frontend->resumed(); 1386 m_frontend.resumed();
1388 } 1387 }
1389 1388
1390 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, std::unique_ ptr<protocol::DictionaryValue> data) 1389 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, std::unique_ ptr<protocol::DictionaryValue> data)
1391 { 1390 {
1392 if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrent CallStackEmptyOrBlackboxed() || !debugger().breakpointsActivated()) 1391 if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrent CallStackEmptyOrBlackboxed() || !debugger().breakpointsActivated())
1393 return; 1392 return;
1394 m_breakReason = breakReason; 1393 m_breakReason = breakReason;
1395 m_breakAuxData = std::move(data); 1394 m_breakAuxData = std::move(data);
1396 m_scheduledDebuggerStep = NoStep; 1395 m_scheduledDebuggerStep = NoStep;
1397 m_steppingFromFramework = false; 1396 m_steppingFromFramework = false;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 if (!enabled()) 1437 if (!enabled())
1439 return; 1438 return;
1440 m_scheduledDebuggerStep = NoStep; 1439 m_scheduledDebuggerStep = NoStep;
1441 m_scripts.clear(); 1440 m_scripts.clear();
1442 m_blackboxedPositions.clear(); 1441 m_blackboxedPositions.clear();
1443 m_breakpointIdToDebuggerBreakpointIds.clear(); 1442 m_breakpointIdToDebuggerBreakpointIds.clear();
1444 allAsyncTasksCanceled(); 1443 allAsyncTasksCanceled();
1445 } 1444 }
1446 1445
1447 } // namespace blink 1446 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698