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

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

Issue 1730383003: DevTools: consistently use Maybe for optional values in the protocol generator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 4 years, 9 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/JSONValues.h" 7 #include "platform/JSONValues.h"
8 #include "platform/v8_inspector/AsyncCallChain.h" 8 #include "platform/v8_inspector/AsyncCallChain.h"
9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h"
10 #include "platform/v8_inspector/InjectedScript.h" 10 #include "platform/v8_inspector/InjectedScript.h"
11 #include "platform/v8_inspector/InjectedScriptHost.h" 11 #include "platform/v8_inspector/InjectedScriptHost.h"
12 #include "platform/v8_inspector/InjectedScriptManager.h" 12 #include "platform/v8_inspector/InjectedScriptManager.h"
13 #include "platform/v8_inspector/JavaScriptCallFrame.h" 13 #include "platform/v8_inspector/JavaScriptCallFrame.h"
14 #include "platform/v8_inspector/PromiseTracker.h" 14 #include "platform/v8_inspector/PromiseTracker.h"
15 #include "platform/v8_inspector/RemoteObjectId.h" 15 #include "platform/v8_inspector/RemoteObjectId.h"
16 #include "platform/v8_inspector/V8AsyncCallTracker.h" 16 #include "platform/v8_inspector/V8AsyncCallTracker.h"
17 #include "platform/v8_inspector/V8JavaScriptCallFrame.h" 17 #include "platform/v8_inspector/V8JavaScriptCallFrame.h"
18 #include "platform/v8_inspector/V8Regex.h" 18 #include "platform/v8_inspector/V8Regex.h"
19 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" 19 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
20 #include "platform/v8_inspector/V8StackTraceImpl.h" 20 #include "platform/v8_inspector/V8StackTraceImpl.h"
21 #include "platform/v8_inspector/V8StringUtil.h" 21 #include "platform/v8_inspector/V8StringUtil.h"
22 #include "platform/v8_inspector/public/V8ContentSearchUtil.h" 22 #include "platform/v8_inspector/public/V8ContentSearchUtil.h"
23 #include "platform/v8_inspector/public/V8Debugger.h" 23 #include "platform/v8_inspector/public/V8Debugger.h"
24 #include "platform/v8_inspector/public/V8DebuggerClient.h" 24 #include "platform/v8_inspector/public/V8DebuggerClient.h"
25 #include "wtf/Optional.h" 25 #include "wtf/Optional.h"
26 #include "wtf/text/StringBuilder.h" 26 #include "wtf/text/StringBuilder.h"
27 #include "wtf/text/WTFString.h" 27 #include "wtf/text/WTFString.h"
28 28
29 using blink::protocol::Array; 29 using blink::protocol::Array;
30 using blink::protocol::OptionalValue; 30 using blink::protocol::Maybe;
31 using blink::protocol::Debugger::AsyncOperation; 31 using blink::protocol::Debugger::AsyncOperation;
32 using blink::protocol::Debugger::BreakpointId; 32 using blink::protocol::Debugger::BreakpointId;
33 using blink::protocol::Debugger::CallFrame; 33 using blink::protocol::Debugger::CallFrame;
34 using blink::protocol::Debugger::CollectionEntry; 34 using blink::protocol::Debugger::CollectionEntry;
35 using blink::protocol::Runtime::ExceptionDetails; 35 using blink::protocol::Runtime::ExceptionDetails;
36 using blink::protocol::Debugger::FunctionDetails; 36 using blink::protocol::Debugger::FunctionDetails;
37 using blink::protocol::Debugger::GeneratorObjectDetails; 37 using blink::protocol::Debugger::GeneratorObjectDetails;
38 using blink::protocol::Debugger::PromiseDetails; 38 using blink::protocol::Debugger::PromiseDetails;
39 using blink::protocol::Runtime::ScriptId; 39 using blink::protocol::Runtime::ScriptId;
40 using blink::protocol::Debugger::StackTrace; 40 using blink::protocol::Debugger::StackTrace;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 { 302 {
303 if (isRegex) { 303 if (isRegex) {
304 V8Regex regex(debugger, pattern, TextCaseSensitive); 304 V8Regex regex(debugger, pattern, TextCaseSensitive);
305 return regex.match(url) != -1; 305 return regex.match(url) != -1;
306 } 306 }
307 return url == pattern; 307 return url == pattern;
308 } 308 }
309 309
310 void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString, 310 void V8DebuggerAgentImpl::setBreakpointByUrl(ErrorString* errorString,
311 int lineNumber, 311 int lineNumber,
312 const OptionalValue<String>& optionalURL, 312 const Maybe<String>& optionalURL,
313 const OptionalValue<String>& optionalURLRegex, 313 const Maybe<String>& optionalURLRegex,
314 const OptionalValue<int>& optionalColumnNumber, 314 const Maybe<int>& optionalColumnNumber,
315 const OptionalValue<String>& optionalCondition, 315 const Maybe<String>& optionalCondition,
316 BreakpointId* outBreakpointId, 316 BreakpointId* outBreakpointId,
317 OwnPtr<protocol::Array<protocol::Debugger::Location>>* locations) 317 OwnPtr<protocol::Array<protocol::Debugger::Location>>* locations)
318 { 318 {
319 *locations = Array<protocol::Debugger::Location>::create(); 319 *locations = Array<protocol::Debugger::Location>::create();
320 if (optionalURL.hasValue() == optionalURLRegex.hasValue()) { 320 if (optionalURL.isJust() == optionalURLRegex.isJust()) {
321 *errorString = "Either url or urlRegex must be specified."; 321 *errorString = "Either url or urlRegex must be specified.";
322 return; 322 return;
323 } 323 }
324 324
325 String url = optionalURL.hasValue() ? optionalURL.get() : optionalURLRegex.g et(); 325 String url = optionalURL.isJust() ? optionalURL.fromJust() : optionalURLRege x.fromJust();
326 int columnNumber = 0; 326 int columnNumber = 0;
327 if (optionalColumnNumber.hasValue()) { 327 if (optionalColumnNumber.isJust()) {
328 columnNumber = optionalColumnNumber.get(); 328 columnNumber = optionalColumnNumber.fromJust();
329 if (columnNumber < 0) { 329 if (columnNumber < 0) {
330 *errorString = "Incorrect column number"; 330 *errorString = "Incorrect column number";
331 return; 331 return;
332 } 332 }
333 } 333 }
334 String condition = optionalCondition.get(""); 334 String condition = optionalCondition.fromMaybe("");
335 bool isRegex = optionalURLRegex.hasValue(); 335 bool isRegex = optionalURLRegex.isJust();
336 336
337 String breakpointId = (isRegex ? "/" + url + "/" : url) + ':' + String::numb er(lineNumber) + ':' + String::number(columnNumber); 337 String breakpointId = (isRegex ? "/" + url + "/" : url) + ':' + String::numb er(lineNumber) + ':' + String::number(columnNumber);
338 RefPtr<JSONObject> breakpointsCookie = m_state->getObject(DebuggerAgentState ::javaScriptBreakpoints); 338 RefPtr<JSONObject> breakpointsCookie = m_state->getObject(DebuggerAgentState ::javaScriptBreakpoints);
339 if (!breakpointsCookie) { 339 if (!breakpointsCookie) {
340 breakpointsCookie = JSONObject::create(); 340 breakpointsCookie = JSONObject::create();
341 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpoint sCookie); 341 m_state->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpoint sCookie);
342 } 342 }
343 if (breakpointsCookie->find(breakpointId) != breakpointsCookie->end()) { 343 if (breakpointsCookie->find(breakpointId) != breakpointsCookie->end()) {
344 *errorString = "Breakpoint at specified location already exists."; 344 *errorString = "Breakpoint at specified location already exists.";
345 return; 345 return;
(...skipping 22 matching lines...) Expand all
368 return false; 368 return false;
369 } 369 }
370 *scriptId = location->getScriptId(); 370 *scriptId = location->getScriptId();
371 *lineNumber = location->getLineNumber(); 371 *lineNumber = location->getLineNumber();
372 *columnNumber = location->getColumnNumber(0); 372 *columnNumber = location->getColumnNumber(0);
373 return true; 373 return true;
374 } 374 }
375 375
376 void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString, 376 void V8DebuggerAgentImpl::setBreakpoint(ErrorString* errorString,
377 PassOwnPtr<protocol::Debugger::Location> location, 377 PassOwnPtr<protocol::Debugger::Location> location,
378 const OptionalValue<String>& optionalCondition, 378 const Maybe<String>& optionalCondition,
379 BreakpointId* outBreakpointId, 379 BreakpointId* outBreakpointId,
380 OwnPtr<protocol::Debugger::Location>* actualLocation) 380 OwnPtr<protocol::Debugger::Location>* actualLocation)
381 { 381 {
382 String scriptId; 382 String scriptId;
383 int lineNumber; 383 int lineNumber;
384 int columnNumber; 384 int columnNumber;
385 385
386 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum ber)) 386 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum ber))
387 return; 387 return;
388 388
389 String condition = optionalCondition.get(""); 389 String condition = optionalCondition.fromMaybe("");
390 390
391 String breakpointId = generateBreakpointId(scriptId, lineNumber, columnNumbe r, UserBreakpointSource); 391 String breakpointId = generateBreakpointId(scriptId, lineNumber, columnNumbe r, UserBreakpointSource);
392 if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) != m_breakpoint IdToDebuggerBreakpointIds.end()) { 392 if (m_breakpointIdToDebuggerBreakpointIds.find(breakpointId) != m_breakpoint IdToDebuggerBreakpointIds.end()) {
393 *errorString = "Breakpoint at specified location already exists."; 393 *errorString = "Breakpoint at specified location already exists.";
394 return; 394 return;
395 } 395 }
396 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition); 396 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition);
397 *actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint, User BreakpointSource); 397 *actualLocation = resolveBreakpoint(breakpointId, scriptId, breakpoint, User BreakpointSource);
398 if (*actualLocation) 398 if (*actualLocation)
399 *outBreakpointId = breakpointId; 399 *outBreakpointId = breakpointId;
(...skipping 21 matching lines...) Expand all
421 const String& debuggerBreakpointId = debuggerBreakpointIdsIterator->valu e[i]; 421 const String& debuggerBreakpointId = debuggerBreakpointIdsIterator->valu e[i];
422 debugger().removeBreakpoint(debuggerBreakpointId); 422 debugger().removeBreakpoint(debuggerBreakpointId);
423 m_serverBreakpoints.remove(debuggerBreakpointId); 423 m_serverBreakpoints.remove(debuggerBreakpointId);
424 m_muteBreakpoints.remove(debuggerBreakpointId); 424 m_muteBreakpoints.remove(debuggerBreakpointId);
425 } 425 }
426 m_breakpointIdToDebuggerBreakpointIds.remove(debuggerBreakpointIdsIterator); 426 m_breakpointIdToDebuggerBreakpointIds.remove(debuggerBreakpointIdsIterator);
427 } 427 }
428 428
429 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString, 429 void V8DebuggerAgentImpl::continueToLocation(ErrorString* errorString,
430 PassOwnPtr<protocol::Debugger::Location> location, 430 PassOwnPtr<protocol::Debugger::Location> location,
431 const protocol::OptionalValue<bool>& interstateLocationOpt) 431 const protocol::Maybe<bool>& interstateLocationOpt)
432 { 432 {
433 if (!checkEnabled(errorString)) 433 if (!checkEnabled(errorString))
434 return; 434 return;
435 if (!m_continueToLocationBreakpointId.isEmpty()) { 435 if (!m_continueToLocationBreakpointId.isEmpty()) {
436 debugger().removeBreakpoint(m_continueToLocationBreakpointId); 436 debugger().removeBreakpoint(m_continueToLocationBreakpointId);
437 m_continueToLocationBreakpointId = ""; 437 m_continueToLocationBreakpointId = "";
438 } 438 }
439 439
440 String scriptId; 440 String scriptId;
441 int lineNumber; 441 int lineNumber;
442 int columnNumber; 442 int columnNumber;
443 443
444 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum ber)) 444 if (!parseLocation(errorString, location, &scriptId, &lineNumber, &columnNum ber))
445 return; 445 return;
446 446
447 ScriptBreakpoint breakpoint(lineNumber, columnNumber, ""); 447 ScriptBreakpoint breakpoint(lineNumber, columnNumber, "");
448 m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakp oint, &lineNumber, &columnNumber, interstateLocationOpt.get(false)); 448 m_continueToLocationBreakpointId = debugger().setBreakpoint(scriptId, breakp oint, &lineNumber, &columnNumber, interstateLocationOpt.fromMaybe(false));
449 resume(errorString); 449 resume(errorString);
450 } 450 }
451 451
452 void V8DebuggerAgentImpl::getStepInPositions(ErrorString* errorString, const Str ing& callFrameId, OwnPtr<Array<protocol::Debugger::Location>>* positions) 452 void V8DebuggerAgentImpl::getStepInPositions(ErrorString* errorString, const Str ing& callFrameId, Maybe<Array<protocol::Debugger::Location>>* positions)
453 { 453 {
454 if (!isPaused() || m_currentCallStack.IsEmpty()) { 454 if (!isPaused() || m_currentCallStack.IsEmpty()) {
455 *errorString = "Attempt to access callframe when debugger is not on paus e"; 455 *errorString = "Attempt to access callframe when debugger is not on paus e";
456 return; 456 return;
457 } 457 }
458 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); 458 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId);
459 if (!remoteId) { 459 if (!remoteId) {
460 *errorString = "Invalid call frame id"; 460 *errorString = "Invalid call frame id";
461 return; 461 return;
462 } 462 }
463 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (remoteId.get()); 463 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (remoteId.get());
464 if (!injectedScript) { 464 if (!injectedScript) {
465 *errorString = "Inspected frame has gone"; 465 *errorString = "Inspected frame has gone";
466 return; 466 return;
467 } 467 }
468 468
469 v8::HandleScope scope(m_isolate); 469 v8::HandleScope scope(m_isolate);
470 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate); 470 v8::Local<v8::Object> callStack = m_currentCallStack.Get(m_isolate);
471 injectedScript->getStepInPositions(errorString, callStack, callFrameId, posi tions); 471 injectedScript->getStepInPositions(errorString, callStack, callFrameId, posi tions);
472 } 472 }
473 473
474 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, OwnPtr<Array<Ca llFrame>>* callFrames, OwnPtr<StackTrace>* asyncStackTrace) 474 void V8DebuggerAgentImpl::getBacktrace(ErrorString* errorString, OwnPtr<Array<Ca llFrame>>* callFrames, Maybe<StackTrace>* asyncStackTrace)
475 { 475 {
476 if (!assertPaused(errorString)) 476 if (!assertPaused(errorString))
477 return; 477 return;
478 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames()); 478 m_currentCallStack.Reset(m_isolate, debugger().currentCallFrames());
479 *callFrames = currentCallFrames(); 479 *callFrames = currentCallFrames();
480 *asyncStackTrace = currentAsyncStackTrace(); 480 *asyncStackTrace = currentAsyncStackTrace();
481 } 481 }
482 482
483 bool V8DebuggerAgentImpl::isCallStackEmptyOrBlackboxed() 483 bool V8DebuggerAgentImpl::isCallStackEmptyOrBlackboxed()
484 { 484 {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 debuggerBreakpointIdsIterator->value.append(debuggerBreakpointId); 600 debuggerBreakpointIdsIterator->value.append(debuggerBreakpointId);
601 601
602 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location ::create() 602 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location ::create()
603 .setScriptId(scriptId) 603 .setScriptId(scriptId)
604 .setLineNumber(actualLineNumber) 604 .setLineNumber(actualLineNumber)
605 .setColumnNumber(actualColumnNumber).build(); 605 .setColumnNumber(actualColumnNumber).build();
606 return location.release(); 606 return location.release();
607 } 607 }
608 608
609 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String& scri ptId, const String& query, 609 void V8DebuggerAgentImpl::searchInContent(ErrorString* error, const String& scri ptId, const String& query,
610 const OptionalValue<bool>& optionalCaseSensitive, 610 const Maybe<bool>& optionalCaseSensitive,
611 const OptionalValue<bool>& optionalIsRegex, 611 const Maybe<bool>& optionalIsRegex,
612 OwnPtr<Array<protocol::Debugger::SearchMatch>>* results) 612 OwnPtr<Array<protocol::Debugger::SearchMatch>>* results)
613 { 613 {
614 ScriptsMap::iterator it = m_scripts.find(scriptId); 614 ScriptsMap::iterator it = m_scripts.find(scriptId);
615 if (it != m_scripts.end()) 615 if (it != m_scripts.end())
616 *results = V8ContentSearchUtil::searchInTextByLines(m_debugger, it->valu e.source(), query, optionalCaseSensitive.get(false), optionalIsRegex.get(false)) ; 616 *results = V8ContentSearchUtil::searchInTextByLines(m_debugger, it->valu e.source(), query, optionalCaseSensitive.fromMaybe(false), optionalIsRegex.fromM aybe(false));
617 else 617 else
618 *error = "No script for id: " + scriptId; 618 *error = "No script for id: " + scriptId;
619 } 619 }
620 620
621 void V8DebuggerAgentImpl::setScriptSource(ErrorString* error, 621 void V8DebuggerAgentImpl::setScriptSource(ErrorString* error,
622 const String& scriptId, 622 const String& scriptId,
623 const String& newContent, 623 const String& newContent,
624 const OptionalValue<bool>& preview, 624 const Maybe<bool>& preview,
625 OwnPtr<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames, 625 Maybe<protocol::Array<protocol::Debugger::CallFrame>>* newCallFrames,
626 OptionalValue<bool>* stackChanged, 626 Maybe<bool>* stackChanged,
627 OwnPtr<StackTrace>* asyncStackTrace, 627 Maybe<StackTrace>* asyncStackTrace,
628 OwnPtr<protocol::Debugger::SetScriptSourceError>* optOutCompileError) 628 Maybe<protocol::Debugger::SetScriptSourceError>* optOutCompileError)
629 { 629 {
630 if (!checkEnabled(error)) 630 if (!checkEnabled(error))
631 return; 631 return;
632 if (!debugger().setScriptSource(scriptId, newContent, preview.get(false), er ror, optOutCompileError, &m_currentCallStack, stackChanged)) 632 if (!debugger().setScriptSource(scriptId, newContent, preview.fromMaybe(fals e), error, optOutCompileError, &m_currentCallStack, stackChanged))
633 return; 633 return;
634 634
635 *newCallFrames = currentCallFrames(); 635 *newCallFrames = currentCallFrames();
636 *asyncStackTrace = currentAsyncStackTrace(); 636 *asyncStackTrace = currentAsyncStackTrace();
637 637
638 ScriptsMap::iterator it = m_scripts.find(scriptId); 638 ScriptsMap::iterator it = m_scripts.find(scriptId);
639 if (it == m_scripts.end()) 639 if (it == m_scripts.end())
640 return; 640 return;
641 it->value.setSource(newContent); 641 it->value.setSource(newContent);
642 } 642 }
643 643
644 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString, 644 void V8DebuggerAgentImpl::restartFrame(ErrorString* errorString,
645 const String& callFrameId, 645 const String& callFrameId,
646 OwnPtr<Array<CallFrame>>* newCallFrames, 646 OwnPtr<Array<CallFrame>>* newCallFrames,
647 OwnPtr<StackTrace>* asyncStackTrace) 647 Maybe<StackTrace>* asyncStackTrace)
648 { 648 {
649 if (!isPaused() || m_currentCallStack.IsEmpty()) { 649 if (!isPaused() || m_currentCallStack.IsEmpty()) {
650 *errorString = "Attempt to access callframe when debugger is not on paus e"; 650 *errorString = "Attempt to access callframe when debugger is not on paus e";
651 return; 651 return;
652 } 652 }
653 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); 653 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId);
654 if (!remoteId) { 654 if (!remoteId) {
655 *errorString = "Invalid call frame id"; 655 *errorString = "Invalid call frame id";
656 return; 656 return;
657 } 657 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 } 904 }
905 RefPtr<AsyncCallStack> asyncStack = m_currentAsyncCallChain->callStacks()[as yncOrdinal - 1]; 905 RefPtr<AsyncCallStack> asyncStack = m_currentAsyncCallChain->callStacks()[as yncOrdinal - 1];
906 *callStack = asyncStack->callFrames(m_isolate); 906 *callStack = asyncStack->callFrames(m_isolate);
907 *isAsync = true; 907 *isAsync = true;
908 return true; 908 return true;
909 } 909 }
910 910
911 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString, 911 void V8DebuggerAgentImpl::evaluateOnCallFrame(ErrorString* errorString,
912 const String& callFrameId, 912 const String& callFrameId,
913 const String& expression, 913 const String& expression,
914 const OptionalValue<String>& objectGroup, 914 const Maybe<String>& objectGroup,
915 const OptionalValue<bool>& includeCommandLineAPI, 915 const Maybe<bool>& includeCommandLineAPI,
916 const OptionalValue<bool>& doNotPauseOnExceptionsAndMuteConsole, 916 const Maybe<bool>& doNotPauseOnExceptionsAndMuteConsole,
917 const OptionalValue<bool>& returnByValue, 917 const Maybe<bool>& returnByValue,
918 const OptionalValue<bool>& generatePreview, 918 const Maybe<bool>& generatePreview,
919 OwnPtr<RemoteObject>* result, 919 OwnPtr<RemoteObject>* result,
920 OptionalValue<bool>* wasThrown, 920 Maybe<bool>* wasThrown,
921 OwnPtr<protocol::Runtime::ExceptionDetails>* exceptionDetails) 921 Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
922 { 922 {
923 if (!isPaused() || m_currentCallStack.IsEmpty()) { 923 if (!isPaused() || m_currentCallStack.IsEmpty()) {
924 *errorString = "Attempt to access callframe when debugger is not on paus e"; 924 *errorString = "Attempt to access callframe when debugger is not on paus e";
925 return; 925 return;
926 } 926 }
927 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); 927 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId);
928 if (!remoteId) { 928 if (!remoteId) {
929 *errorString = "Invalid call frame id"; 929 *errorString = "Invalid call frame id";
930 return; 930 return;
931 } 931 }
932 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (remoteId.get()); 932 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (remoteId.get());
933 if (!injectedScript) { 933 if (!injectedScript) {
934 *errorString = "Inspected frame has gone"; 934 *errorString = "Inspected frame has gone";
935 return; 935 return;
936 } 936 }
937 937
938 v8::HandleScope scope(m_isolate); 938 v8::HandleScope scope(m_isolate);
939 bool isAsync = false; 939 bool isAsync = false;
940 v8::Local<v8::Object> callStack; 940 v8::Local<v8::Object> callStack;
941 if (!callStackForId(errorString, *remoteId, &callStack, &isAsync)) 941 if (!callStackForId(errorString, *remoteId, &callStack, &isAsync))
942 return; 942 return;
943 ASSERT(!callStack.IsEmpty()); 943 ASSERT(!callStack.IsEmpty());
944 944
945 Optional<IgnoreExceptionsScope> ignoreExceptionsScope; 945 Optional<IgnoreExceptionsScope> ignoreExceptionsScope;
946 if (doNotPauseOnExceptionsAndMuteConsole.get(false)) 946 if (doNotPauseOnExceptionsAndMuteConsole.fromMaybe(false))
947 ignoreExceptionsScope.emplace(m_debugger); 947 ignoreExceptionsScope.emplace(m_debugger);
948 948
949 injectedScript->evaluateOnCallFrame(errorString, callStack, isAsync, callFra meId, expression, objectGroup.get(""), includeCommandLineAPI.get(false), returnB yValue.get(false), generatePreview.get(false), result, wasThrown, exceptionDetai ls); 949 injectedScript->evaluateOnCallFrame(errorString, callStack, isAsync, callFra meId, expression, objectGroup.fromMaybe(""), includeCommandLineAPI.fromMaybe(fal se), returnByValue.fromMaybe(false), generatePreview.fromMaybe(false), result, w asThrown, exceptionDetails);
950 } 950 }
951 951
952 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString, 952 void V8DebuggerAgentImpl::setVariableValue(ErrorString* errorString,
953 int scopeNumber, 953 int scopeNumber,
954 const String& variableName, 954 const String& variableName,
955 PassOwnPtr<protocol::Runtime::CallArgument> newValue, 955 PassOwnPtr<protocol::Runtime::CallArgument> newValue,
956 const OptionalValue<String>& callFrameId, 956 const Maybe<String>& callFrameId,
957 const OptionalValue<String>& functionObjectId) 957 const Maybe<String>& functionObjectId)
958 { 958 {
959 if (!checkEnabled(errorString)) 959 if (!checkEnabled(errorString))
960 return; 960 return;
961 InjectedScript* injectedScript = nullptr; 961 InjectedScript* injectedScript = nullptr;
962 if (callFrameId.hasValue()) { 962 if (callFrameId.isJust()) {
963 if (!isPaused() || m_currentCallStack.IsEmpty()) { 963 if (!isPaused() || m_currentCallStack.IsEmpty()) {
964 *errorString = "Attempt to access callframe when debugger is not on pause"; 964 *errorString = "Attempt to access callframe when debugger is not on pause";
965 return; 965 return;
966 } 966 }
967 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameI d.get()); 967 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameI d.fromJust());
968 if (!remoteId) { 968 if (!remoteId) {
969 *errorString = "Invalid call frame id"; 969 *errorString = "Invalid call frame id";
970 return; 970 return;
971 } 971 }
972 injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.ge t()); 972 injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.ge t());
973 if (!injectedScript) { 973 if (!injectedScript) {
974 *errorString = "Inspected frame has gone"; 974 *errorString = "Inspected frame has gone";
975 return; 975 return;
976 } 976 }
977 } else if (functionObjectId.hasValue()) { 977 } else if (functionObjectId.isJust()) {
978 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionObjectId .get()); 978 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionObjectId .fromJust());
979 if (!remoteId) { 979 if (!remoteId) {
980 *errorString = "Invalid object id"; 980 *errorString = "Invalid object id";
981 return; 981 return;
982 } 982 }
983 injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.ge t()); 983 injectedScript = m_injectedScriptManager->findInjectedScript(remoteId.ge t());
984 if (!injectedScript) { 984 if (!injectedScript) {
985 *errorString = "Function object id cannot be resolved"; 985 *errorString = "Function object id cannot be resolved";
986 return; 986 return;
987 } 987 }
988 } else { 988 } else {
989 *errorString = "Either call frame or function object must be specified"; 989 *errorString = "Either call frame or function object must be specified";
990 return; 990 return;
991 } 991 }
992 String newValueString = protocol::toValue(newValue)->toJSONString(); 992 String newValueString = protocol::toValue(newValue)->toJSONString();
993 v8::HandleScope scope(m_isolate); 993 v8::HandleScope scope(m_isolate);
994 v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate); 994 v8::Local<v8::Object> currentCallStack = m_currentCallStack.Get(m_isolate);
995 injectedScript->setVariableValue(errorString, currentCallStack, callFrameId, functionObjectId, scopeNumber, variableName, newValueString); 995 injectedScript->setVariableValue(errorString, currentCallStack, callFrameId, functionObjectId, scopeNumber, variableName, newValueString);
996 } 996 }
997 997
998 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth) 998 void V8DebuggerAgentImpl::setAsyncCallStackDepth(ErrorString* errorString, int d epth)
999 { 999 {
1000 if (!checkEnabled(errorString)) 1000 if (!checkEnabled(errorString))
1001 return; 1001 return;
1002 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth); 1002 m_state->setNumber(DebuggerAgentState::asyncCallStackDepth, depth);
1003 internalSetAsyncCallStackDepth(depth); 1003 internalSetAsyncCallStackDepth(depth);
1004 } 1004 }
1005 1005
1006 void V8DebuggerAgentImpl::enablePromiseTracker(ErrorString* errorString, 1006 void V8DebuggerAgentImpl::enablePromiseTracker(ErrorString* errorString,
1007 const OptionalValue<bool>& captureStacks) 1007 const Maybe<bool>& captureStacks)
1008 { 1008 {
1009 if (!checkEnabled(errorString)) 1009 if (!checkEnabled(errorString))
1010 return; 1010 return;
1011 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, true); 1011 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, true);
1012 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, capture Stacks.get(false)); 1012 m_state->setBoolean(DebuggerAgentState::promiseTrackerCaptureStacks, capture Stacks.fromMaybe(false));
1013 m_promiseTracker->setEnabled(true, captureStacks.get(false)); 1013 m_promiseTracker->setEnabled(true, captureStacks.fromMaybe(false));
1014 } 1014 }
1015 1015
1016 void V8DebuggerAgentImpl::disablePromiseTracker(ErrorString* errorString) 1016 void V8DebuggerAgentImpl::disablePromiseTracker(ErrorString* errorString)
1017 { 1017 {
1018 if (!checkEnabled(errorString)) 1018 if (!checkEnabled(errorString))
1019 return; 1019 return;
1020 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false); 1020 m_state->setBoolean(DebuggerAgentState::promiseTrackerEnabled, false);
1021 m_promiseTracker->setEnabled(false, false); 1021 m_promiseTracker->setEnabled(false, false);
1022 } 1022 }
1023 1023
1024 void V8DebuggerAgentImpl::getPromiseById(ErrorString* errorString, int promiseId , const OptionalValue<String>& objectGroup, OwnPtr<RemoteObject>* promise) 1024 void V8DebuggerAgentImpl::getPromiseById(ErrorString* errorString, int promiseId , const Maybe<String>& objectGroup, OwnPtr<RemoteObject>* promise)
1025 { 1025 {
1026 if (!checkEnabled(errorString)) 1026 if (!checkEnabled(errorString))
1027 return; 1027 return;
1028 if (!m_promiseTracker->isEnabled()) { 1028 if (!m_promiseTracker->isEnabled()) {
1029 *errorString = "Promise tracking is disabled"; 1029 *errorString = "Promise tracking is disabled";
1030 return; 1030 return;
1031 } 1031 }
1032 v8::HandleScope handles(m_isolate); 1032 v8::HandleScope handles(m_isolate);
1033 v8::Local<v8::Object> value = m_promiseTracker->promiseById(promiseId); 1033 v8::Local<v8::Object> value = m_promiseTracker->promiseById(promiseId);
1034 if (value.IsEmpty()) { 1034 if (value.IsEmpty()) {
1035 *errorString = "Promise with specified ID not found."; 1035 *errorString = "Promise with specified ID not found.";
1036 return; 1036 return;
1037 } 1037 }
1038 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( value->CreationContext()); 1038 InjectedScript* injectedScript = m_injectedScriptManager->injectedScriptFor( value->CreationContext());
1039 *promise = injectedScript->wrapObject(value, objectGroup.get("")); 1039 *promise = injectedScript->wrapObject(value, objectGroup.fromMaybe(""));
1040 } 1040 }
1041 1041
1042 void V8DebuggerAgentImpl::didUpdatePromise(const String& eventType, PassOwnPtr<p rotocol::Debugger::PromiseDetails> promise) 1042 void V8DebuggerAgentImpl::didUpdatePromise(const String& eventType, PassOwnPtr<p rotocol::Debugger::PromiseDetails> promise)
1043 { 1043 {
1044 if (m_frontend) 1044 if (m_frontend)
1045 m_frontend->promiseUpdated(eventType, promise); 1045 m_frontend->promiseUpdated(eventType, promise);
1046 } 1046 }
1047 1047
1048 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String& description) 1048 int V8DebuggerAgentImpl::traceAsyncOperationStarting(const String& description)
1049 { 1049 {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 1427
1428 int executionContextId = script.executionContextId(); 1428 int executionContextId = script.executionContextId();
1429 bool isContentScript = script.isContentScript(); 1429 bool isContentScript = script.isContentScript();
1430 bool isInternalScript = script.isInternalScript(); 1430 bool isInternalScript = script.isInternalScript();
1431 bool isLiveEdit = script.isLiveEdit(); 1431 bool isLiveEdit = script.isLiveEdit();
1432 bool hasSourceURL = script.hasSourceURL(); 1432 bool hasSourceURL = script.hasSourceURL();
1433 String scriptURL = script.sourceURL(); 1433 String scriptURL = script.sourceURL();
1434 String sourceMapURL = script.sourceMappingURL(); 1434 String sourceMapURL = script.sourceMappingURL();
1435 bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceM appingURL; 1435 bool deprecatedCommentWasUsed = isDeprecatedSourceURL || isDeprecatedSourceM appingURL;
1436 1436
1437 OptionalValue<String> sourceMapURLParam = sourceMapURL; 1437 const Maybe<String>& sourceMapURLParam = sourceMapURL;
1438 const bool* isContentScriptParam = isContentScript ? &isContentScript : null ptr; 1438 const bool* isContentScriptParam = isContentScript ? &isContentScript : null ptr;
1439 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n ullptr; 1439 const bool* isInternalScriptParam = isInternalScript ? &isInternalScript : n ullptr;
1440 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr; 1440 const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr;
1441 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr; 1441 const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
1442 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr ecatedCommentWasUsed : nullptr; 1442 const bool* deprecatedCommentWasUsedParam = deprecatedCommentWasUsed ? &depr ecatedCommentWasUsed : nullptr;
1443 if (parsedScript.success) 1443 if (parsedScript.success)
1444 m_frontend->scriptParsed(parsedScript.scriptId, scriptURL, script.startL ine(), script.startColumn(), script.endLine(), script.endColumn(), executionCont extId, isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapUR LParam, hasSourceURLParam, deprecatedCommentWasUsedParam); 1444 m_frontend->scriptParsed(parsedScript.scriptId, scriptURL, script.startL ine(), script.startColumn(), script.endLine(), script.endColumn(), executionCont extId, isContentScriptParam, isInternalScriptParam, isLiveEditParam, sourceMapUR LParam, hasSourceURLParam, deprecatedCommentWasUsedParam);
1445 else 1445 else
1446 m_frontend->scriptFailedToParse(parsedScript.scriptId, scriptURL, script .startLine(), script.startColumn(), script.endLine(), script.endColumn(), execut ionContextId, isContentScriptParam, isInternalScriptParam, sourceMapURLParam, ha sSourceURLParam, deprecatedCommentWasUsedParam); 1446 m_frontend->scriptFailedToParse(parsedScript.scriptId, scriptURL, script .startLine(), script.startColumn(), script.endLine(), script.endColumn(), execut ionContextId, isContentScriptParam, isInternalScriptParam, sourceMapURLParam, ha sSourceURLParam, deprecatedCommentWasUsedParam);
1447 1447
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 m_scripts.clear(); 1623 m_scripts.clear();
1624 m_blackboxedPositions.clear(); 1624 m_blackboxedPositions.clear();
1625 m_breakpointIdToDebuggerBreakpointIds.clear(); 1625 m_breakpointIdToDebuggerBreakpointIds.clear();
1626 resetAsyncCallTracker(); 1626 resetAsyncCallTracker();
1627 m_promiseTracker->clear(); 1627 m_promiseTracker->clear();
1628 if (m_frontend) 1628 if (m_frontend)
1629 m_frontend->globalObjectCleared(); 1629 m_frontend->globalObjectCleared();
1630 } 1630 }
1631 1631
1632 } // namespace blink 1632 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698