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

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

Issue 2226863003: [DevTools] Reduce API surface of String16. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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/Parser.h" 7 #include "platform/inspector_protocol/Parser.h"
8 #include "platform/inspector_protocol/String16.h" 8 #include "platform/inspector_protocol/String16.h"
9 #include "platform/inspector_protocol/Values.h" 9 #include "platform/inspector_protocol/Values.h"
10 #include "platform/v8_inspector/InjectedScript.h" 10 #include "platform/v8_inspector/InjectedScript.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 case V8DebuggerAgentImpl::DebugCommandBreakpointSource: 63 case V8DebuggerAgentImpl::DebugCommandBreakpointSource:
64 return ":debug"; 64 return ":debug";
65 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource: 65 case V8DebuggerAgentImpl::MonitorCommandBreakpointSource:
66 return ":monitor"; 66 return ":monitor";
67 } 67 }
68 return String16(); 68 return String16();
69 } 69 }
70 70
71 static String16 generateBreakpointId(const String16& scriptId, int lineNumber, i nt columnNumber, V8DebuggerAgentImpl::BreakpointSource source) 71 static String16 generateBreakpointId(const String16& scriptId, int lineNumber, i nt columnNumber, V8DebuggerAgentImpl::BreakpointSource source)
72 { 72 {
73 return scriptId + ":" + String16::fromInteger(lineNumber) + ":" + String16:: fromInteger(columnNumber) + breakpointIdSuffix(source); 73 return scriptId + ":" + protocol::string16FromInteger(lineNumber) + ":" + pr otocol::string16FromInteger(columnNumber) + breakpointIdSuffix(source);
74 } 74 }
75 75
76 static bool positionComparator(const std::pair<int, int>& a, const std::pair<int , int>& b) 76 static bool positionComparator(const std::pair<int, int>& a, const std::pair<int , int>& b)
77 { 77 {
78 if (a.first != b.first) 78 if (a.first != b.first)
79 return a.first < b.first; 79 return a.first < b.first;
80 return a.second < b.second; 80 return a.second < b.second;
81 } 81 }
82 82
83 static bool hasInternalError(ErrorString* errorString, bool hasError) 83 static bool hasInternalError(ErrorString* errorString, bool hasError)
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (optionalColumnNumber.isJust()) { 281 if (optionalColumnNumber.isJust()) {
282 columnNumber = optionalColumnNumber.fromJust(); 282 columnNumber = optionalColumnNumber.fromJust();
283 if (columnNumber < 0) { 283 if (columnNumber < 0) {
284 *errorString = "Incorrect column number"; 284 *errorString = "Incorrect column number";
285 return; 285 return;
286 } 286 }
287 } 287 }
288 String16 condition = optionalCondition.fromMaybe(""); 288 String16 condition = optionalCondition.fromMaybe("");
289 bool isRegex = optionalURLRegex.isJust(); 289 bool isRegex = optionalURLRegex.isJust();
290 290
291 String16 breakpointId = (isRegex ? "/" + url + "/" : url) + ":" + String16:: fromInteger(lineNumber) + ":" + String16::fromInteger(columnNumber); 291 String16 breakpointId = (isRegex ? "/" + url + "/" : url) + ":" + protocol:: string16FromInteger(lineNumber) + ":" + protocol::string16FromInteger(columnNumb er);
292 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints); 292 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints);
293 if (!breakpointsCookie) { 293 if (!breakpointsCookie) {
294 std::unique_ptr<protocol::DictionaryValue> newValue = protocol::Dictiona ryValue::create(); 294 std::unique_ptr<protocol::DictionaryValue> newValue = protocol::Dictiona ryValue::create();
295 breakpointsCookie = newValue.get(); 295 breakpointsCookie = newValue.get();
296 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, std::move( newValue)); 296 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, std::move( newValue));
297 } 297 }
298 if (breakpointsCookie->get(breakpointId)) { 298 if (breakpointsCookie->get(breakpointId)) {
299 *errorString = "Breakpoint at specified location already exists."; 299 *errorString = "Breakpoint at specified location already exists.";
300 return; 300 return;
301 } 301 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 { 426 {
427 DCHECK(enabled()); 427 DCHECK(enabled());
428 JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[ 0].get() : nullptr; 428 JavaScriptCallFrame* frame = m_pausedCallFrames.size() ? m_pausedCallFrames[ 0].get() : nullptr;
429 return isCallFrameWithUnknownScriptOrBlackboxed(frame); 429 return isCallFrameWithUnknownScriptOrBlackboxed(frame);
430 } 430 }
431 431
432 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal lFrame* frame) 432 bool V8DebuggerAgentImpl::isCallFrameWithUnknownScriptOrBlackboxed(JavaScriptCal lFrame* frame)
433 { 433 {
434 if (!frame) 434 if (!frame)
435 return true; 435 return true;
436 ScriptsMap::iterator it = m_scripts.find(String16::fromInteger(frame->source ID())); 436 ScriptsMap::iterator it = m_scripts.find(protocol::string16FromInteger(frame ->sourceID()));
437 if (it == m_scripts.end()) { 437 if (it == m_scripts.end()) {
438 // Unknown scripts are blackboxed. 438 // Unknown scripts are blackboxed.
439 return true; 439 return true;
440 } 440 }
441 if (m_blackboxPattern) { 441 if (m_blackboxPattern) {
442 const String16& scriptSourceURL = it->second->sourceURL(); 442 const String16& scriptSourceURL = it->second->sourceURL();
443 if (!scriptSourceURL.isEmpty() && m_blackboxPattern->match(scriptSourceU RL) != -1) 443 if (!scriptSourceURL.isEmpty() && m_blackboxPattern->match(scriptSourceU RL) != -1)
444 return true; 444 return true;
445 } 445 }
446 auto itBlackboxedPositions = m_blackboxedPositions.find(String16::fromIntege r(frame->sourceID())); 446 auto itBlackboxedPositions = m_blackboxedPositions.find(protocol::string16Fr omInteger(frame->sourceID()));
447 if (itBlackboxedPositions == m_blackboxedPositions.end()) 447 if (itBlackboxedPositions == m_blackboxedPositions.end())
448 return false; 448 return false;
449 449
450 const std::vector<std::pair<int, int>>& ranges = itBlackboxedPositions->seco nd; 450 const std::vector<std::pair<int, int>>& ranges = itBlackboxedPositions->seco nd;
451 auto itRange = std::lower_bound(ranges.begin(), ranges.end(), 451 auto itRange = std::lower_bound(ranges.begin(), ranges.end(),
452 std::make_pair(frame->line(), frame->column()), positionComparator); 452 std::make_pair(frame->line(), frame->column()), positionComparator);
453 // Ranges array contains positions in script where blackbox state is changed . 453 // Ranges array contains positions in script where blackbox state is changed .
454 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blac kboxed... 454 // [(0,0) ... ranges[0]) isn't blackboxed, [ranges[0] ... ranges[1]) is blac kboxed...
455 return std::distance(ranges.begin(), itRange) % 2; 455 return std::distance(ranges.begin(), itRange) % 2;
456 } 456 }
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 } 1057 }
1058 } 1058 }
1059 1059
1060 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const std::vector<String16>& hitBreakpoints, bool isPromiseRejection) 1060 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const std::vector<String16>& hitBreakpoints, bool isPromiseRejection)
1061 { 1061 {
1062 JavaScriptCallFrames callFrames = m_debugger->currentCallFrames(1); 1062 JavaScriptCallFrames callFrames = m_debugger->currentCallFrames(1);
1063 JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin() ->get() : nullptr; 1063 JavaScriptCallFrame* topCallFrame = !callFrames.empty() ? callFrames.begin() ->get() : nullptr;
1064 1064
1065 // Skip pause in internal scripts (e.g. InjectedScriptSource.js). 1065 // Skip pause in internal scripts (e.g. InjectedScriptSource.js).
1066 if (topCallFrame) { 1066 if (topCallFrame) {
1067 ScriptsMap::iterator it = m_scripts.find(String16::fromInteger(topCallFr ame->sourceID())); 1067 ScriptsMap::iterator it = m_scripts.find(protocol::string16FromInteger(t opCallFrame->sourceID()));
1068 if (it != m_scripts.end() && it->second->isInternalScript()) 1068 if (it != m_scripts.end() && it->second->isInternalScript())
1069 return RequestStepFrame; 1069 return RequestStepFrame;
1070 } 1070 }
1071 1071
1072 V8DebuggerAgentImpl::SkipPauseRequest result; 1072 V8DebuggerAgentImpl::SkipPauseRequest result;
1073 if (m_skipAllPauses) 1073 if (m_skipAllPauses)
1074 result = RequestContinue; 1074 result = RequestContinue;
1075 else if (!hitBreakpoints.empty()) 1075 else if (!hitBreakpoints.empty())
1076 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i n frameworks. 1076 result = RequestNoSkip; // Don't skip explicit breakpoints even if set i n frameworks.
1077 else if (!exception.IsEmpty()) 1077 else if (!exception.IsEmpty())
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 { 1195 {
1196 if (!enabled()) 1196 if (!enabled())
1197 return; 1197 return;
1198 m_scheduledDebuggerStep = NoStep; 1198 m_scheduledDebuggerStep = NoStep;
1199 m_scripts.clear(); 1199 m_scripts.clear();
1200 m_blackboxedPositions.clear(); 1200 m_blackboxedPositions.clear();
1201 m_breakpointIdToDebuggerBreakpointIds.clear(); 1201 m_breakpointIdToDebuggerBreakpointIds.clear();
1202 } 1202 }
1203 1203
1204 } // namespace blink 1204 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698