Chromium Code Reviews| Index: src/inspector/v8-debugger-agent-impl.cc |
| diff --git a/src/inspector/v8-debugger-agent-impl.cc b/src/inspector/v8-debugger-agent-impl.cc |
| index f318619b35bf2b37a0696f9af59bef791840af77..24b13f1a5e23a59f108c5aab942a3faa7cd6a4de 100644 |
| --- a/src/inspector/v8-debugger-agent-impl.cc |
| +++ b/src/inspector/v8-debugger-agent-impl.cc |
| @@ -380,6 +380,49 @@ void V8DebuggerAgentImpl::removeBreakpoint(const String16& breakpointId) { |
| m_breakpointIdToDebuggerBreakpointIds.erase(breakpointId); |
| } |
| +void V8DebuggerAgentImpl::getPossibleBreakpoints( |
| + ErrorString* errorString, |
| + std::unique_ptr<protocol::Debugger::Location> start, |
| + const Maybe<protocol::Debugger::Location>& end, |
| + std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations) { |
| + String16 scriptId = start->getScriptId(); |
| + int startLine = start->getLineNumber(); |
| + int startColumn = start->getColumnNumber(0); |
| + int endLine = end.isJust() ? end.fromJust()->getLineNumber() : -1; |
| + int endColumn = end.isJust() ? end.fromJust()->getColumnNumber(0) : -1; |
| + |
| + if (end.isJust()) { |
| + if (end.fromJust()->getScriptId() != scriptId) { |
| + *errorString = "Locations should contain the same scriptId"; |
| + return; |
| + } |
| + } |
| + auto it = m_scripts.find(scriptId); |
| + if (it == m_scripts.end()) { |
| + *errorString = "Script not found"; |
| + return; |
| + } |
| + |
| + std::vector<int> positions; |
| + if (!it->second->getPossibleBreakpoints(startLine, startColumn, endLine, |
| + endColumn, positions) || |
| + positions.size() % 2) { |
|
Yang
2016/11/03 08:03:26
We would not have to check this if positions conta
kozy
2016/11/03 17:26:45
Removed.
|
| + *errorString = "Internal error"; |
| + return; |
| + } |
| + |
| + using protocol::Debugger::Location; |
| + *locations = protocol::Array<Location>::create(); |
| + for (size_t i = 0; i < positions.size(); i += 2) { |
| + (*locations) |
| + ->addItem(Location::create() |
| + .setScriptId(scriptId) |
| + .setLineNumber(positions[i]) |
| + .setColumnNumber(positions[i + 1]) |
| + .build()); |
| + } |
| +} |
| + |
| void V8DebuggerAgentImpl::continueToLocation( |
| ErrorString* errorString, |
| std::unique_ptr<protocol::Debugger::Location> location) { |
| @@ -547,7 +590,7 @@ void V8DebuggerAgentImpl::setScriptSource( |
| return; |
| ScriptsMap::iterator it = m_scripts.find(scriptId); |
| - if (it != m_scripts.end()) it->second->setSource(m_isolate, newSource); |
| + if (it != m_scripts.end()) it->second->setSource(newSource); |
| std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString); |
| if (!callFrames) return; |