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

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

Issue 1128273005: Devtools: Move runMessageLoopOnPause and other methods on ScriptDebugServer::Client (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix ownptrs Created 5 years, 7 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 }; 73 };
74 74
75 v8::MaybeLocal<v8::Value> ScriptDebugServer::callDebuggerMethod(const char* func tionName, int argc, v8::Local<v8::Value> argv[]) 75 v8::MaybeLocal<v8::Value> ScriptDebugServer::callDebuggerMethod(const char* func tionName, int argc, v8::Local<v8::Value> argv[])
76 { 76 {
77 v8::Local<v8::Object> debuggerScript = debuggerScriptLocal(); 77 v8::Local<v8::Object> debuggerScript = debuggerScriptLocal();
78 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr ipt->Get(v8InternalizedString(functionName))); 78 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr ipt->Get(v8InternalizedString(functionName)));
79 ASSERT(m_isolate->InContext()); 79 ASSERT(m_isolate->InContext());
80 return V8ScriptRunner::callInternalFunction(function, debuggerScript, argc, argv, m_isolate); 80 return V8ScriptRunner::callInternalFunction(function, debuggerScript, argc, argv, m_isolate);
81 } 81 }
82 82
83 ScriptDebugServer::ScriptDebugServer(v8::Isolate* isolate, PassOwnPtr<Client> cl ient) 83 ScriptDebugServer::ScriptDebugServer(v8::Isolate* isolate, Client* client)
84 : m_isolate(isolate) 84 : m_isolate(isolate)
85 , m_client(client) 85 , m_client(client)
86 , m_breakpointsActivated(true) 86 , m_breakpointsActivated(true)
87 , m_runningNestedMessageLoop(false) 87 , m_runningNestedMessageLoop(false)
88 , m_taskQueue(adoptPtr(new ThreadSafeTaskQueue)) 88 , m_taskQueue(adoptPtr(new ThreadSafeTaskQueue))
89 { 89 {
90 } 90 }
91 91
92 ScriptDebugServer::~ScriptDebugServer() 92 ScriptDebugServer::~ScriptDebugServer()
93 { 93 {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 m_breakProgramCallbackTemplate.Reset(m_isolate, templ); 266 m_breakProgramCallbackTemplate.Reset(m_isolate, templ);
267 } 267 }
268 268
269 v8::Local<v8::Function> breakProgramFunction = v8::Local<v8::FunctionTemplat e>::New(m_isolate, m_breakProgramCallbackTemplate)->GetFunction(); 269 v8::Local<v8::Function> breakProgramFunction = v8::Local<v8::FunctionTemplat e>::New(m_isolate, m_breakProgramCallbackTemplate)->GetFunction();
270 v8::Debug::Call(breakProgramFunction); 270 v8::Debug::Call(breakProgramFunction);
271 } 271 }
272 272
273 void ScriptDebugServer::continueProgram() 273 void ScriptDebugServer::continueProgram()
274 { 274 {
275 if (isPaused()) 275 if (isPaused())
276 quitMessageLoopOnPause(); 276 m_client->quitMessageLoopOnPause();
277 m_pausedScriptState.clear(); 277 m_pausedScriptState.clear();
278 m_executionState.Clear(); 278 m_executionState.Clear();
279 } 279 }
280 280
281 void ScriptDebugServer::stepIntoStatement() 281 void ScriptDebugServer::stepIntoStatement()
282 { 282 {
283 ASSERT(isPaused()); 283 ASSERT(isPaused());
284 ASSERT(!m_executionState.IsEmpty()); 284 ASSERT(!m_executionState.IsEmpty());
285 v8::HandleScope handleScope(m_isolate); 285 v8::HandleScope handleScope(m_isolate);
286 v8::Local<v8::Value> argv[] = { m_executionState }; 286 v8::Local<v8::Value> argv[] = { m_executionState };
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 v8::Local<v8::Array> hitBreakpoints; 515 v8::Local<v8::Array> hitBreakpoints;
516 thisPtr->handleProgramBreak(pausedScriptState, v8::Local<v8::Object>::Cast(i nfo[0]), exception, hitBreakpoints); 516 thisPtr->handleProgramBreak(pausedScriptState, v8::Local<v8::Object>::Cast(i nfo[0]), exception, hitBreakpoints);
517 } 517 }
518 518
519 void ScriptDebugServer::handleProgramBreak(ScriptState* pausedScriptState, v8::L ocal<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::A rray> hitBreakpointNumbers, bool isPromiseRejection) 519 void ScriptDebugServer::handleProgramBreak(ScriptState* pausedScriptState, v8::L ocal<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::A rray> hitBreakpointNumbers, bool isPromiseRejection)
520 { 520 {
521 // Don't allow nested breaks. 521 // Don't allow nested breaks.
522 if (m_runningNestedMessageLoop) 522 if (m_runningNestedMessageLoop)
523 return; 523 return;
524 524
525 ScriptDebugListener* listener = getDebugListenerForContext(pausedScriptState ->context()); 525 ScriptDebugListener* listener = m_client->getDebugListenerForContext(pausedS criptState->context());
526 if (!listener) 526 if (!listener)
527 return; 527 return;
528 528
529 Vector<String> breakpointIds; 529 Vector<String> breakpointIds;
530 if (!hitBreakpointNumbers.IsEmpty()) { 530 if (!hitBreakpointNumbers.IsEmpty()) {
531 breakpointIds.resize(hitBreakpointNumbers->Length()); 531 breakpointIds.resize(hitBreakpointNumbers->Length());
532 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) { 532 for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
533 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i); 533 v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get (i);
534 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2()); 534 ASSERT(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt3 2());
535 breakpointIds[i] = String::number(hitBreakpointNumber->Int32Value()) ; 535 breakpointIds[i] = String::number(hitBreakpointNumber->Int32Value()) ;
536 } 536 }
537 } 537 }
538 538
539 m_pausedScriptState = pausedScriptState; 539 m_pausedScriptState = pausedScriptState;
540 m_executionState = executionState; 540 m_executionState = executionState;
541 ScriptDebugListener::SkipPauseRequest result = listener->didPause(pausedScri ptState, currentCallFrames(), ScriptValue(pausedScriptState, exception), breakpo intIds, isPromiseRejection); 541 ScriptDebugListener::SkipPauseRequest result = listener->didPause(pausedScri ptState, currentCallFrames(), ScriptValue(pausedScriptState, exception), breakpo intIds, isPromiseRejection);
542 if (result == ScriptDebugListener::NoSkip) { 542 if (result == ScriptDebugListener::NoSkip) {
543 m_runningNestedMessageLoop = true; 543 m_runningNestedMessageLoop = true;
544 runMessageLoopOnPause(pausedScriptState->context()); 544 m_client->runMessageLoopOnPause(pausedScriptState->context());
545 m_runningNestedMessageLoop = false; 545 m_runningNestedMessageLoop = false;
546 } 546 }
547 m_pausedScriptState.clear(); 547 m_pausedScriptState.clear();
548 m_executionState.Clear(); 548 m_executionState.Clear();
549 549
550 if (result == ScriptDebugListener::StepFrame) { 550 if (result == ScriptDebugListener::StepFrame) {
551 v8::Local<v8::Value> argv[] = { executionState }; 551 v8::Local<v8::Value> argv[] = { executionState };
552 callDebuggerMethod("stepFrameStatement", 1, argv); 552 callDebuggerMethod("stepFrameStatement", 1, argv);
553 } else if (result == ScriptDebugListener::StepInto) { 553 } else if (result == ScriptDebugListener::StepInto) {
554 v8::Local<v8::Value> argv[] = { executionState }; 554 v8::Local<v8::Value> argv[] = { executionState };
(...skipping 27 matching lines...) Expand all
582 { 582 {
583 if (!enabled()) 583 if (!enabled())
584 return; 584 return;
585 v8::DebugEvent event = eventDetails.GetEvent(); 585 v8::DebugEvent event = eventDetails.GetEvent();
586 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C ompileError && event != v8::PromiseEvent) 586 if (event != v8::AsyncTaskEvent && event != v8::Break && event != v8::Except ion && event != v8::AfterCompile && event != v8::BeforeCompile && event != v8::C ompileError && event != v8::PromiseEvent)
587 return; 587 return;
588 588
589 v8::Local<v8::Context> eventContext = eventDetails.GetEventContext(); 589 v8::Local<v8::Context> eventContext = eventDetails.GetEventContext();
590 ASSERT(!eventContext.IsEmpty()); 590 ASSERT(!eventContext.IsEmpty());
591 591
592 ScriptDebugListener* listener = getDebugListenerForContext(eventContext); 592 ScriptDebugListener* listener = m_client->getDebugListenerForContext(eventCo ntext);
593 if (listener) { 593 if (listener) {
594 v8::HandleScope scope(m_isolate); 594 v8::HandleScope scope(m_isolate);
595 if (event == v8::AfterCompile || event == v8::CompileError) { 595 if (event == v8::AfterCompile || event == v8::CompileError) {
596 v8::Context::Scope contextScope(debuggerContext()); 596 v8::Context::Scope contextScope(debuggerContext());
597 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() }; 597 v8::Local<v8::Value> argv[] = { eventDetails.GetEventData() };
598 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri pt", 1, argv).ToLocalChecked(); 598 v8::Local<v8::Value> value = callDebuggerMethod("getAfterCompileScri pt", 1, argv).ToLocalChecked();
599 ASSERT(value->IsObject()); 599 ASSERT(value->IsObject());
600 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); 600 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
601 dispatchDidParseSource(listener, object, event != v8::AfterCompile ? CompileError : CompileSuccess); 601 dispatchDidParseSource(listener, object, event != v8::AfterCompile ? CompileError : CompileSuccess);
602 } else if (event == v8::Exception) { 602 } else if (event == v8::Exception) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 return callDebuggerMethod("setFunctionVariableValue", 4, argv); 758 return callDebuggerMethod("setFunctionVariableValue", 4, argv);
759 } 759 }
760 760
761 761
762 bool ScriptDebugServer::isPaused() 762 bool ScriptDebugServer::isPaused()
763 { 763 {
764 return m_pausedScriptState; 764 return m_pausedScriptState;
765 } 765 }
766 766
767 } // namespace blink 767 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698