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

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

Issue 2104063002: [DevTools] Store script source in v8::Global. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more cleanup 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 // 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return scriptId + ":" + String16::number(lineNumber) + ":" + String16::numbe r(columnNumber) + breakpointIdSuffix(source); 71 return scriptId + ":" + String16::number(lineNumber) + ":" + String16::numbe r(columnNumber) + breakpointIdSuffix(source);
72 } 72 }
73 73
74 static bool positionComparator(const std::pair<int, int>& a, const std::pair<int , int>& b) 74 static bool positionComparator(const std::pair<int, int>& a, const std::pair<int , int>& b)
75 { 75 {
76 if (a.first != b.first) 76 if (a.first != b.first)
77 return a.first < b.first; 77 return a.first < b.first;
78 return a.second < b.second; 78 return a.second < b.second;
79 } 79 }
80 80
81 static const LChar hexDigits[17] = "0123456789ABCDEF";
82
83 static void appendUnsignedAsHex(unsigned number, String16Builder* destination)
84 {
85 for (size_t i = 0; i < 8; ++i) {
86 destination->append(hexDigits[number & 0xF]);
87 number >>= 4;
88 }
89 }
90
91 // Hash algorithm for substrings is described in "Über die Komplexität der Multi plikation in
92 // eingeschränkten Branchingprogrammmodellen" by Woelfe.
93 // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECT ION00832000000000000000
94 static String16 calculateHash(const String16& str)
95 {
96 static uint64_t prime[] = { 0x3FB75161, 0xAB1F4E4F, 0x82675BC5, 0xCD924D35, 0x81ABE279 };
97 static uint64_t random[] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 };
98 static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA1 1D, 0x8F462907 };
99
100 uint64_t hashes[] = { 0, 0, 0, 0, 0 };
101 uint64_t zi[] = { 1, 1, 1, 1, 1 };
102
103 const size_t hashesSize = PROTOCOL_ARRAY_LENGTH(hashes);
104
105 size_t current = 0;
106 const uint32_t* data = nullptr;
107 data = reinterpret_cast<const uint32_t*>(str.characters16());
108 for (size_t i = 0; i < str.sizeInBytes() / 4; i += 4) {
109 uint32_t v = data[i];
110 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF;
111 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current];
112 zi[current] = (zi[current] * random[current]) % prime[current];
113 current = current == hashesSize - 1 ? 0 : current + 1;
114 }
115 if (str.sizeInBytes() % 4) {
116 uint32_t v = 0;
117 for (size_t i = str.sizeInBytes() - str.sizeInBytes() % 4; i < str.sizeI nBytes(); ++i) {
118 v <<= 8;
119 v |= reinterpret_cast<const uint8_t*>(data)[i];
120 }
121 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF;
122 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current];
123 zi[current] = (zi[current] * random[current]) % prime[current];
124 current = current == hashesSize - 1 ? 0 : current + 1;
125 }
126
127 for (size_t i = 0; i < hashesSize; ++i)
128 hashes[i] = (hashes[i] + zi[i] * (prime[i] - 1)) % prime[i];
129
130 String16Builder hash;
131 for (size_t i = 0; i < hashesSize; ++i)
132 appendUnsignedAsHex(hashes[i], &hash);
133 return hash.toString();
134 }
135
136 static bool hasInternalError(ErrorString* errorString, bool hasError) 81 static bool hasInternalError(ErrorString* errorString, bool hasError)
137 { 82 {
138 if (hasError) 83 if (hasError)
139 *errorString = "Internal error"; 84 *errorString = "Internal error";
140 return hasError; 85 return hasError;
141 } 86 }
142 87
143 static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation(const String16& scriptId, int lineNumber, int columnNumber) 88 static std::unique_ptr<protocol::Debugger::Location> buildProtocolLocation(const String16& scriptId, int lineNumber, int columnNumber)
144 { 89 {
145 return protocol::Debugger::Location::create() 90 return protocol::Debugger::Location::create()
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 127 }
183 128
184 void V8DebuggerAgentImpl::enable() 129 void V8DebuggerAgentImpl::enable()
185 { 130 {
186 // debugger().addListener may result in reporting all parsed scripts to 131 // debugger().addListener may result in reporting all parsed scripts to
187 // the agent so it should already be in enabled state by then. 132 // the agent so it should already be in enabled state by then.
188 m_enabled = true; 133 m_enabled = true;
189 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true); 134 m_state->setBoolean(DebuggerAgentState::debuggerEnabled, true);
190 debugger().debuggerAgentEnabled(); 135 debugger().debuggerAgentEnabled();
191 136
192 std::vector<V8DebuggerParsedScript> compiledScripts; 137 std::vector<std::unique_ptr<V8DebuggerScript>> compiledScripts;
193 debugger().getCompiledScripts(m_session->contextGroupId(), compiledScripts); 138 debugger().getCompiledScripts(m_session->contextGroupId(), compiledScripts);
194 for (size_t i = 0; i < compiledScripts.size(); i++) 139 for (size_t i = 0; i < compiledScripts.size(); i++)
195 didParseSource(compiledScripts[i]); 140 didParseSource(std::move(compiledScripts[i]), true);
196 141
197 // FIXME(WK44513): breakpoints activated flag should be synchronized between all front-ends 142 // FIXME(WK44513): breakpoints activated flag should be synchronized between all front-ends
198 debugger().setBreakpointsActivated(true); 143 debugger().setBreakpointsActivated(true);
199 m_session->changeInstrumentationCounter(+1); 144 m_session->changeInstrumentationCounter(+1);
200 } 145 }
201 146
202 bool V8DebuggerAgentImpl::enabled() 147 bool V8DebuggerAgentImpl::enabled()
203 { 148 {
204 return m_enabled; 149 return m_enabled;
205 } 150 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 } 296 }
352 if (breakpointsCookie->get(breakpointId)) { 297 if (breakpointsCookie->get(breakpointId)) {
353 *errorString = "Breakpoint at specified location already exists."; 298 *errorString = "Breakpoint at specified location already exists.";
354 return; 299 return;
355 } 300 }
356 301
357 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur l, lineNumber, columnNumber, condition, isRegex)); 302 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur l, lineNumber, columnNumber, condition, isRegex));
358 303
359 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); 304 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition);
360 for (const auto& script : m_scripts) { 305 for (const auto& script : m_scripts) {
361 if (!matches(m_debugger, script.second.sourceURL(), url, isRegex)) 306 if (!matches(m_debugger, script.second->sourceURL(), url, isRegex))
362 continue; 307 continue;
363 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi nt(breakpointId, script.first, breakpoint, UserBreakpointSource); 308 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi nt(breakpointId, script.first, breakpoint, UserBreakpointSource);
364 if (location) 309 if (location)
365 (*locations)->addItem(std::move(location)); 310 (*locations)->addItem(std::move(location));
366 } 311 }
367 312
368 *outBreakpointId = breakpointId; 313 *outBreakpointId = breakpointId;
369 } 314 }
370 315
371 static bool parseLocation(ErrorString* errorString, std::unique_ptr<protocol::De bugger::Location> location, String16* scriptId, int* lineNumber, int* columnNumb er) 316 static bool parseLocation(ErrorString* errorString, std::unique_ptr<protocol::De bugger::Location> location, String16* scriptId, int* lineNumber, int* columnNumb er)
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal lFrame* frame) 431 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal lFrame* frame)
487 { 432 {
488 if (!frame) 433 if (!frame)
489 return true; 434 return true;
490 ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID()) ); 435 ScriptsMap::iterator it = m_scripts.find(String16::number(frame->sourceID()) );
491 if (it == m_scripts.end()) { 436 if (it == m_scripts.end()) {
492 // Unknown scripts are blackboxed. 437 // Unknown scripts are blackboxed.
493 return true; 438 return true;
494 } 439 }
495 if (m_blackboxPattern) { 440 if (m_blackboxPattern) {
496 const String16& scriptSourceURL = it->second.sourceURL(); 441 const String16& scriptSourceURL = it->second->sourceURL();
497 if (!scriptSourceURL.isEmpty() && m_blackboxPattern->match(scriptSourceU RL) != -1) 442 if (!scriptSourceURL.isEmpty() && m_blackboxPattern->match(scriptSourceU RL) != -1)
498 return true; 443 return true;
499 } 444 }
500 auto itBlackboxedPositions = m_blackboxedPositions.find(String16::number(fra me->sourceID())); 445 auto itBlackboxedPositions = m_blackboxedPositions.find(String16::number(fra me->sourceID()));
501 if (itBlackboxedPositions == m_blackboxedPositions.end()) 446 if (itBlackboxedPositions == m_blackboxedPositions.end())
502 return false; 447 return false;
503 448
504 const std::vector<std::pair<int, int>>& ranges = itBlackboxedPositions->seco nd; 449 const std::vector<std::pair<int, int>>& ranges = itBlackboxedPositions->seco nd;
505 auto itRange = std::lower_bound(ranges.cbegin(), ranges.cend(), 450 auto itRange = std::lower_bound(ranges.cbegin(), ranges.cend(),
506 std::make_pair(frame->line(), frame->column()), positionComparator); 451 std::make_pair(frame->line(), frame->column()), positionComparator);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 489
545 std::unique_ptr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakp oint(const String16& breakpointId, const String16& scriptId, const ScriptBreakpo int& breakpoint, BreakpointSource source) 490 std::unique_ptr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakp oint(const String16& breakpointId, const String16& scriptId, const ScriptBreakpo int& breakpoint, BreakpointSource source)
546 { 491 {
547 DCHECK(enabled()); 492 DCHECK(enabled());
548 // FIXME: remove these checks once crbug.com/520702 is resolved. 493 // FIXME: remove these checks once crbug.com/520702 is resolved.
549 CHECK(!breakpointId.isEmpty()); 494 CHECK(!breakpointId.isEmpty());
550 CHECK(!scriptId.isEmpty()); 495 CHECK(!scriptId.isEmpty());
551 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); 496 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId);
552 if (scriptIterator == m_scripts.end()) 497 if (scriptIterator == m_scripts.end())
553 return nullptr; 498 return nullptr;
554 const V8DebuggerScript& script = scriptIterator->second; 499 if (breakpoint.lineNumber < scriptIterator->second->startLine() || scriptIte rator->second->endLine() < breakpoint.lineNumber)
555 if (breakpoint.lineNumber < script.startLine() || script.endLine() < breakpo int.lineNumber)
556 return nullptr; 500 return nullptr;
557 501
558 int actualLineNumber; 502 int actualLineNumber;
559 int actualColumnNumber; 503 int actualColumnNumber;
560 String16 debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoin t, &actualLineNumber, &actualColumnNumber, false); 504 String16 debuggerBreakpointId = debugger().setBreakpoint(scriptId, breakpoin t, &actualLineNumber, &actualColumnNumber, false);
561 if (debuggerBreakpointId.isEmpty()) 505 if (debuggerBreakpointId.isEmpty())
562 return nullptr; 506 return nullptr;
563 507
564 m_serverBreakpoints[debuggerBreakpointId] = std::make_pair(breakpointId, sou rce); 508 m_serverBreakpoints[debuggerBreakpointId] = std::make_pair(breakpointId, sou rce);
565 CHECK(!breakpointId.isEmpty()); 509 CHECK(!breakpointId.isEmpty());
566 510
567 m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back(debuggerBreakp ointId); 511 m_breakpointIdToDebuggerBreakpointIds[breakpointId].push_back(debuggerBreakp ointId);
568 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber) ; 512 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber) ;
569 } 513 }
570 514
571 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc riptId, const String16& query, 515 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc riptId, const String16& query,
572 const Maybe<bool>& optionalCaseSensitive, 516 const Maybe<bool>& optionalCaseSensitive,
573 const Maybe<bool>& optionalIsRegex, 517 const Maybe<bool>& optionalIsRegex,
574 std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results) 518 std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results)
575 { 519 {
520 v8::HandleScope handles(m_isolate);
576 ScriptsMap::iterator it = m_scripts.find(scriptId); 521 ScriptsMap::iterator it = m_scripts.find(scriptId);
577 if (it != m_scripts.end()) 522 if (it != m_scripts.end())
578 *results = V8ContentSearchUtil::searchInTextByLines(m_session, it->secon d.source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromM aybe(false)); 523 *results = V8ContentSearchUtil::searchInTextByLines(m_session, toProtoco lString(it->second->source(m_isolate)), query, optionalCaseSensitive.fromMaybe(f alse), optionalIsRegex.fromMaybe(false));
579 else 524 else
580 *error = String16("No script for id: " + scriptId); 525 *error = String16("No script for id: " + scriptId);
581 } 526 }
582 527
583 void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString, 528 void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString,
584 const String16& scriptId, 529 const String16& scriptId,
585 const String16& newContent, 530 const String16& newContent,
586 const Maybe<bool>& preview, 531 const Maybe<bool>& preview,
587 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, 532 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames,
588 Maybe<bool>* stackChanged, 533 Maybe<bool>* stackChanged,
589 Maybe<StackTrace>* asyncStackTrace, 534 Maybe<StackTrace>* asyncStackTrace,
590 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError) 535 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError)
591 { 536 {
592 if (!checkEnabled(errorString)) 537 if (!checkEnabled(errorString))
593 return; 538 return;
594 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals e), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) 539
540 v8::HandleScope handles(m_isolate);
541 v8::Local<v8::String> newSource = toV8String(m_isolate, newContent);
542 if (!debugger().setScriptSource(scriptId, newSource, preview.fromMaybe(false ), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged))
595 return; 543 return;
596 544
545 ScriptsMap::iterator it = m_scripts.find(scriptId);
546 if (it != m_scripts.end())
547 it->second->setSource(m_isolate, newSource);
548
597 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString ); 549 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString );
598 if (!callFrames) 550 if (!callFrames)
599 return; 551 return;
600 *newCallFrames = std::move(callFrames); 552 *newCallFrames = std::move(callFrames);
601 *asyncStackTrace = currentAsyncStackTrace(); 553 *asyncStackTrace = currentAsyncStackTrace();
602
603 ScriptsMap::iterator it = m_scripts.find(scriptId);
604 if (it == m_scripts.end())
605 return;
606 it->second.setSource(newContent);
607 } 554 }
608 555
609 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, 556 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString,
610 const String16& callFrameId, 557 const String16& callFrameId,
611 std::unique_ptr<Array<CallFrame>>* newCallFrames, 558 std::unique_ptr<Array<CallFrame>>* newCallFrames,
612 Maybe<StackTrace>* asyncStackTrace) 559 Maybe<StackTrace>* asyncStackTrace)
613 { 560 {
614 if (!assertPaused(errorString)) 561 if (!assertPaused(errorString))
615 return; 562 return;
616 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId); 563 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId);
(...skipping 21 matching lines...) Expand all
638 585
639 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc riptId, String16* scriptSource) 586 void V8DebuggerAgentImpl::getScriptSource(ErrorString* error, const String16& sc riptId, String16* scriptSource)
640 { 587 {
641 if (!checkEnabled(error)) 588 if (!checkEnabled(error))
642 return; 589 return;
643 ScriptsMap::iterator it = m_scripts.find(scriptId); 590 ScriptsMap::iterator it = m_scripts.find(scriptId);
644 if (it == m_scripts.end()) { 591 if (it == m_scripts.end()) {
645 *error = "No script for id: " + scriptId; 592 *error = "No script for id: " + scriptId;
646 return; 593 return;
647 } 594 }
648 *scriptSource = it->second.source(); 595 v8::HandleScope handles(m_isolate);
596 *scriptSource = toProtocolString(it->second->source(m_isolate));
649 } 597 }
650 598
651 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str ing16& functionId, std::unique_ptr<FunctionDetails>* details) 599 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str ing16& functionId, std::unique_ptr<FunctionDetails>* details)
652 { 600 {
653 if (!checkEnabled(errorString)) 601 if (!checkEnabled(errorString))
654 return; 602 return;
655 InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contex tGroupId(), functionId); 603 InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contex tGroupId(), functionId);
656 if (!scope.initialize()) 604 if (!scope.initialize())
657 return; 605 return;
658 if (!scope.object()->IsFunction()) { 606 if (!scope.object()->IsFunction()) {
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 } 1041 }
1094 1042
1095 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() 1043 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace()
1096 { 1044 {
1097 if (m_pausedContext.IsEmpty()) 1045 if (m_pausedContext.IsEmpty())
1098 return nullptr; 1046 return nullptr;
1099 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain(); 1047 V8StackTraceImpl* stackTrace = m_debugger->currentAsyncCallChain();
1100 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) : nu llptr; 1048 return stackTrace ? stackTrace->buildInspectorObjectForTail(m_debugger) : nu llptr;
1101 } 1049 }
1102 1050
1103 void V8DebuggerAgentImpl::didParseSource(const V8DebuggerParsedScript& parsedScr ipt) 1051 void V8DebuggerAgentImpl::didParseSource(std::unique_ptr<V8DebuggerScript> scrip t, bool success)
1104 { 1052 {
1105 V8DebuggerScript script = parsedScript.script; 1053 v8::HandleScope handles(m_isolate);
1106 1054 String16 scriptSource = toProtocolString(script->source(m_isolate));
1107 bool isDeprecatedSourceURL = false; 1055 bool isDeprecatedSourceURL = false;
1108 if (!parsedScript.success) 1056 if (!success)
1109 script.setSourceURL(V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecatedSourceURL)); 1057 script->setSourceURL(V8ContentSearchUtil::findSourceURL(scriptSource, fa lse, &isDeprecatedSourceURL));
1110 else if (script.hasSourceURL()) 1058 else if (script->hasSourceURL())
1111 V8ContentSearchUtil::findSourceURL(script.source(), false, &isDeprecated SourceURL); 1059 V8ContentSearchUtil::findSourceURL(scriptSource, false, &isDeprecatedSou rceURL);
1112 1060
1113 bool isDeprecatedSourceMappingURL = false; 1061 bool isDeprecatedSourceMappingURL = false;
1114 if (!parsedScript.success) 1062 if (!success)
1115 script.setSourceMappingURL(V8ContentSearchUtil::findSourceMapURL(script. source(), false, &isDeprecatedSourceMappingURL)); 1063 script->setSourceMappingURL(V8ContentSearchUtil::findSourceMapURL(script Source, false, &isDeprecatedSourceMappingURL));
1116 else if (!script.sourceMappingURL().isEmpty()) 1064 else if (!script->sourceMappingURL().isEmpty())
1117 V8ContentSearchUtil::findSourceMapURL(script.source(), false, &isDepreca tedSourceMappingURL); 1065 V8ContentSearchUtil::findSourceMapURL(scriptSource, false, &isDeprecated SourceMappingURL);
1118 1066
1119 script.setHash(calculateHash(script.source())); 1067 bool isContentScript = script->isContentScript();
1120 1068 bool isInternalScript = script->isInternalScript();
1121 int executionContextId = script.executionContextId(); 1069 bool isLiveEdit = script->isLiveEdit();
1122 bool isContentScript = script.isContentScript(); 1070 bool hasSourceURL = script->hasSourceURL();
1123 bool isInternalScript = script.isInternalScript(); 1071 String16 scriptId = script->scriptId();
1124 bool isLiveEdit = script.isLiveEdit(); 1072 String16 scriptURL = script->sourceURL();
1125 bool hasSourceURL = script.hasSourceURL();
1126 String16 scriptURL = script.sourceURL();
1127 String16 sourceMapURL = script.sourceMappingURL();
1128 bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceM appingURL; 1073 bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceM appingURL;
1129 1074
1130 const Maybe<String16>& sourceMapURLParam = sourceMapURL; 1075 const Maybe<String16>& sourceMapURLParam = script->sourceMappingURL();
1131 const bool* isContentScriptParam = isContentScript ? &isContentScript : null ptr; 1076 const bool* isContentScriptParam = isContentScript ? &isContentScript : null ptr;
1132 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n ullptr; 1077 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n ullptr;
1133 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; 1078 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr;
1134 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; 1079 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
1135 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr ecatedCommentWasUsed : nullptr; 1080 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr ecatedCommentWasUsed : nullptr;
1136 if (parsedScript.success) 1081 if (success)
1137 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); 1082 m_frontend.scriptParsed(scriptId, scriptURL, script->startLine(), script ->startColumn(), script->endLine(), script->endColumn(), script->executionContex tId(), script->hash(), isContentScriptParam, isInternalScriptParam, isLiveEditPa ram, sourceMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
1138 else 1083 else
1139 m_frontend.scriptFailedToParse(parsedScript.scriptId, scriptURL, script. startLine(), script.startColumn(), script.endLine(), script.endColumn(), executi onContextId, script.hash(), isContentScriptParam, isInternalScriptParam, sourceM apURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam); 1084 m_frontend.scriptFailedToParse(scriptId, scriptURL, script->startLine(), script->startColumn(), script->endLine(), script->endColumn(), script->executio nContextId(), script->hash(), isContentScriptParam, isInternalScriptParam, sourc eMapURLParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
1140 1085
1141 m_scripts[parsedScript.scriptId] = script; 1086 m_scripts[scriptId] = std::move(script);
1142 1087
1143 if (scriptURL.isEmpty() || !parsedScript.success) 1088 if (scriptURL.isEmpty() || !success)
1144 return; 1089 return;
1145 1090
1146 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints); 1091 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints);
1147 if (!breakpointsCookie) 1092 if (!breakpointsCookie)
1148 return; 1093 return;
1149 1094
1150 for (size_t i = 0; i < breakpointsCookie->size(); ++i) { 1095 for (size_t i = 0; i < breakpointsCookie->size(); ++i) {
1151 auto cookie = breakpointsCookie->at(i); 1096 auto cookie = breakpointsCookie->at(i);
1152 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue: :cast(cookie.second); 1097 protocol::DictionaryValue* breakpointObject = protocol::DictionaryValue: :cast(cookie.second);
1153 bool isRegex; 1098 bool isRegex;
1154 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); 1099 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex);
1155 String16 url; 1100 String16 url;
1156 breakpointObject->getString(DebuggerAgentState::url, &url); 1101 breakpointObject->getString(DebuggerAgentState::url, &url);
1157 if (!matches(m_debugger, scriptURL, url, isRegex)) 1102 if (!matches(m_debugger, scriptURL, url, isRegex))
1158 continue; 1103 continue;
1159 ScriptBreakpoint breakpoint; 1104 ScriptBreakpoint breakpoint;
1160 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber); 1105 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber);
1161 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber); 1106 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber);
1162 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition); 1107 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition);
1163 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi nt(cookie.first, parsedScript.scriptId, breakpoint, UserBreakpointSource); 1108 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi nt(cookie.first, scriptId, breakpoint, UserBreakpointSource);
1164 if (location) 1109 if (location)
1165 m_frontend.breakpointResolved(cookie.first, std::move(location)); 1110 m_frontend.breakpointResolved(cookie.first, std::move(location));
1166 } 1111 }
1167 } 1112 }
1168 1113
1169 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const std::vector<String16>& hitBreakpoints, bool isPromiseRejection) 1114 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const std::vector<String16>& hitBreakpoints, bool isPromiseRejection)
1170 { 1115 {
1171 JavaScriptCallFrames callFrames = debugger().currentCallFrames(1); 1116 JavaScriptCallFrames callFrames = debugger().currentCallFrames(1);
1172 JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin() ->get() : nullptr; 1117 JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin() ->get() : nullptr;
1173 1118
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 { 1242 {
1298 if (!enabled()) 1243 if (!enabled())
1299 return; 1244 return;
1300 m_scheduledDebuggerStep = NoStep; 1245 m_scheduledDebuggerStep = NoStep;
1301 m_scripts.clear(); 1246 m_scripts.clear();
1302 m_blackboxedPositions.clear(); 1247 m_blackboxedPositions.clear();
1303 m_breakpointIdToDebuggerBreakpointIds.clear(); 1248 m_breakpointIdToDebuggerBreakpointIds.clear();
1304 } 1249 }
1305 1250
1306 } // namespace blink 1251 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698