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

Side by Side Diff: Source/bindings/core/v8/ScriptDebugServer.cpp

Issue 433653003: Support Promises event-based instrumentation on backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address review comments + REBASE Created 6 years, 3 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 /* 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD etails) 480 void ScriptDebugServer::handleV8DebugEvent(const v8::Debug::EventDetails& eventD etails)
481 { 481 {
482 v8::DebugEvent event = eventDetails.GetEvent(); 482 v8::DebugEvent event = eventDetails.GetEvent();
483 483
484 if (event == v8::BreakForCommand) { 484 if (event == v8::BreakForCommand) {
485 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie ntData()); 485 ClientDataImpl* data = static_cast<ClientDataImpl*>(eventDetails.GetClie ntData());
486 data->task()->run(); 486 data->task()->run();
487 return; 487 return;
488 } 488 }
489 489
490 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C ompileError) 490 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C ompileError && event != v8::PromiseEvent)
491 return; 491 return;
492 492
493 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); 493 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext();
494 ASSERT(!eventContext.IsEmpty()); 494 ASSERT(!eventContext.IsEmpty());
495 495
496 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); 496 ScriptDebugListener* listener = getDebugListenerForContext(eventContext);
497 if (listener) { 497 if (listener) {
498 v8::HandleScope scope(m_isolate); 498 v8::HandleScope scope(m_isolate);
499 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol ate); 499 v8::Handle<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isol ate);
500 if (event == v8::BeforeCompile) { 500 if (event == v8::BeforeCompile) {
(...skipping 11 matching lines...) Expand all
512 v8::Handle<v8::Value> exception = callInternalGetterFunction(eventDa ta, "exception", m_isolate); 512 v8::Handle<v8::Value> exception = callInternalGetterFunction(eventDa ta, "exception", m_isolate);
513 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), exception, v8::Handle<v8::Array>()); 513 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), exception, v8::Handle<v8::Array>());
514 } else if (event == v8::Break) { 514 } else if (event == v8::Break) {
515 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8 ::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu mbers"))); 515 v8::Handle<v8::Function> getBreakpointNumbersFunction = v8::Local<v8 ::Function>::Cast(debuggerScript->Get(v8AtomicString(m_isolate, "getBreakpointNu mbers")));
516 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() }; 516 v8::Handle<v8::Value> argv[] = { eventDetails.GetEventData() };
517 v8::Handle<v8::Value> hitBreakpoints = V8ScriptRunner::callInternalF unction(getBreakpointNumbersFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), ar gv, m_isolate); 517 v8::Handle<v8::Value> hitBreakpoints = V8ScriptRunner::callInternalF unction(getBreakpointNumbersFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), ar gv, m_isolate);
518 ASSERT(hitBreakpoints->IsArray()); 518 ASSERT(hitBreakpoints->IsArray());
519 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), v8::Handle<v8::Value>(), hitBreakpoints.As<v8::Array>()); 519 handleProgramBreak(ScriptState::from(eventContext), eventDetails.Get ExecutionState(), v8::Handle<v8::Value>(), hitBreakpoints.As<v8::Array>());
520 } else if (event == v8::AsyncTaskEvent) { 520 } else if (event == v8::AsyncTaskEvent) {
521 handleV8AsyncTaskEvent(listener, ScriptState::from(eventContext), ev entDetails.GetExecutionState(), eventDetails.GetEventData()); 521 handleV8AsyncTaskEvent(listener, ScriptState::from(eventContext), ev entDetails.GetExecutionState(), eventDetails.GetEventData());
522 } else if (event == v8::PromiseEvent) {
523 handleV8PromiseEvent(listener, ScriptState::from(eventContext), even tDetails.GetExecutionState(), eventDetails.GetEventData());
522 } 524 }
523 } 525 }
524 } 526 }
525 527
526 void ScriptDebugServer::handleV8AsyncTaskEvent(ScriptDebugListener* listener, Sc riptState* pausedScriptState, v8::Handle<v8::Object> executionState, v8::Handle< v8::Object> eventData) 528 void ScriptDebugServer::handleV8AsyncTaskEvent(ScriptDebugListener* listener, Sc riptState* pausedScriptState, v8::Handle<v8::Object> executionState, v8::Handle< v8::Object> eventData)
527 { 529 {
528 String type = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio n(eventData, "type", m_isolate)); 530 String type = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio n(eventData, "type", m_isolate));
529 String name = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio n(eventData, "name", m_isolate)); 531 String name = toCoreStringWithUndefinedOrNullCheck(callInternalGetterFunctio n(eventData, "name", m_isolate));
530 int id = callInternalGetterFunction(eventData, "id", m_isolate)->ToInteger() ->Value(); 532 int id = callInternalGetterFunction(eventData, "id", m_isolate)->ToInteger() ->Value();
531 533
532 m_pausedScriptState = pausedScriptState; 534 m_pausedScriptState = pausedScriptState;
533 m_executionState = executionState; 535 m_executionState = executionState;
534 listener->didReceiveV8AsyncTaskEvent(pausedScriptState->executionContext(), type, name, id); 536 listener->didReceiveV8AsyncTaskEvent(pausedScriptState->executionContext(), type, name, id);
535 m_pausedScriptState.clear(); 537 m_pausedScriptState.clear();
536 m_executionState.Clear(); 538 m_executionState.Clear();
537 } 539 }
538 540
541 void ScriptDebugServer::handleV8PromiseEvent(ScriptDebugListener* listener, Scri ptState* pausedScriptState, v8::Handle<v8::Object> executionState, v8::Handle<v8 ::Object> eventData)
542 {
543 v8::Handle<v8::Value> argv[] = { eventData };
544 v8::Local<v8::Object> promiseDetails = callDebuggerMethod("getPromiseDetails ", 1, argv)->ToObject();
545 v8::Handle<v8::Object> promise = promiseDetails->Get(v8AtomicString(m_isolat e, "promise"))->ToObject();
546 int status = promiseDetails->Get(v8AtomicString(m_isolate, "status"))->ToInt eger()->Value();
547 v8::Handle<v8::Value> parentPromise = promiseDetails->Get(v8AtomicString(m_i solate, "parentPromise"));
548
549 m_pausedScriptState = pausedScriptState;
550 m_executionState = executionState;
551 listener->didReceiveV8PromiseEvent(pausedScriptState, promise, parentPromise , status);
552 m_pausedScriptState.clear();
553 m_executionState.Clear();
554 }
555
539 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object, CompileResult compileResult) 556 void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8 ::Handle<v8::Object> object, CompileResult compileResult)
540 { 557 {
541 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id")); 558 v8::Handle<v8::Value> id = object->Get(v8AtomicString(m_isolate, "id"));
542 ASSERT(!id.IsEmpty() && id->IsInt32()); 559 ASSERT(!id.IsEmpty() && id->IsInt32());
543 String sourceID = String::number(id->Int32Value()); 560 String sourceID = String::number(id->Int32Value());
544 561
545 ScriptDebugListener::Script script; 562 ScriptDebugListener::Script script;
546 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString (m_isolate, "name"))); 563 script.url = toCoreStringWithUndefinedOrNullCheck(object->Get(v8AtomicString (m_isolate, "name")));
547 script.sourceURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v8Atomic String(m_isolate, "sourceURL"))); 564 script.sourceURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v8Atomic String(m_isolate, "sourceURL")));
548 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v 8AtomicString(m_isolate, "sourceMappingURL"))); 565 script.sourceMappingURL = toCoreStringWithUndefinedOrNullCheck(object->Get(v 8AtomicString(m_isolate, "sourceMappingURL")));
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 { 707 {
691 return PassOwnPtr<ScriptSourceCode>(); 708 return PassOwnPtr<ScriptSourceCode>();
692 } 709 }
693 710
694 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou rce, const String& url, const String& functionName) 711 String ScriptDebugServer::preprocessEventListener(LocalFrame*, const String& sou rce, const String& url, const String& functionName)
695 { 712 {
696 return source; 713 return source;
697 } 714 }
698 715
699 } // namespace blink 716 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698