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

Side by Side Diff: Source/core/inspector/V8Debugger.cpp

Issue 1217773007: [DevTools] Replace reportCompiledScripts with explicit [get]compiledScripts. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 return !m_debuggerScript.IsEmpty(); 99 return !m_debuggerScript.IsEmpty();
100 } 100 }
101 101
102 void V8Debugger::setContextDebugData(v8::Local<v8::Context> context, const Strin g& contextDebugData) 102 void V8Debugger::setContextDebugData(v8::Local<v8::Context> context, const Strin g& contextDebugData)
103 { 103 {
104 v8::HandleScope scope(context->GetIsolate()); 104 v8::HandleScope scope(context->GetIsolate());
105 v8::Context::Scope contextScope(context); 105 v8::Context::Scope contextScope(context);
106 context->SetEmbedderData(static_cast<int>(gin::kDebugIdIndex), v8String(cont ext->GetIsolate(), contextDebugData)); 106 context->SetEmbedderData(static_cast<int>(gin::kDebugIdIndex), v8String(cont ext->GetIsolate(), contextDebugData));
107 } 107 }
108 108
109 void V8Debugger::reportCompiledScripts(const String& contextDebugDataSubstring, ScriptDebugListener* listener) 109 void V8Debugger::compiledScripts(const String& contextDebugDataSubstring, Vector <ScriptDebugListener::ParsedScript>& result)
yurys 2015/07/07 06:44:54 Since result is returned via out parameter it shou
dgozman 2015/07/07 10:07:25 Done.
110 { 110 {
111 v8::HandleScope scope(m_isolate); 111 v8::HandleScope scope(m_isolate);
112 v8::Context::Scope contextScope(debuggerContext()); 112 v8::Context::Scope contextScope(debuggerContext());
113 113
114 v8::Local<v8::Object> debuggerScript = debuggerScriptLocal(); 114 v8::Local<v8::Object> debuggerScript = debuggerScriptLocal();
115 ASSERT(!debuggerScript->IsUndefined()); 115 ASSERT(!debuggerScript->IsUndefined());
116 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d ebuggerScript->Get(v8InternalizedString("getScripts"))); 116 v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(d ebuggerScript->Get(v8InternalizedString("getScripts")));
117 v8::Local<v8::Value> argv[] = { v8String(m_isolate, contextDebugDataSubstrin g) }; 117 v8::Local<v8::Value> argv[] = { v8String(m_isolate, contextDebugDataSubstrin g) };
118 v8::Local<v8::Value> value; 118 v8::Local<v8::Value> value;
119 if (!V8ScriptRunner::callInternalFunction(getScriptsFunction, debuggerScript , WTF_ARRAY_LENGTH(argv), argv, m_isolate).ToLocal(&value)) 119 if (!V8ScriptRunner::callInternalFunction(getScriptsFunction, debuggerScript , WTF_ARRAY_LENGTH(argv), argv, m_isolate).ToLocal(&value))
120 return; 120 return;
121 ASSERT(value->IsArray()); 121 ASSERT(value->IsArray());
122 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value); 122 v8::Local<v8::Array> scriptsArray = v8::Local<v8::Array>::Cast(value);
123 result.reserveCapacity(scriptsArray->Length());
123 for (unsigned i = 0; i < scriptsArray->Length(); ++i) 124 for (unsigned i = 0; i < scriptsArray->Length(); ++i)
124 dispatchDidParseSource(listener, v8::Local<v8::Object>::Cast(scriptsArra y->Get(v8::Integer::New(m_isolate, i))), CompileSuccess); 125 result.append(createParsedScript(v8::Local<v8::Object>::Cast(scriptsArra y->Get(v8::Integer::New(m_isolate, i))), CompileSuccess));
125 } 126 }
126 127
127 String V8Debugger::setBreakpoint(const String& sourceID, const ScriptBreakpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool intersta tementLocation) 128 String V8Debugger::setBreakpoint(const String& sourceID, const ScriptBreakpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool intersta tementLocation)
128 { 129 {
129 v8::HandleScope scope(m_isolate); 130 v8::HandleScope scope(m_isolate);
130 v8::Context::Scope contextScope(debuggerContext()); 131 v8::Context::Scope contextScope(debuggerContext());
131 132
132 v8::Local<v8::Object> info = v8::Object::New(m_isolate); 133 v8::Local<v8::Object> info = v8::Object::New(m_isolate);
133 info->Set(v8InternalizedString("sourceID"), v8String(m_isolate, sourceID)); 134 info->Set(v8InternalizedString("sourceID"), v8String(m_isolate, sourceID));
134 info->Set(v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, sc riptBreakpoint.lineNumber)); 135 info->Set(v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, sc riptBreakpoint.lineNumber));
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 549
549 ScriptDebugListener* listener = m_client->getDebugListenerForContext(eventCo ntext); 550 ScriptDebugListener* listener = m_client->getDebugListenerForContext(eventCo ntext);
550 if (listener) { 551 if (listener) {
551 v8::HandleScope scope(m_isolate); 552 v8::HandleScope scope(m_isolate);
552 if (event == v8::AfterCompile || event == v8::CompileError) { 553 if (event == v8::AfterCompile || event == v8::CompileError) {
553 v8::Context::Scope contextScope(debuggerContext()); 554 v8::Context::Scope contextScope(debuggerContext());
554 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() }; 555 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() };
555 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri pt", 1, argv).ToLocalChecked(); 556 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri pt", 1, argv).ToLocalChecked();
556 ASSERT(value->IsObject()); 557 ASSERT(value->IsObject());
557 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); 558 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
558 dispatchDidParseSource(listener, object, event != v8::AfterCompile ? CompileError : CompileSuccess); 559 listener->didParseSource(createParsedScript(object, event != v8::Aft erCompile ? CompileError : CompileSuccess));
559 } else if (event == v8::Exception) { 560 } else if (event == v8::Exception) {
560 v8::Local<v8::Object> eventData = eventDetails.GetEventData(); 561 v8::Local<v8::Object> eventData = eventDetails.GetEventData();
561 v8::Local<v8::Value> exception = callInternalGetterFunction(eventDat a, "exception"); 562 v8::Local<v8::Value> exception = callInternalGetterFunction(eventDat a, "exception");
562 v8::Local<v8::Value> promise = callInternalGetterFunction(eventData, "promise"); 563 v8::Local<v8::Value> promise = callInternalGetterFunction(eventData, "promise");
563 bool isPromiseRejection = !promise.IsEmpty() && promise->IsObject(); 564 bool isPromiseRejection = !promise.IsEmpty() && promise->IsObject();
564 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), exception, v8::Local<v8::Array>(), isPromiseRejection); 565 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), exception, v8::Local<v8::Array>(), isPromiseRejection);
565 } else if (event == v8::Break) { 566 } else if (event == v8::Break) {
566 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() }; 567 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() };
567 v8::Local<v8::Value> hitBreakpoints = callDebuggerMethod("getBreakpo intNumbers", 1, argv).ToLocalChecked(); 568 v8::Local<v8::Value> hitBreakpoints = callDebuggerMethod("getBreakpo intNumbers", 1, argv).ToLocalChecked();
568 ASSERT(hitBreakpoints->IsArray()); 569 ASSERT(hitBreakpoints->IsArray());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 int status = promiseDetails->Get(v8InternalizedString("status"))->ToInteger( m_isolate)->Value(); 601 int status = promiseDetails->Get(v8InternalizedString("status"))->ToInteger( m_isolate)->Value();
601 v8::Local<v8::Value> parentPromise = promiseDetails->Get(v8InternalizedStrin g("parentPromise")); 602 v8::Local<v8::Value> parentPromise = promiseDetails->Get(v8InternalizedStrin g("parentPromise"));
602 603
603 m_pausedScriptState = pausedScriptState; 604 m_pausedScriptState = pausedScriptState;
604 m_executionState = executionState; 605 m_executionState = executionState;
605 listener->didReceiveV8PromiseEvent(pausedScriptState, promise, parentPromise , status); 606 listener->didReceiveV8PromiseEvent(pausedScriptState, promise, parentPromise , status);
606 m_pausedScriptState.clear(); 607 m_pausedScriptState.clear();
607 m_executionState.Clear(); 608 m_executionState.Clear();
608 } 609 }
609 610
610 void V8Debugger::dispatchDidParseSource(ScriptDebugListener* listener, v8::Local <v8::Object> object, CompileResult compileResult) 611 ScriptDebugListener::ParsedScript V8Debugger::createParsedScript(v8::Local<v8::O bject> object, CompileResult compileResult)
611 { 612 {
612 v8::Local<v8::Value> id = object->Get(v8InternalizedString("id")); 613 v8::Local<v8::Value> id = object->Get(v8InternalizedString("id"));
613 ASSERT(!id.IsEmpty() && id->IsInt32()); 614 ASSERT(!id.IsEmpty() && id->IsInt32());
614 String sourceID = String::number(id->Int32Value());
615 615
616 ScriptDebugListener::Script script; 616 ScriptDebugListener::ParsedScript parsedScript;
617 script.setURL(toCoreStringWithUndefinedOrNullCheck(object->Get(v8Internalize dString("name")))) 617 parsedScript.scriptId = String::number(id->Int32Value());
618 parsedScript.script.setURL(toCoreStringWithUndefinedOrNullCheck(object->Get( v8InternalizedString("name"))))
618 .setSourceURL(toCoreStringWithUndefinedOrNullCheck(object->Get(v8Interna lizedString("sourceURL")))) 619 .setSourceURL(toCoreStringWithUndefinedOrNullCheck(object->Get(v8Interna lizedString("sourceURL"))))
619 .setSourceMappingURL(toCoreStringWithUndefinedOrNullCheck(object->Get(v8 InternalizedString("sourceMappingURL")))) 620 .setSourceMappingURL(toCoreStringWithUndefinedOrNullCheck(object->Get(v8 InternalizedString("sourceMappingURL"))))
620 .setSource(toCoreStringWithUndefinedOrNullCheck(object->Get(v8Internaliz edString("source")))) 621 .setSource(toCoreStringWithUndefinedOrNullCheck(object->Get(v8Internaliz edString("source"))))
621 .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger( m_isolate)->Value()) 622 .setStartLine(object->Get(v8InternalizedString("startLine"))->ToInteger( m_isolate)->Value())
622 .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInte ger(m_isolate)->Value()) 623 .setStartColumn(object->Get(v8InternalizedString("startColumn"))->ToInte ger(m_isolate)->Value())
623 .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_is olate)->Value()) 624 .setEndLine(object->Get(v8InternalizedString("endLine"))->ToInteger(m_is olate)->Value())
624 .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger( m_isolate)->Value()) 625 .setEndColumn(object->Get(v8InternalizedString("endColumn"))->ToInteger( m_isolate)->Value())
625 .setIsContentScript(object->Get(v8InternalizedString("isContentScript")) ->ToBoolean(m_isolate)->Value()) 626 .setIsContentScript(object->Get(v8InternalizedString("isContentScript")) ->ToBoolean(m_isolate)->Value())
626 .setIsInternalScript(object->Get(v8InternalizedString("isInternalScript" ))->ToBoolean(m_isolate)->Value()); 627 .setIsInternalScript(object->Get(v8InternalizedString("isInternalScript" ))->ToBoolean(m_isolate)->Value());
627 628 parsedScript.compileResult = compileResult;
628 listener->didParseSource(sourceID, script, compileResult); 629 return parsedScript;
629 } 630 }
630 631
631 void V8Debugger::compileDebuggerScript() 632 void V8Debugger::compileDebuggerScript()
632 { 633 {
633 if (!m_debuggerScript.IsEmpty()) { 634 if (!m_debuggerScript.IsEmpty()) {
634 ASSERT_NOT_REACHED(); 635 ASSERT_NOT_REACHED();
635 return; 636 return;
636 } 637 }
637 638
638 v8::HandleScope scope(m_isolate); 639 v8::HandleScope scope(m_isolate);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 return callDebuggerMethod("setFunctionVariableValue", 4, argv); 706 return callDebuggerMethod("setFunctionVariableValue", 4, argv);
706 } 707 }
707 708
708 709
709 bool V8Debugger::isPaused() 710 bool V8Debugger::isPaused()
710 { 711 {
711 return m_pausedScriptState; 712 return m_pausedScriptState;
712 } 713 }
713 714
714 } // namespace blink 715 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698