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

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

Issue 2004313003: DevTools: migrate from OwnPtr to std::unique_ptr for inspector protocol classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return hash.toString(); 140 return hash.toString();
141 } 141 }
142 142
143 static bool hasInternalError(ErrorString* errorString, bool hasError) 143 static bool hasInternalError(ErrorString* errorString, bool hasError)
144 { 144 {
145 if (hasError) 145 if (hasError)
146 *errorString = "Internal error"; 146 *errorString = "Internal error";
147 return hasError; 147 return hasError;
148 } 148 }
149 149
150 static PassOwnPtr<protocol::Debugger::Location> buildProtocolLocation(const Stri ng16& 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::Frontend::Debugger* frontend, protocol::DictionaryValue* state) 158 V8DebuggerAgentImpl::V8DebuggerAgentImpl(V8InspectorSessionImpl* session, protoc ol::Frontend::Debugger* frontend, protocol::DictionaryValue* state)
159 : m_debugger(session->debugger()) 159 : m_debugger(session->debugger())
160 , m_session(session) 160 , m_session(session)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return; 307 return;
308 debugger().setBreakpointsActivated(active); 308 debugger().setBreakpointsActivated(active);
309 } 309 }
310 310
311 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped) 311 void V8DebuggerAgentImpl::setSkipAllPauses(ErrorString*, bool skipped)
312 { 312 {
313 m_skipAllPauses = skipped; 313 m_skipAllPauses = skipped;
314 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses); 314 m_state->setBoolean(DebuggerAgentState::skipAllPauses, m_skipAllPauses);
315 } 315 }
316 316
317 static PassOwnPtr<protocol::DictionaryValue> buildObjectForBreakpointCookie(cons t String16& url, int lineNumber, int columnNumber, const String16& condition, bo ol isRegex) 317 static std::unique_ptr<protocol::DictionaryValue> buildObjectForBreakpointCookie (const String16& url, int lineNumber, int columnNumber, const String16& conditio n, bool isRegex)
318 { 318 {
319 OwnPtr<protocol::DictionaryValue> breakpointObject = protocol::DictionaryVal ue::create(); 319 std::unique_ptr<protocol::DictionaryValue> breakpointObject = protocol::Dict ionaryValue::create();
320 breakpointObject->setString(DebuggerAgentState::url, url); 320 breakpointObject->setString(DebuggerAgentState::url, url);
321 breakpointObject->setNumber(DebuggerAgentState::lineNumber, lineNumber); 321 breakpointObject->setNumber(DebuggerAgentState::lineNumber, lineNumber);
322 breakpointObject->setNumber(DebuggerAgentState::columnNumber, columnNumber); 322 breakpointObject->setNumber(DebuggerAgentState::columnNumber, columnNumber);
323 breakpointObject->setString(DebuggerAgentState::condition, condition); 323 breakpointObject->setString(DebuggerAgentState::condition, condition);
324 breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex); 324 breakpointObject->setBoolean(DebuggerAgentState::isRegex, isRegex);
325 return breakpointObject; 325 return breakpointObject;
326 } 326 }
327 327
328 static bool matches(V8DebuggerImpl* debugger, const String16& url, const String1 6& pattern, bool isRegex) 328 static bool matches(V8DebuggerImpl* debugger, const String16& url, const String1 6& pattern, bool isRegex)
329 { 329 {
330 if (isRegex) { 330 if (isRegex) {
331 V8Regex regex(debugger, pattern, true); 331 V8Regex regex(debugger, pattern, true);
332 return regex.match(url) != -1; 332 return regex.match(url) != -1;
333 } 333 }
334 return url == pattern; 334 return url == pattern;
335 } 335 }
336 336
337 void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, 337 void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString,
338 int lineNumber, 338 int lineNumber,
339 const Maybe<String16>& optionalURL, 339 const Maybe<String16>& optionalURL,
340 const Maybe<String16>& optionalURLRegex, 340 const Maybe<String16>& optionalURLRegex,
341 const Maybe<int>& optionalColumnNumber, 341 const Maybe<int>& optionalColumnNumber,
342 const Maybe<String16>& optionalCondition, 342 const Maybe<String16>& optionalCondition,
343 String16* outBreakpointId, 343 String16* outBreakpointId,
344 OwnPtr<protocol::Array<protocol::Debugger::Location>>* locations) 344 std::unique_ptr<protocol::Array<protocol::Debugger::Location>>* locations)
345 { 345 {
346 *locations = Array<protocol::Debugger::Location>::create(); 346 *locations = Array<protocol::Debugger::Location>::create();
347 if (optionalURL.isJust() == optionalURLRegex.isJust()) { 347 if (optionalURL.isJust() == optionalURLRegex.isJust()) {
348 *errorString = "Either url or urlRegex must be specified."; 348 *errorString = "Either url or urlRegex must be specified.";
349 return; 349 return;
350 } 350 }
351 351
352 String16 url = optionalURL.isJust() ? optionalURL.fromJust() : optionalURLRe gex.fromJust(); 352 String16 url = optionalURL.isJust() ? optionalURL.fromJust() : optionalURLRe gex.fromJust();
353 int columnNumber = 0; 353 int columnNumber = 0;
354 if (optionalColumnNumber.isJust()) { 354 if (optionalColumnNumber.isJust()) {
355 columnNumber = optionalColumnNumber.fromJust(); 355 columnNumber = optionalColumnNumber.fromJust();
356 if (columnNumber < 0) { 356 if (columnNumber < 0) {
357 *errorString = "Incorrect column number"; 357 *errorString = "Incorrect column number";
358 return; 358 return;
359 } 359 }
360 } 360 }
361 String16 condition = optionalCondition.fromMaybe(""); 361 String16 condition = optionalCondition.fromMaybe("");
362 bool isRegex = optionalURLRegex.isJust(); 362 bool isRegex = optionalURLRegex.isJust();
363 363
364 String16 breakpointId = (isRegex ? "/" + url + "/" : url) + ":" + String16:: number(lineNumber) + ":" + String16::number(columnNumber); 364 String16 breakpointId = (isRegex ? "/" + url + "/" : url) + ":" + String16:: number(lineNumber) + ":" + String16::number(columnNumber);
365 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints); 365 protocol::DictionaryValue* breakpointsCookie = m_state->getObject(DebuggerAg entState::javaScriptBreakpoints);
366 if (!breakpointsCookie) { 366 if (!breakpointsCookie) {
367 OwnPtr<protocol::DictionaryValue> newValue = protocol::DictionaryValue:: create(); 367 std::unique_ptr<protocol::DictionaryValue> newValue = protocol::Dictiona ryValue::create();
368 breakpointsCookie = newValue.get(); 368 breakpointsCookie = newValue.get();
369 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, std::move( newValue)); 369 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, std::move( newValue));
370 } 370 }
371 if (breakpointsCookie->get(breakpointId)) { 371 if (breakpointsCookie->get(breakpointId)) {
372 *errorString = "Breakpoint at specified location already exists."; 372 *errorString = "Breakpoint at specified location already exists.";
373 return; 373 return;
374 } 374 }
375 375
376 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur l, lineNumber, columnNumber, condition, isRegex)); 376 breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(ur l, lineNumber, columnNumber, condition, isRegex));
377 377
378 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); 378 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition);
379 for (auto& script : m_scripts) { 379 for (auto& script : m_scripts) {
380 if (!matches(m_debugger, script.second->sourceURL(), url, isRegex)) 380 if (!matches(m_debugger, script.second->sourceURL(), url, isRegex))
381 continue; 381 continue;
382 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(breakp ointId, script.first, breakpoint, UserBreakpointSource); 382 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi nt(breakpointId, script.first, breakpoint, UserBreakpointSource);
383 if (location) 383 if (location)
384 (*locations)->addItem(std::move(location)); 384 (*locations)->addItem(std::move(location));
385 } 385 }
386 386
387 *outBreakpointId = breakpointId; 387 *outBreakpointId = breakpointId;
388 } 388 }
389 389
390 static bool parseLocation(ErrorString* errorString, PassOwnPtr<protocol::Debugge r::Location> location, String16* scriptId, int* lineNumber, int* columnNumber) 390 static bool parseLocation(ErrorString* errorString, std::unique_ptr<protocol::De bugger::Location> location, String16* scriptId, int* lineNumber, int* columnNumb er)
391 { 391 {
392 *scriptId = location->getScriptId(); 392 *scriptId = location->getScriptId();
393 *lineNumber = location->getLineNumber(); 393 *lineNumber = location->getLineNumber();
394 *columnNumber = location->getColumnNumber(0); 394 *columnNumber = location->getColumnNumber(0);
395 return true; 395 return true;
396 } 396 }
397 397
398 void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString, 398 void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString,
399 PassOwnPtr<protocol::Debugger::Location> location, 399 std::unique_ptr<protocol::Debugger::Location> location,
400 const Maybe<String16>& optionalCondition, 400 const Maybe<String16>& optionalCondition,
401 String16* outBreakpointId, 401 String16* outBreakpointId,
402 OwnPtr<protocol::Debugger::Location>* actualLocation) 402 std::unique_ptr<protocol::Debugger::Location>* actualLocation)
403 { 403 {
404 String16 scriptId; 404 String16 scriptId;
405 int lineNumber; 405 int lineNumber;
406 int columnNumber; 406 int columnNumber;
407 407
408 if (!parseLocation(errorString, std::move(location), &scriptId, &lineNumber, &columnNumber)) 408 if (!parseLocation(errorString, std::move(location), &scriptId, &lineNumber, &columnNumber))
409 return; 409 return;
410 410
411 String16 condition = optionalCondition.fromMaybe(""); 411 String16 condition = optionalCondition.fromMaybe("");
412 412
(...skipping 30 matching lines...) Expand all
443 for (size_t i = 0; i < ids->size(); ++i) { 443 for (size_t i = 0; i < ids->size(); ++i) {
444 const String16& debuggerBreakpointId = ids->at(i); 444 const String16& debuggerBreakpointId = ids->at(i);
445 445
446 debugger().removeBreakpoint(debuggerBreakpointId); 446 debugger().removeBreakpoint(debuggerBreakpointId);
447 m_serverBreakpoints.remove(debuggerBreakpointId); 447 m_serverBreakpoints.remove(debuggerBreakpointId);
448 } 448 }
449 m_breakpointIdToDebuggerBreakpointIds.remove(breakpointId); 449 m_breakpointIdToDebuggerBreakpointIds.remove(breakpointId);
450 } 450 }
451 451
452 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, 452 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString,
453 PassOwnPtr<protocol::Debugger::Location> location, 453 std::unique_ptr<protocol::Debugger::Location> location,
454 const protocol::Maybe<bool>& interstateLocationOpt) 454 const protocol::Maybe<bool>& interstateLocationOpt)
455 { 455 {
456 if (!checkEnabled(errorString)) 456 if (!checkEnabled(errorString))
457 return; 457 return;
458 if (!m_continueToLocationBreakpointId.isEmpty()) { 458 if (!m_continueToLocationBreakpointId.isEmpty()) {
459 debugger().removeBreakpoint(m_continueToLocationBreakpointId); 459 debugger().removeBreakpoint(m_continueToLocationBreakpointId);
460 m_continueToLocationBreakpointId = ""; 460 m_continueToLocationBreakpointId = "";
461 } 461 }
462 462
463 String16 scriptId; 463 String16 scriptId;
464 int lineNumber; 464 int lineNumber;
465 int columnNumber; 465 int columnNumber;
466 466
467 if (!parseLocation(errorString, std::move(location), &scriptId, &lineNumber, &columnNumber)) 467 if (!parseLocation(errorString, std::move(location), &scriptId, &lineNumber, &columnNumber))
468 return; 468 return;
469 469
470 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); 470 ScriptBreakpoint breakpoint(lineNumber, columnNumber, "");
471 m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakp oint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false)); 471 m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakp oint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false));
472 resume(errorString); 472 resume(errorString);
473 } 473 }
474 474
475 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, OwnPtr<Array<Ca llFrame>>* callFrames, Maybe<StackTrace>* asyncStackTrace) 475 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, std::unique_ptr <Array<CallFrame>>* callFrames, Maybe<StackTrace>* asyncStackTrace)
476 { 476 {
477 if (!assertPaused(errorString)) 477 if (!assertPaused(errorString))
478 return; 478 return;
479 m_pausedCallFrames.swap(debugger().currentCallFrames()); 479 m_pausedCallFrames.swap(debugger().currentCallFrames());
480 *callFrames = currentCallFrames(errorString); 480 *callFrames = currentCallFrames(errorString);
481 if (!*callFrames) 481 if (!*callFrames)
482 return; 482 return;
483 *asyncStackTrace = currentAsyncStackTrace(); 483 *asyncStackTrace = currentAsyncStackTrace();
484 } 484 }
485 485
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 if (m_skippedStepFrameCount >= maxSkipStepFrameCount) 551 if (m_skippedStepFrameCount >= maxSkipStepFrameCount)
552 return RequestStepOut; 552 return RequestStepOut;
553 553
554 if (!m_skippedStepFrameCount) 554 if (!m_skippedStepFrameCount)
555 m_recursionLevelForStepFrame = 1; 555 m_recursionLevelForStepFrame = 1;
556 556
557 ++m_skippedStepFrameCount; 557 ++m_skippedStepFrameCount;
558 return RequestStepFrame; 558 return RequestStepFrame;
559 } 559 }
560 560
561 PassOwnPtr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakpoint( const String16& breakpointId, const String16& scriptId, const ScriptBreakpoint& breakpoint, BreakpointSource source) 561 std::unique_ptr<protocol::Debugger::Location> V8DebuggerAgentImpl::resolveBreakp oint(const String16& breakpointId, const String16& scriptId, const ScriptBreakpo int& breakpoint, BreakpointSource source)
562 { 562 {
563 DCHECK(enabled()); 563 DCHECK(enabled());
564 // FIXME: remove these checks once crbug.com/520702 is resolved. 564 // FIXME: remove these checks once crbug.com/520702 is resolved.
565 CHECK(!breakpointId.isEmpty()); 565 CHECK(!breakpointId.isEmpty());
566 CHECK(!scriptId.isEmpty()); 566 CHECK(!scriptId.isEmpty());
567 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId); 567 ScriptsMap::iterator scriptIterator = m_scripts.find(scriptId);
568 if (scriptIterator == m_scripts.end()) 568 if (scriptIterator == m_scripts.end())
569 return nullptr; 569 return nullptr;
570 V8DebuggerScript* script = scriptIterator->second; 570 V8DebuggerScript* script = scriptIterator->second;
571 if (breakpoint.lineNumber < script->startLine() || script->endLine() < break point.lineNumber) 571 if (breakpoint.lineNumber < script->startLine() || script->endLine() < break point.lineNumber)
(...skipping 12 matching lines...) Expand all
584 584
585 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId); 585 BreakpointIdToDebuggerBreakpointIdsMap::iterator debuggerBreakpointIdsIterat or = m_breakpointIdToDebuggerBreakpointIds.find(breakpointId);
586 debuggerBreakpointIdsIterator->second->append(debuggerBreakpointId); 586 debuggerBreakpointIdsIterator->second->append(debuggerBreakpointId);
587 587
588 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber) ; 588 return buildProtocolLocation(scriptId, actualLineNumber, actualColumnNumber) ;
589 } 589 }
590 590
591 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc riptId, const String16& query, 591 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String16& sc riptId, const String16& query,
592 const Maybe<bool>& optionalCaseSensitive, 592 const Maybe<bool>& optionalCaseSensitive,
593 const Maybe<bool>& optionalIsRegex, 593 const Maybe<bool>& optionalIsRegex,
594 OwnPtr<Array<protocol::Debugger::SearchMatch>>* results) 594 std::unique_ptr<Array<protocol::Debugger::SearchMatch>>* results)
595 { 595 {
596 ScriptsMap::iterator it = m_scripts.find(scriptId); 596 ScriptsMap::iterator it = m_scripts.find(scriptId);
597 if (it != m_scripts.end()) 597 if (it != m_scripts.end())
598 *results = V8ContentSearchUtil::searchInTextByLines(m_session, it->secon d->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.from Maybe(false)); 598 *results = V8ContentSearchUtil::searchInTextByLines(m_session, it->secon d->source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.from Maybe(false));
599 else 599 else
600 *error = String16("No script for id: " + scriptId); 600 *error = String16("No script for id: " + scriptId);
601 } 601 }
602 602
603 void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString, 603 void V8DebuggerAgentImpl::setScriptSource(ErrorString* errorString,
604 const String16& scriptId, 604 const String16& scriptId,
605 const String16& newContent, 605 const String16& newContent,
606 const Maybe<bool>& preview, 606 const Maybe<bool>& preview,
607 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, 607 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames,
608 Maybe<bool>* stackChanged, 608 Maybe<bool>* stackChanged,
609 Maybe<StackTrace>* asyncStackTrace, 609 Maybe<StackTrace>* asyncStackTrace,
610 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError) 610 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError)
611 { 611 {
612 if (!checkEnabled(errorString)) 612 if (!checkEnabled(errorString))
613 return; 613 return;
614 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals e), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged)) 614 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals e), errorString, optOutCompileError, &m_pausedCallFrames, stackChanged))
615 return; 615 return;
616 616
617 OwnPtr<Array<CallFrame>> callFrames = currentCallFrames(errorString); 617 std::unique_ptr<Array<CallFrame>> callFrames = currentCallFrames(errorString );
618 if (!callFrames) 618 if (!callFrames)
619 return; 619 return;
620 *newCallFrames = std::move(callFrames); 620 *newCallFrames = std::move(callFrames);
621 *asyncStackTrace = currentAsyncStackTrace(); 621 *asyncStackTrace = currentAsyncStackTrace();
622 622
623 ScriptsMap::iterator it = m_scripts.find(scriptId); 623 ScriptsMap::iterator it = m_scripts.find(scriptId);
624 if (it == m_scripts.end()) 624 if (it == m_scripts.end())
625 return; 625 return;
626 it->second->setSource(newContent); 626 it->second->setSource(newContent);
627 } 627 }
628 628
629 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, 629 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString,
630 const String16& callFrameId, 630 const String16& callFrameId,
631 OwnPtr<Array<CallFrame>>* newCallFrames, 631 std::unique_ptr<Array<CallFrame>>* newCallFrames,
632 Maybe<StackTrace>* asyncStackTrace) 632 Maybe<StackTrace>* asyncStackTrace)
633 { 633 {
634 if (!assertPaused(errorString)) 634 if (!assertPaused(errorString))
635 return; 635 return;
636 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId); 636 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId);
637 if (!scope.initialize()) 637 if (!scope.initialize())
638 return; 638 return;
639 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { 639 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) {
640 *errorString = "Could not find call frame with given id"; 640 *errorString = "Could not find call frame with given id";
641 return; 641 return;
(...skipping 18 matching lines...) Expand all
660 if (!checkEnabled(error)) 660 if (!checkEnabled(error))
661 return; 661 return;
662 ScriptsMap::iterator it = m_scripts.find(scriptId); 662 ScriptsMap::iterator it = m_scripts.find(scriptId);
663 if (it == m_scripts.end()) { 663 if (it == m_scripts.end()) {
664 *error = "No script for id: " + scriptId; 664 *error = "No script for id: " + scriptId;
665 return; 665 return;
666 } 666 }
667 *scriptSource = it->second->source(); 667 *scriptSource = it->second->source();
668 } 668 }
669 669
670 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str ing16& functionId, OwnPtr<FunctionDetails>* details) 670 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str ing16& functionId, std::unique_ptr<FunctionDetails>* details)
671 { 671 {
672 if (!checkEnabled(errorString)) 672 if (!checkEnabled(errorString))
673 return; 673 return;
674 InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contex tGroupId(), functionId); 674 InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contex tGroupId(), functionId);
675 if (!scope.initialize()) 675 if (!scope.initialize())
676 return; 676 return;
677 if (!scope.object()->IsFunction()) { 677 if (!scope.object()->IsFunction()) {
678 *errorString = "Value with given id is not a function"; 678 *errorString = "Value with given id is not a function";
679 return; 679 return;
680 } 680 }
681 v8::Local<v8::Function> function = scope.object().As<v8::Function>(); 681 v8::Local<v8::Function> function = scope.object().As<v8::Function>();
682 682
683 v8::Local<v8::Value> scopesValue; 683 v8::Local<v8::Value> scopesValue;
684 v8::Local<v8::Array> scopes; 684 v8::Local<v8::Array> scopes;
685 if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValu e->IsArray()) { 685 if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValu e->IsArray()) {
686 scopes = scopesValue.As<v8::Array>(); 686 scopes = scopesValue.As<v8::Array>();
687 if (!scope.injectedScript()->wrapPropertyInArray(errorString, scopes, to V8StringInternalized(m_isolate, "object"), scope.objectGroupName())) 687 if (!scope.injectedScript()->wrapPropertyInArray(errorString, scopes, to V8StringInternalized(m_isolate, "object"), scope.objectGroupName()))
688 return; 688 return;
689 } 689 }
690 690
691 OwnPtr<FunctionDetails> functionDetails = FunctionDetails::create() 691 std::unique_ptr<FunctionDetails> functionDetails = FunctionDetails::create()
692 .setLocation(buildProtocolLocation(String16::number(function->ScriptId() ), function->GetScriptLineNumber(), function->GetScriptColumnNumber())) 692 .setLocation(buildProtocolLocation(String16::number(function->ScriptId() ), function->GetScriptLineNumber(), function->GetScriptColumnNumber()))
693 .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName()) ) 693 .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName()) )
694 .setIsGenerator(function->IsGeneratorFunction()).build(); 694 .setIsGenerator(function->IsGeneratorFunction()).build();
695 695
696 if (!scopes.IsEmpty()) { 696 if (!scopes.IsEmpty()) {
697 protocol::ErrorSupport errorSupport; 697 protocol::ErrorSupport errorSupport;
698 OwnPtr<protocol::Array<protocol::Debugger::Scope>> scopeChain = protocol ::Array<protocol::Debugger::Scope>::parse(toProtocolValue(scope.context(), scope s).get(), &errorSupport); 698 std::unique_ptr<protocol::Array<protocol::Debugger::Scope>> scopeChain = protocol::Array<protocol::Debugger::Scope>::parse(toProtocolValue(scope.context (), scopes).get(), &errorSupport);
699 if (hasInternalError(errorString, errorSupport.hasErrors())) 699 if (hasInternalError(errorString, errorSupport.hasErrors()))
700 return; 700 return;
701 functionDetails->setScopeChain(std::move(scopeChain)); 701 functionDetails->setScopeChain(std::move(scopeChain));
702 } 702 }
703 703
704 *details = std::move(functionDetails); 704 *details = std::move(functionDetails);
705 } 705 }
706 706
707 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co nst String16& objectId, OwnPtr<GeneratorObjectDetails>* outDetails) 707 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co nst String16& objectId, std::unique_ptr<GeneratorObjectDetails>* outDetails)
708 { 708 {
709 if (!checkEnabled(errorString)) 709 if (!checkEnabled(errorString))
710 return; 710 return;
711 InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contex tGroupId(), objectId); 711 InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contex tGroupId(), objectId);
712 if (!scope.initialize()) 712 if (!scope.initialize())
713 return; 713 return;
714 if (!scope.object()->IsObject()) { 714 if (!scope.object()->IsObject()) {
715 *errorString = "Value with given id is not an Object"; 715 *errorString = "Value with given id is not an Object";
716 return; 716 return;
717 } 717 }
718 v8::Local<v8::Object> object = scope.object().As<v8::Object>(); 718 v8::Local<v8::Object> object = scope.object().As<v8::Object>();
719 719
720 v8::Local<v8::Object> detailsObject; 720 v8::Local<v8::Object> detailsObject;
721 v8::Local<v8::Value> detailsValue = debugger().generatorObjectDetails(object ); 721 v8::Local<v8::Value> detailsValue = debugger().generatorObjectDetails(object );
722 if (hasInternalError(errorString, !detailsValue->IsObject() || !detailsValue ->ToObject(scope.context()).ToLocal(&detailsObject))) 722 if (hasInternalError(errorString, !detailsValue->IsObject() || !detailsValue ->ToObject(scope.context()).ToLocal(&detailsObject)))
723 return; 723 return;
724 724
725 if (!scope.injectedScript()->wrapObjectProperty(errorString, detailsObject, toV8StringInternalized(m_isolate, "function"), scope.objectGroupName())) 725 if (!scope.injectedScript()->wrapObjectProperty(errorString, detailsObject, toV8StringInternalized(m_isolate, "function"), scope.objectGroupName()))
726 return; 726 return;
727 727
728 protocol::ErrorSupport errors; 728 protocol::ErrorSupport errors;
729 OwnPtr<GeneratorObjectDetails> protocolDetails = GeneratorObjectDetails::par se(toProtocolValue(scope.context(), detailsObject).get(), &errors); 729 std::unique_ptr<GeneratorObjectDetails> protocolDetails = GeneratorObjectDet ails::parse(toProtocolValue(scope.context(), detailsObject).get(), &errors);
730 if (hasInternalError(errorString, !protocolDetails)) 730 if (hasInternalError(errorString, !protocolDetails))
731 return; 731 return;
732 *outDetails = std::move(protocolDetails); 732 *outDetails = std::move(protocolDetails);
733 } 733 }
734 734
735 void V8DebuggerAgentImpl::getCollectionEntries(ErrorString* errorString, const S tring16& objectId, OwnPtr<protocol::Array<CollectionEntry>>* outEntries) 735 void V8DebuggerAgentImpl::getCollectionEntries(ErrorString* errorString, const S tring16& objectId, std::unique_ptr<protocol::Array<CollectionEntry>>* outEntries )
736 { 736 {
737 if (!checkEnabled(errorString)) 737 if (!checkEnabled(errorString))
738 return; 738 return;
739 InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contex tGroupId(), objectId); 739 InjectedScript::ObjectScope scope(errorString, m_debugger, m_session->contex tGroupId(), objectId);
740 if (!scope.initialize()) 740 if (!scope.initialize())
741 return; 741 return;
742 if (!scope.object()->IsObject()) { 742 if (!scope.object()->IsObject()) {
743 *errorString = "Object with given id is not a collection"; 743 *errorString = "Object with given id is not a collection";
744 return; 744 return;
745 } 745 }
746 v8::Local<v8::Object> object = scope.object().As<v8::Object>(); 746 v8::Local<v8::Object> object = scope.object().As<v8::Object>();
747 747
748 v8::Local<v8::Value> entriesValue = m_debugger->collectionEntries(object); 748 v8::Local<v8::Value> entriesValue = m_debugger->collectionEntries(object);
749 if (hasInternalError(errorString, entriesValue.IsEmpty())) 749 if (hasInternalError(errorString, entriesValue.IsEmpty()))
750 return; 750 return;
751 if (entriesValue->IsUndefined()) { 751 if (entriesValue->IsUndefined()) {
752 *errorString = "Object with given id is not a collection"; 752 *errorString = "Object with given id is not a collection";
753 return; 753 return;
754 } 754 }
755 if (hasInternalError(errorString, !entriesValue->IsArray())) 755 if (hasInternalError(errorString, !entriesValue->IsArray()))
756 return; 756 return;
757 v8::Local<v8::Array> entriesArray = entriesValue.As<v8::Array>(); 757 v8::Local<v8::Array> entriesArray = entriesValue.As<v8::Array>();
758 if (!scope.injectedScript()->wrapPropertyInArray(errorString, entriesArray, toV8StringInternalized(m_isolate, "key"), scope.objectGroupName())) 758 if (!scope.injectedScript()->wrapPropertyInArray(errorString, entriesArray, toV8StringInternalized(m_isolate, "key"), scope.objectGroupName()))
759 return; 759 return;
760 if (!scope.injectedScript()->wrapPropertyInArray(errorString, entriesArray, toV8StringInternalized(m_isolate, "value"), scope.objectGroupName())) 760 if (!scope.injectedScript()->wrapPropertyInArray(errorString, entriesArray, toV8StringInternalized(m_isolate, "value"), scope.objectGroupName()))
761 return; 761 return;
762 protocol::ErrorSupport errors; 762 protocol::ErrorSupport errors;
763 OwnPtr<protocol::Array<CollectionEntry>> entries = protocol::Array<Collectio nEntry>::parse(toProtocolValue(scope.context(), entriesArray).get(), &errors); 763 std::unique_ptr<protocol::Array<CollectionEntry>> entries = protocol::Array< CollectionEntry>::parse(toProtocolValue(scope.context(), entriesArray).get(), &e rrors);
764 if (hasInternalError(errorString, !entries)) 764 if (hasInternalError(errorString, !entries))
765 return; 765 return;
766 *outEntries = std::move(entries); 766 *outEntries = std::move(entries);
767 } 767 }
768 768
769 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas on, PassOwnPtr<protocol::DictionaryValue> data) 769 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas on, std::unique_ptr<protocol::DictionaryValue> data)
770 { 770 {
771 if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseSc heduled || debugger().isPaused() || !debugger().breakpointsActivated()) 771 if (!enabled() || m_scheduledDebuggerStep == StepInto || m_javaScriptPauseSc heduled || debugger().isPaused() || !debugger().breakpointsActivated())
772 return; 772 return;
773 m_breakReason = breakReason; 773 m_breakReason = breakReason;
774 m_breakAuxData = std::move(data); 774 m_breakAuxData = std::move(data);
775 m_pausingOnNativeEvent = true; 775 m_pausingOnNativeEvent = true;
776 m_skipNextDebuggerStepOut = false; 776 m_skipNextDebuggerStepOut = false;
777 debugger().setPauseOnNextStatement(true); 777 debugger().setPauseOnNextStatement(true);
778 } 778 }
779 779
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 } 908 }
909 909
910 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, 910 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString,
911 const String16& callFrameId, 911 const String16& callFrameId,
912 const String16& expression, 912 const String16& expression,
913 const Maybe<String16>& objectGroup, 913 const Maybe<String16>& objectGroup,
914 const Maybe<bool>& includeCommandLineAPI, 914 const Maybe<bool>& includeCommandLineAPI,
915 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole, 915 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole,
916 const Maybe<bool>& returnByValue, 916 const Maybe<bool>& returnByValue,
917 const Maybe<bool>& generatePreview, 917 const Maybe<bool>& generatePreview,
918 OwnPtr<RemoteObject>* result, 918 std::unique_ptr<RemoteObject>* result,
919 Maybe<bool>* wasThrown, 919 Maybe<bool>* wasThrown,
920 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) 920 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
921 { 921 {
922 if (!assertPaused(errorString)) 922 if (!assertPaused(errorString))
923 return; 923 return;
924 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId); 924 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId);
925 if (!scope.initialize()) 925 if (!scope.initialize())
926 return; 926 return;
927 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) { 927 if (scope.frameOrdinal() >= m_pausedCallFrames.size()) {
928 *errorString = "Could not find call frame with given id"; 928 *errorString = "Could not find call frame with given id";
(...skipping 17 matching lines...) Expand all
946 returnByValue.fromMaybe(false), 946 returnByValue.fromMaybe(false),
947 generatePreview.fromMaybe(false), 947 generatePreview.fromMaybe(false),
948 result, 948 result,
949 wasThrown, 949 wasThrown,
950 exceptionDetails); 950 exceptionDetails);
951 } 951 }
952 952
953 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, 953 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString,
954 int scopeNumber, 954 int scopeNumber,
955 const String16& variableName, 955 const String16& variableName,
956 PassOwnPtr<protocol::Runtime::CallArgument> newValueArgument, 956 std::unique_ptr<protocol::Runtime::CallArgument> newValueArgument,
957 const String16& callFrameId) 957 const String16& callFrameId)
958 { 958 {
959 if (!checkEnabled(errorString)) 959 if (!checkEnabled(errorString))
960 return; 960 return;
961 if (!assertPaused(errorString)) 961 if (!assertPaused(errorString))
962 return; 962 return;
963 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId); 963 InjectedScript::CallFrameScope scope(errorString, m_debugger, m_session->con textGroupId(), callFrameId);
964 if (!scope.initialize()) 964 if (!scope.initialize())
965 return; 965 return;
966 966
(...skipping 18 matching lines...) Expand all
985 return; 985 return;
986 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); 986 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth);
987 internalSetAsyncCallStackDepth(depth); 987 internalSetAsyncCallStackDepth(depth);
988 } 988 }
989 989
990 void V8DebuggerAgentImpl::asyncTaskScheduled(const String16& taskName, void* tas k, bool recurring) 990 void V8DebuggerAgentImpl::asyncTaskScheduled(const String16& taskName, void* tas k, bool recurring)
991 { 991 {
992 if (!m_maxAsyncCallStackDepth) 992 if (!m_maxAsyncCallStackDepth)
993 return; 993 return;
994 v8::HandleScope scope(m_isolate); 994 v8::HandleScope scope(m_isolate);
995 OwnPtr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, V8StackTrac e::maxCallStackSizeToCapture, taskName); 995 std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, V8 StackTrace::maxCallStackSizeToCapture, taskName);
996 if (chain) { 996 if (chain) {
997 m_asyncTaskStacks.set(task, std::move(chain)); 997 m_asyncTaskStacks.set(task, std::move(chain));
998 if (recurring) 998 if (recurring)
999 m_recurringTasks.add(task); 999 m_recurringTasks.add(task);
1000 } 1000 }
1001 } 1001 }
1002 1002
1003 void V8DebuggerAgentImpl::asyncTaskCanceled(void* task) 1003 void V8DebuggerAgentImpl::asyncTaskCanceled(void* task)
1004 { 1004 {
1005 if (!m_maxAsyncCallStackDepth) 1005 if (!m_maxAsyncCallStackDepth)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 { 1051 {
1052 m_asyncTaskStacks.clear(); 1052 m_asyncTaskStacks.clear();
1053 m_recurringTasks.clear(); 1053 m_recurringTasks.clear();
1054 m_currentStacks.clear(); 1054 m_currentStacks.clear();
1055 1055
1056 #if ENABLE(ASSERT) 1056 #if ENABLE(ASSERT)
1057 m_currentTasks.clear(); 1057 m_currentTasks.clear();
1058 #endif 1058 #endif
1059 } 1059 }
1060 1060
1061 void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, PassOwnP tr<protocol::Array<String16>> patterns) 1061 void V8DebuggerAgentImpl::setBlackboxPatterns(ErrorString* errorString, std::uni que_ptr<protocol::Array<String16>> patterns)
1062 { 1062 {
1063 if (!patterns->length()) { 1063 if (!patterns->length()) {
1064 m_blackboxPattern = nullptr; 1064 m_blackboxPattern = nullptr;
1065 m_state->remove(DebuggerAgentState::blackboxPattern); 1065 m_state->remove(DebuggerAgentState::blackboxPattern);
1066 return; 1066 return;
1067 } 1067 }
1068 1068
1069 String16Builder patternBuilder; 1069 String16Builder patternBuilder;
1070 patternBuilder.append("("); 1070 patternBuilder.append("(");
1071 for (size_t i = 0; i < patterns->length() - 1; ++i) 1071 for (size_t i = 0; i < patterns->length() - 1; ++i)
1072 patternBuilder.append(patterns->get(i) + "|"); 1072 patternBuilder.append(patterns->get(i) + "|");
1073 patternBuilder.append(patterns->get(patterns->length() - 1) + ")"); 1073 patternBuilder.append(patterns->get(patterns->length() - 1) + ")");
1074 String16 pattern = patternBuilder.toString(); 1074 String16 pattern = patternBuilder.toString();
1075 if (!setBlackboxPattern(errorString, pattern)) 1075 if (!setBlackboxPattern(errorString, pattern))
1076 return; 1076 return;
1077 m_state->setString(DebuggerAgentState::blackboxPattern, pattern); 1077 m_state->setString(DebuggerAgentState::blackboxPattern, pattern);
1078 } 1078 }
1079 1079
1080 bool V8DebuggerAgentImpl::setBlackboxPattern(ErrorString* errorString, const Str ing16& pattern) 1080 bool V8DebuggerAgentImpl::setBlackboxPattern(ErrorString* errorString, const Str ing16& pattern)
1081 { 1081 {
1082 OwnPtr<V8Regex> regex = adoptPtr(new V8Regex(m_debugger, pattern, true /** c aseSensitive */, false /** multiline */)); 1082 std::unique_ptr<V8Regex> regex(new V8Regex(m_debugger, pattern, true /** cas eSensitive */, false /** multiline */));
1083 if (!regex->isValid()) { 1083 if (!regex->isValid()) {
1084 *errorString = "Pattern parser error: " + regex->errorMessage(); 1084 *errorString = "Pattern parser error: " + regex->errorMessage();
1085 return false; 1085 return false;
1086 } 1086 }
1087 m_blackboxPattern = std::move(regex); 1087 m_blackboxPattern = std::move(regex);
1088 return true; 1088 return true;
1089 } 1089 }
1090 1090
1091 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16 & scriptId, PassOwnPtr<protocol::Array<protocol::Debugger::ScriptPosition>> inPo sitions) 1091 void V8DebuggerAgentImpl::setBlackboxedRanges(ErrorString* error, const String16 & scriptId, std::unique_ptr<protocol::Array<protocol::Debugger::ScriptPosition>> inPositions)
1092 { 1092 {
1093 if (!m_scripts.contains(scriptId)) { 1093 if (!m_scripts.contains(scriptId)) {
1094 *error = "No script with passed id."; 1094 *error = "No script with passed id.";
1095 return; 1095 return;
1096 } 1096 }
1097 1097
1098 if (!inPositions->length()) { 1098 if (!inPositions->length()) {
1099 m_blackboxedPositions.remove(scriptId); 1099 m_blackboxedPositions.remove(scriptId);
1100 return; 1100 return;
1101 } 1101 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 // from the old StepFrame. 1169 // from the old StepFrame.
1170 m_skippedStepFrameCount = 0; 1170 m_skippedStepFrameCount = 0;
1171 if (m_scheduledDebuggerStep == NoStep) 1171 if (m_scheduledDebuggerStep == NoStep)
1172 debugger().clearStepping(); 1172 debugger().clearStepping();
1173 else if (m_scheduledDebuggerStep == StepOut) 1173 else if (m_scheduledDebuggerStep == StepOut)
1174 m_skipNextDebuggerStepOut = true; 1174 m_skipNextDebuggerStepOut = true;
1175 } 1175 }
1176 } 1176 }
1177 } 1177 }
1178 1178
1179 PassOwnPtr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorString* errorString) 1179 std::unique_ptr<Array<CallFrame>> V8DebuggerAgentImpl::currentCallFrames(ErrorSt ring* errorString)
1180 { 1180 {
1181 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size()) 1181 if (m_pausedContext.IsEmpty() || !m_pausedCallFrames.size())
1182 return Array<CallFrame>::create(); 1182 return Array<CallFrame>::create();
1183 ErrorString ignored; 1183 ErrorString ignored;
1184 InjectedScript* topFrameInjectedScript = m_session->findInjectedScript(&igno red, V8Debugger::contextId(m_pausedContext.Get(m_isolate))); 1184 InjectedScript* topFrameInjectedScript = m_session->findInjectedScript(&igno red, V8Debugger::contextId(m_pausedContext.Get(m_isolate)));
1185 if (!topFrameInjectedScript) { 1185 if (!topFrameInjectedScript) {
1186 // Context has been reported as removed while on pause. 1186 // Context has been reported as removed while on pause.
1187 return Array<CallFrame>::create(); 1187 return Array<CallFrame>::create();
1188 } 1188 }
1189 1189
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 if (details->Has(context, toV8StringInternalized(m_isolate, "returnValue ")).FromMaybe(false)) { 1221 if (details->Has(context, toV8StringInternalized(m_isolate, "returnValue ")).FromMaybe(false)) {
1222 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St ringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectG roup)) 1222 if (!injectedScript->wrapObjectProperty(errorString, details, toV8St ringInternalized(m_isolate, "returnValue"), V8InspectorSession::backtraceObjectG roup))
1223 return Array<CallFrame>::create(); 1223 return Array<CallFrame>::create();
1224 } 1224 }
1225 1225
1226 if (hasInternalError(errorString, !objects->Set(context, frameOrdinal, d etails).FromMaybe(false))) 1226 if (hasInternalError(errorString, !objects->Set(context, frameOrdinal, d etails).FromMaybe(false)))
1227 return Array<CallFrame>::create(); 1227 return Array<CallFrame>::create();
1228 } 1228 }
1229 1229
1230 protocol::ErrorSupport errorSupport; 1230 protocol::ErrorSupport errorSupport;
1231 OwnPtr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toProtocolValu e(context, objects).get(), &errorSupport); 1231 std::unique_ptr<Array<CallFrame>> callFrames = Array<CallFrame>::parse(toPro tocolValue(context, objects).get(), &errorSupport);
1232 if (hasInternalError(errorString, !callFrames)) 1232 if (hasInternalError(errorString, !callFrames))
1233 return Array<CallFrame>::create(); 1233 return Array<CallFrame>::create();
1234 return callFrames; 1234 return callFrames;
1235 } 1235 }
1236 1236
1237 PassOwnPtr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace() 1237 std::unique_ptr<StackTrace> V8DebuggerAgentImpl::currentAsyncStackTrace()
1238 { 1238 {
1239 if (m_pausedContext.IsEmpty() || !m_maxAsyncCallStackDepth || !m_currentStac ks.size() || !m_currentStacks.last()) 1239 if (m_pausedContext.IsEmpty() || !m_maxAsyncCallStackDepth || !m_currentStac ks.size() || !m_currentStacks.last())
1240 return nullptr; 1240 return nullptr;
1241 1241
1242 return m_currentStacks.last()->buildInspectorObjectForTail(this); 1242 return m_currentStacks.last()->buildInspectorObjectForTail(this);
1243 } 1243 }
1244 1244
1245 V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain() 1245 V8StackTraceImpl* V8DebuggerAgentImpl::currentAsyncCallChain()
1246 { 1246 {
1247 if (!m_currentStacks.size()) 1247 if (!m_currentStacks.size())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1302 bool isRegex; 1302 bool isRegex;
1303 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex); 1303 breakpointObject->getBoolean(DebuggerAgentState::isRegex, &isRegex);
1304 String16 url; 1304 String16 url;
1305 breakpointObject->getString(DebuggerAgentState::url, &url); 1305 breakpointObject->getString(DebuggerAgentState::url, &url);
1306 if (!matches(m_debugger, scriptURL, url, isRegex)) 1306 if (!matches(m_debugger, scriptURL, url, isRegex))
1307 continue; 1307 continue;
1308 ScriptBreakpoint breakpoint; 1308 ScriptBreakpoint breakpoint;
1309 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber); 1309 breakpointObject->getNumber(DebuggerAgentState::lineNumber, &breakpoint. lineNumber);
1310 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber); 1310 breakpointObject->getNumber(DebuggerAgentState::columnNumber, &breakpoin t.columnNumber);
1311 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition); 1311 breakpointObject->getString(DebuggerAgentState::condition, &breakpoint.c ondition);
1312 OwnPtr<protocol::Debugger::Location> location = resolveBreakpoint(cookie .first, parsedScript.scriptId, breakpoint, UserBreakpointSource); 1312 std::unique_ptr<protocol::Debugger::Location> location = resolveBreakpoi nt(cookie.first, parsedScript.scriptId, breakpoint, UserBreakpointSource);
1313 if (location) 1313 if (location)
1314 m_frontend->breakpointResolved(cookie.first, std::move(location)); 1314 m_frontend->breakpointResolved(cookie.first, std::move(location));
1315 } 1315 }
1316 } 1316 }
1317 1317
1318 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const protocol::Vector<Strin g16>& hitBreakpoints, bool isPromiseRejection) 1318 V8DebuggerAgentImpl::SkipPauseRequest V8DebuggerAgentImpl::didPause(v8::Local<v8 ::Context> context, v8::Local<v8::Value> exception, const protocol::Vector<Strin g16>& hitBreakpoints, bool isPromiseRejection)
1319 { 1319 {
1320 JavaScriptCallFrames callFrames = debugger().currentCallFrames(1); 1320 JavaScriptCallFrames callFrames = debugger().currentCallFrames(1);
1321 JavaScriptCallFrame* topCallFrame = callFrames.size() > 0 ? callFrames[0] : nullptr; 1321 JavaScriptCallFrame* topCallFrame = callFrames.size() > 0 ? callFrames[0] : nullptr;
1322 1322
(...skipping 26 matching lines...) Expand all
1349 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8Debugger::contextId(context)); 1349 InjectedScript* injectedScript = m_session->findInjectedScript(&ignored, V8Debugger::contextId(context));
1350 if (injectedScript) { 1350 if (injectedScript) {
1351 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception; 1351 m_breakReason = isPromiseRejection ? protocol::Debugger::Paused::Rea sonEnum::PromiseRejection : protocol::Debugger::Paused::ReasonEnum::Exception;
1352 ErrorString errorString; 1352 ErrorString errorString;
1353 auto obj = injectedScript->wrapObject(&errorString, exception, V8Ins pectorSession::backtraceObjectGroup); 1353 auto obj = injectedScript->wrapObject(&errorString, exception, V8Ins pectorSession::backtraceObjectGroup);
1354 m_breakAuxData = obj ? obj->serialize() : nullptr; 1354 m_breakAuxData = obj ? obj->serialize() : nullptr;
1355 // m_breakAuxData might be null after this. 1355 // m_breakAuxData might be null after this.
1356 } 1356 }
1357 } 1357 }
1358 1358
1359 OwnPtr<Array<String16>> hitBreakpointIds = Array<String16>::create(); 1359 std::unique_ptr<Array<String16>> hitBreakpointIds = Array<String16>::create( );
1360 1360
1361 for (const auto& point : hitBreakpoints) { 1361 for (const auto& point : hitBreakpoints) {
1362 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter ator = m_serverBreakpoints.find(point); 1362 DebugServerBreakpointToBreakpointIdAndSourceMap::iterator breakpointIter ator = m_serverBreakpoints.find(point);
1363 if (breakpointIterator != m_serverBreakpoints.end()) { 1363 if (breakpointIterator != m_serverBreakpoints.end()) {
1364 const String16& localId = breakpointIterator->second->first; 1364 const String16& localId = breakpointIterator->second->first;
1365 hitBreakpointIds->addItem(localId); 1365 hitBreakpointIds->addItem(localId);
1366 1366
1367 BreakpointSource source = breakpointIterator->second->second; 1367 BreakpointSource source = breakpointIterator->second->second;
1368 if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other & & source == DebugCommandBreakpointSource) 1368 if (m_breakReason == protocol::Debugger::Paused::ReasonEnum::Other & & source == DebugCommandBreakpointSource)
1369 m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCom mand; 1369 m_breakReason = protocol::Debugger::Paused::ReasonEnum::DebugCom mand;
(...skipping 18 matching lines...) Expand all
1388 1388
1389 void V8DebuggerAgentImpl::didContinue() 1389 void V8DebuggerAgentImpl::didContinue()
1390 { 1390 {
1391 m_pausedContext.Reset(); 1391 m_pausedContext.Reset();
1392 JavaScriptCallFrames emptyCallFrames; 1392 JavaScriptCallFrames emptyCallFrames;
1393 m_pausedCallFrames.swap(emptyCallFrames); 1393 m_pausedCallFrames.swap(emptyCallFrames);
1394 clearBreakDetails(); 1394 clearBreakDetails();
1395 m_frontend->resumed(); 1395 m_frontend->resumed();
1396 } 1396 }
1397 1397
1398 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, PassOwnPtr<p rotocol::DictionaryValue> data) 1398 void V8DebuggerAgentImpl::breakProgram(const String16& breakReason, std::unique_ ptr<protocol::DictionaryValue> data)
1399 { 1399 {
1400 if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrent CallStackEmptyOrBlackboxed() || !debugger().breakpointsActivated()) 1400 if (!enabled() || m_skipAllPauses || !m_pausedContext.IsEmpty() || isCurrent CallStackEmptyOrBlackboxed() || !debugger().breakpointsActivated())
1401 return; 1401 return;
1402 m_breakReason = breakReason; 1402 m_breakReason = breakReason;
1403 m_breakAuxData = std::move(data); 1403 m_breakAuxData = std::move(data);
1404 m_scheduledDebuggerStep = NoStep; 1404 m_scheduledDebuggerStep = NoStep;
1405 m_steppingFromFramework = false; 1405 m_steppingFromFramework = false;
1406 m_pausingOnNativeEvent = false; 1406 m_pausingOnNativeEvent = false;
1407 debugger().breakProgram(); 1407 debugger().breakProgram();
1408 } 1408 }
1409 1409
1410 void V8DebuggerAgentImpl::breakProgramOnException(const String16& breakReason, P assOwnPtr<protocol::DictionaryValue> data) 1410 void V8DebuggerAgentImpl::breakProgramOnException(const String16& breakReason, s td::unique_ptr<protocol::DictionaryValue> data)
1411 { 1411 {
1412 if (!enabled() || m_debugger->getPauseOnExceptionsState() == V8DebuggerImpl: :DontPauseOnExceptions) 1412 if (!enabled() || m_debugger->getPauseOnExceptionsState() == V8DebuggerImpl: :DontPauseOnExceptions)
1413 return; 1413 return;
1414 breakProgram(breakReason, std::move(data)); 1414 breakProgram(breakReason, std::move(data));
1415 } 1415 }
1416 1416
1417 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString) 1417 bool V8DebuggerAgentImpl::assertPaused(ErrorString* errorString)
1418 { 1418 {
1419 if (m_pausedContext.IsEmpty()) { 1419 if (m_pausedContext.IsEmpty()) {
1420 *errorString = "Can only perform operation while paused."; 1420 *errorString = "Can only perform operation while paused.";
(...skipping 25 matching lines...) Expand all
1446 if (!enabled()) 1446 if (!enabled())
1447 return; 1447 return;
1448 m_scheduledDebuggerStep = NoStep; 1448 m_scheduledDebuggerStep = NoStep;
1449 m_scripts.clear(); 1449 m_scripts.clear();
1450 m_blackboxedPositions.clear(); 1450 m_blackboxedPositions.clear();
1451 m_breakpointIdToDebuggerBreakpointIds.clear(); 1451 m_breakpointIdToDebuggerBreakpointIds.clear();
1452 allAsyncTasksCanceled(); 1452 allAsyncTasksCanceled();
1453 } 1453 }
1454 1454
1455 } // namespace blink 1455 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698