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

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/V8Debugger.cpp

Issue 2205913002: [DevTools] Split a part of V8Inspector into V8Debugger. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8-inspector-rename
Patch Set: context scope! Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/v8_inspector/V8Debugger.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8InspectorImpl.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8Debugger.cpp
similarity index 55%
copy from third_party/WebKit/Source/platform/v8_inspector/V8InspectorImpl.cpp
copy to third_party/WebKit/Source/platform/v8_inspector/V8Debugger.cpp
index 2a6ef839f7d6b104b4f655598eb40c3a9cc7a561..ff93531a63843220b435ad98411894b3067d9e73 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8InspectorImpl.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8Debugger.cpp
@@ -1,59 +1,24 @@
-/*
- * Copyright (c) 2010-2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
-#include "platform/v8_inspector/V8InspectorImpl.h"
+#include "platform/v8_inspector/V8Debugger.h"
-#include "platform/inspector_protocol/Values.h"
-#include "platform/v8_inspector/Atomics.h"
#include "platform/v8_inspector/DebuggerScript.h"
-#include "platform/v8_inspector/InspectedContext.h"
#include "platform/v8_inspector/ScriptBreakpoint.h"
#include "platform/v8_inspector/V8Compat.h"
-#include "platform/v8_inspector/V8ConsoleAgentImpl.h"
-#include "platform/v8_inspector/V8ConsoleMessage.h"
#include "platform/v8_inspector/V8DebuggerAgentImpl.h"
-#include "platform/v8_inspector/V8InjectedScriptHost.h"
-#include "platform/v8_inspector/V8InspectorSessionImpl.h"
+#include "platform/v8_inspector/V8InspectorImpl.h"
#include "platform/v8_inspector/V8InternalValueType.h"
-#include "platform/v8_inspector/V8RuntimeAgentImpl.h"
#include "platform/v8_inspector/V8StackTraceImpl.h"
#include "platform/v8_inspector/V8StringUtil.h"
#include "platform/v8_inspector/public/V8InspectorClient.h"
-#include <v8-profiler.h>
namespace blink {
namespace {
const char stepIntoV8MethodName[] = "stepIntoStatement";
const char stepOutV8MethodName[] = "stepOutOfFunction";
-volatile int s_lastContextId = 0;
static const char v8AsyncTaskEventEnqueue[] = "enqueue";
static const char v8AsyncTaskEventWillHandle[] = "willHandle";
static const char v8AsyncTaskEventDidHandle[] = "didHandle";
@@ -67,47 +32,45 @@ inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate)
static bool inLiveEditScope = false;
-v8::MaybeLocal<v8::Value> V8InspectorImpl::callDebuggerMethod(const char* functionName, int argc, v8::Local<v8::Value> argv[])
+v8::MaybeLocal<v8::Value> V8Debugger::callDebuggerMethod(const char* functionName, int argc, v8::Local<v8::Value> argv[])
{
v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
- v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScript->Get(v8InternalizedString(functionName)));
+ v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScript->Get(toV8StringInternalized(m_isolate, functionName)));
DCHECK(m_isolate->InContext());
return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc, argv);
}
-std::unique_ptr<V8Inspector> V8Inspector::create(v8::Isolate* isolate, V8InspectorClient* client)
-{
- return wrapUnique(new V8InspectorImpl(isolate, client));
-}
-
-V8InspectorImpl::V8InspectorImpl(v8::Isolate* isolate, V8InspectorClient* client)
+V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector)
: m_isolate(isolate)
- , m_client(client)
- , m_capturingStackTracesCount(0)
- , m_lastExceptionId(0)
- , m_enabledAgentsCount(0)
+ , m_inspector(inspector)
+ , m_lastContextId(0)
+ , m_enableCount(0)
, m_breakpointsActivated(true)
, m_runningNestedMessageLoop(false)
, m_maxAsyncCallStackDepth(0)
{
}
-V8InspectorImpl::~V8InspectorImpl()
+V8Debugger::~V8Debugger()
{
}
-void V8InspectorImpl::enable()
+void V8Debugger::enable()
{
+ if (m_enableCount++)
+ return;
DCHECK(!enabled());
v8::HandleScope scope(m_isolate);
- v8::Debug::SetDebugEventListener(m_isolate, &V8InspectorImpl::v8DebugEventCallback, v8::External::New(m_isolate, this));
+ v8::Debug::SetDebugEventListener(m_isolate, &V8Debugger::v8DebugEventCallback, v8::External::New(m_isolate, this));
m_debuggerContext.Reset(m_isolate, v8::Debug::GetDebugContext(m_isolate));
compileDebuggerScript();
}
-void V8InspectorImpl::disable()
+void V8Debugger::disable()
{
+ if (--m_enableCount)
+ return;
DCHECK(enabled());
clearBreakpoints();
m_debuggerScript.Reset();
@@ -116,13 +79,13 @@ void V8InspectorImpl::disable()
v8::Debug::SetDebugEventListener(m_isolate, nullptr);
}
-bool V8InspectorImpl::enabled() const
+bool V8Debugger::enabled() const
{
return !m_debuggerScript.IsEmpty();
}
// static
-int V8InspectorImpl::contextId(v8::Local<v8::Context> context)
+int V8Debugger::contextId(v8::Local<v8::Context> context)
{
v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex));
if (data.IsEmpty() || !data->IsString())
@@ -140,7 +103,7 @@ int V8InspectorImpl::contextId(v8::Local<v8::Context> context)
}
// static
-int V8InspectorImpl::getGroupId(v8::Local<v8::Context> context)
+int V8Debugger::getGroupId(v8::Local<v8::Context> context)
{
v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex));
if (data.IsEmpty() || !data->IsString())
@@ -154,43 +117,13 @@ int V8InspectorImpl::getGroupId(v8::Local<v8::Context> context)
return dataString.substring(0, commaPos).toInt();
}
-void V8InspectorImpl::debuggerAgentEnabled()
-{
- if (!m_enabledAgentsCount++)
- enable();
-}
-
-void V8InspectorImpl::debuggerAgentDisabled()
-{
- if (!--m_enabledAgentsCount)
- disable();
-}
-
-V8DebuggerAgentImpl* V8InspectorImpl::findEnabledDebuggerAgent(int contextGroupId)
-{
- if (!contextGroupId)
- return nullptr;
- SessionMap::iterator it = m_sessions.find(contextGroupId);
- if (it == m_sessions.end())
- return nullptr;
- V8DebuggerAgentImpl* agent = it->second->debuggerAgent();
- if (!agent->enabled())
- return nullptr;
- return agent;
-}
-
-V8DebuggerAgentImpl* V8InspectorImpl::findEnabledDebuggerAgent(v8::Local<v8::Context> context)
-{
- return findEnabledDebuggerAgent(getGroupId(context));
-}
-
-void V8InspectorImpl::getCompiledScripts(int contextGroupId, std::vector<std::unique_ptr<V8DebuggerScript>>& result)
+void V8Debugger::getCompiledScripts(int contextGroupId, std::vector<std::unique_ptr<V8DebuggerScript>>& result)
{
v8::HandleScope scope(m_isolate);
v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
DCHECK(!debuggerScript->IsUndefined());
- v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(debuggerScript->Get(v8InternalizedString("getScripts")));
+ v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(debuggerScript->Get(toV8StringInternalized(m_isolate, "getScripts")));
v8::Local<v8::Value> argv[] = { v8::Integer::New(m_isolate, contextGroupId) };
v8::Local<v8::Value> value;
if (!getScriptsFunction->Call(debuggerContext(), debuggerScript, PROTOCOL_ARRAY_LENGTH(argv), argv).ToLocal(&value))
@@ -204,49 +137,49 @@ void V8InspectorImpl::getCompiledScripts(int contextGroupId, std::vector<std::un
}
}
-String16 V8InspectorImpl::setBreakpoint(const String16& sourceID, const ScriptBreakpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation)
+String16 V8Debugger::setBreakpoint(const String16& sourceID, const ScriptBreakpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber, bool interstatementLocation)
{
v8::HandleScope scope(m_isolate);
v8::Context::Scope contextScope(debuggerContext());
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
- info->Set(v8InternalizedString("sourceID"), toV8String(m_isolate, sourceID));
- info->Set(v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, scriptBreakpoint.lineNumber));
- info->Set(v8InternalizedString("columnNumber"), v8::Integer::New(m_isolate, scriptBreakpoint.columnNumber));
- info->Set(v8InternalizedString("interstatementLocation"), v8Boolean(interstatementLocation, m_isolate));
- info->Set(v8InternalizedString("condition"), toV8String(m_isolate, scriptBreakpoint.condition));
+ info->Set(toV8StringInternalized(m_isolate, "sourceID"), toV8String(m_isolate, sourceID));
+ info->Set(toV8StringInternalized(m_isolate, "lineNumber"), v8::Integer::New(m_isolate, scriptBreakpoint.lineNumber));
+ info->Set(toV8StringInternalized(m_isolate, "columnNumber"), v8::Integer::New(m_isolate, scriptBreakpoint.columnNumber));
+ info->Set(toV8StringInternalized(m_isolate, "interstatementLocation"), v8Boolean(interstatementLocation, m_isolate));
+ info->Set(toV8StringInternalized(m_isolate, "condition"), toV8String(m_isolate, scriptBreakpoint.condition));
- v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("setBreakpoint")));
+ v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "setBreakpoint")));
v8::Local<v8::Value> breakpointId = v8::Debug::Call(debuggerContext(), setBreakpointFunction, info).ToLocalChecked();
if (!breakpointId->IsString())
return "";
- *actualLineNumber = info->Get(v8InternalizedString("lineNumber"))->Int32Value();
- *actualColumnNumber = info->Get(v8InternalizedString("columnNumber"))->Int32Value();
+ *actualLineNumber = info->Get(toV8StringInternalized(m_isolate, "lineNumber"))->Int32Value();
+ *actualColumnNumber = info->Get(toV8StringInternalized(m_isolate, "columnNumber"))->Int32Value();
return toProtocolString(breakpointId.As<v8::String>());
}
-void V8InspectorImpl::removeBreakpoint(const String16& breakpointId)
+void V8Debugger::removeBreakpoint(const String16& breakpointId)
{
v8::HandleScope scope(m_isolate);
v8::Context::Scope contextScope(debuggerContext());
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
- info->Set(v8InternalizedString("breakpointId"), toV8String(m_isolate, breakpointId));
+ info->Set(toV8StringInternalized(m_isolate, "breakpointId"), toV8String(m_isolate, breakpointId));
- v8::Local<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("removeBreakpoint")));
+ v8::Local<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "removeBreakpoint")));
v8::Debug::Call(debuggerContext(), removeBreakpointFunction, info).ToLocalChecked();
}
-void V8InspectorImpl::clearBreakpoints()
+void V8Debugger::clearBreakpoints()
{
v8::HandleScope scope(m_isolate);
v8::Context::Scope contextScope(debuggerContext());
- v8::Local<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("clearBreakpoints")));
+ v8::Local<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "clearBreakpoints")));
v8::Debug::Call(debuggerContext(), clearBreakpoints).ToLocalChecked();
}
-void V8InspectorImpl::setBreakpointsActivated(bool activated)
+void V8Debugger::setBreakpointsActivated(bool activated)
{
if (!enabled()) {
NOTREACHED();
@@ -256,14 +189,14 @@ void V8InspectorImpl::setBreakpointsActivated(bool activated)
v8::Context::Scope contextScope(debuggerContext());
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
- info->Set(v8InternalizedString("enabled"), v8::Boolean::New(m_isolate, activated));
- v8::Local<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("setBreakpointsActivated")));
+ info->Set(toV8StringInternalized(m_isolate, "enabled"), v8::Boolean::New(m_isolate, activated));
+ v8::Local<v8::Function> setBreakpointsActivated = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "setBreakpointsActivated")));
v8::Debug::Call(debuggerContext(), setBreakpointsActivated, info).ToLocalChecked();
m_breakpointsActivated = activated;
}
-V8InspectorImpl::PauseOnExceptionsState V8InspectorImpl::getPauseOnExceptionsState()
+V8Debugger::PauseOnExceptionsState V8Debugger::getPauseOnExceptionsState()
{
DCHECK(enabled());
v8::HandleScope scope(m_isolate);
@@ -271,10 +204,10 @@ V8InspectorImpl::PauseOnExceptionsState V8InspectorImpl::getPauseOnExceptionsSta
v8::Local<v8::Value> argv[] = { v8::Undefined(m_isolate) };
v8::Local<v8::Value> result = callDebuggerMethod("pauseOnExceptionsState", 0, argv).ToLocalChecked();
- return static_cast<V8InspectorImpl::PauseOnExceptionsState>(result->Int32Value());
+ return static_cast<V8Debugger::PauseOnExceptionsState>(result->Int32Value());
}
-void V8InspectorImpl::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState)
+void V8Debugger::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState)
{
DCHECK(enabled());
v8::HandleScope scope(m_isolate);
@@ -284,7 +217,7 @@ void V8InspectorImpl::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnEx
callDebuggerMethod("setPauseOnExceptionsState", 1, argv);
}
-void V8InspectorImpl::setPauseOnNextStatement(bool pause)
+void V8Debugger::setPauseOnNextStatement(bool pause)
{
if (m_runningNestedMessageLoop)
return;
@@ -294,14 +227,14 @@ void V8InspectorImpl::setPauseOnNextStatement(bool pause)
v8::Debug::CancelDebugBreak(m_isolate);
}
-bool V8InspectorImpl::canBreakProgram()
+bool V8Debugger::canBreakProgram()
{
if (!m_breakpointsActivated)
return false;
return m_isolate->InContext();
}
-void V8InspectorImpl::breakProgram()
+void V8Debugger::breakProgram()
{
if (isPaused()) {
DCHECK(!m_runningNestedMessageLoop);
@@ -316,20 +249,20 @@ void V8InspectorImpl::breakProgram()
v8::HandleScope scope(m_isolate);
v8::Local<v8::Function> breakFunction;
- if (!v8::Function::New(m_isolate->GetCurrentContext(), &V8InspectorImpl::breakProgramCallback, v8::External::New(m_isolate, this), 0, v8::ConstructorBehavior::kThrow).ToLocal(&breakFunction))
+ if (!v8::Function::New(m_isolate->GetCurrentContext(), &V8Debugger::breakProgramCallback, v8::External::New(m_isolate, this), 0, v8::ConstructorBehavior::kThrow).ToLocal(&breakFunction))
return;
v8::Debug::Call(debuggerContext(), breakFunction).ToLocalChecked();
}
-void V8InspectorImpl::continueProgram()
+void V8Debugger::continueProgram()
{
if (isPaused())
- m_client->quitMessageLoopOnPause();
+ m_inspector->client()->quitMessageLoopOnPause();
m_pausedContext.Clear();
m_executionState.Clear();
}
-void V8InspectorImpl::stepIntoStatement()
+void V8Debugger::stepIntoStatement()
{
DCHECK(isPaused());
DCHECK(!m_executionState.IsEmpty());
@@ -339,7 +272,7 @@ void V8InspectorImpl::stepIntoStatement()
continueProgram();
}
-void V8InspectorImpl::stepOverStatement()
+void V8Debugger::stepOverStatement()
{
DCHECK(isPaused());
DCHECK(!m_executionState.IsEmpty());
@@ -349,7 +282,7 @@ void V8InspectorImpl::stepOverStatement()
continueProgram();
}
-void V8InspectorImpl::stepOutOfFunction()
+void V8Debugger::stepOutOfFunction()
{
DCHECK(isPaused());
DCHECK(!m_executionState.IsEmpty());
@@ -359,7 +292,7 @@ void V8InspectorImpl::stepOutOfFunction()
continueProgram();
}
-void V8InspectorImpl::clearStepping()
+void V8Debugger::clearStepping()
{
DCHECK(enabled());
v8::HandleScope scope(m_isolate);
@@ -369,7 +302,7 @@ void V8InspectorImpl::clearStepping()
callDebuggerMethod("clearStepping", 0, argv);
}
-bool V8InspectorImpl::setScriptSource(const String16& sourceID, v8::Local<v8::String> newSource, bool preview, ErrorString* error, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged)
+bool V8Debugger::setScriptSource(const String16& sourceID, v8::Local<v8::String> newSource, bool preview, ErrorString* error, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails, JavaScriptCallFrames* newCallFrames, Maybe<bool>* stackChanged)
{
class EnableLiveEditScope {
public:
@@ -441,13 +374,13 @@ bool V8InspectorImpl::setScriptSource(const String16& sourceID, v8::Local<v8::St
return false;
}
-JavaScriptCallFrames V8InspectorImpl::currentCallFrames(int limit)
+JavaScriptCallFrames V8Debugger::currentCallFrames(int limit)
{
if (!m_isolate->InContext())
return JavaScriptCallFrames();
v8::Local<v8::Value> currentCallFramesV8;
if (m_executionState.IsEmpty()) {
- v8::Local<v8::Function> currentCallFramesFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(v8InternalizedString("currentCallFrames")));
+ v8::Local<v8::Function> currentCallFramesFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(toV8StringInternalized(m_isolate, "currentCallFrames")));
currentCallFramesV8 = v8::Debug::Call(debuggerContext(), currentCallFramesFunction, v8::Integer::New(m_isolate, limit)).ToLocalChecked();
} else {
v8::Local<v8::Value> argv[] = { m_executionState, v8::Integer::New(m_isolate, limit) };
@@ -470,16 +403,16 @@ JavaScriptCallFrames V8InspectorImpl::currentCallFrames(int limit)
return callFrames;
}
-static V8InspectorImpl* toV8InspectorImpl(v8::Local<v8::Value> data)
+static V8Debugger* toV8Debugger(v8::Local<v8::Value> data)
{
void* p = v8::Local<v8::External>::Cast(data)->Value();
- return static_cast<V8InspectorImpl*>(p);
+ return static_cast<V8Debugger*>(p);
}
-void V8InspectorImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
+void V8Debugger::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
DCHECK_EQ(info.Length(), 2);
- V8InspectorImpl* thisPtr = toV8InspectorImpl(info.Data());
+ V8Debugger* thisPtr = toV8Debugger(info.Data());
if (!thisPtr->enabled())
return;
v8::Local<v8::Context> pausedContext = thisPtr->m_isolate->GetCurrentContext();
@@ -488,13 +421,13 @@ void V8InspectorImpl::breakProgramCallback(const v8::FunctionCallbackInfo<v8::Va
thisPtr->handleProgramBreak(pausedContext, v8::Local<v8::Object>::Cast(info[0]), exception, hitBreakpoints);
}
-void V8InspectorImpl::handleProgramBreak(v8::Local<v8::Context> pausedContext, v8::Local<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::Array> hitBreakpointNumbers, bool isPromiseRejection)
+void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext, v8::Local<v8::Object> executionState, v8::Local<v8::Value> exception, v8::Local<v8::Array> hitBreakpointNumbers, bool isPromiseRejection)
{
// Don't allow nested breaks.
if (m_runningNestedMessageLoop)
return;
- V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(pausedContext);
+ V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext));
if (!agent)
return;
@@ -515,9 +448,9 @@ void V8InspectorImpl::handleProgramBreak(v8::Local<v8::Context> pausedContext, v
m_runningNestedMessageLoop = true;
int groupId = getGroupId(pausedContext);
DCHECK(groupId);
- m_client->runMessageLoopOnPause(groupId);
+ m_inspector->client()->runMessageLoopOnPause(groupId);
// The agent may have been removed in the nested loop.
- agent = findEnabledDebuggerAgent(pausedContext);
+ agent = m_inspector->enabledDebuggerAgentForGroup(getGroupId(pausedContext));
if (agent)
agent->didContinue();
m_runningNestedMessageLoop = false;
@@ -537,21 +470,21 @@ void V8InspectorImpl::handleProgramBreak(v8::Local<v8::Context> pausedContext, v
}
}
-void V8InspectorImpl::v8DebugEventCallback(const v8::Debug::EventDetails& eventDetails)
+void V8Debugger::v8DebugEventCallback(const v8::Debug::EventDetails& eventDetails)
{
- V8InspectorImpl* thisPtr = toV8InspectorImpl(eventDetails.GetCallbackData());
+ V8Debugger* thisPtr = toV8Debugger(eventDetails.GetCallbackData());
thisPtr->handleV8DebugEvent(eventDetails);
}
-v8::Local<v8::Value> V8InspectorImpl::callInternalGetterFunction(v8::Local<v8::Object> object, const char* functionName)
+v8::Local<v8::Value> V8Debugger::callInternalGetterFunction(v8::Local<v8::Object> object, const char* functionName)
{
v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
- v8::Local<v8::Value> getterValue = object->Get(v8InternalizedString(functionName));
+ v8::Local<v8::Value> getterValue = object->Get(toV8StringInternalized(m_isolate, functionName));
DCHECK(!getterValue.IsEmpty() && getterValue->IsFunction());
return v8::Local<v8::Function>::Cast(getterValue)->Call(m_isolate->GetCurrentContext(), object, 0, 0).ToLocalChecked();
}
-void V8InspectorImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDetails)
+void V8Debugger::handleV8DebugEvent(const v8::Debug::EventDetails& eventDetails)
{
if (!enabled())
return;
@@ -568,7 +501,7 @@ void V8InspectorImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDet
return;
}
- V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(eventContext);
+ V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(getGroupId(eventContext));
if (agent) {
v8::HandleScope scope(m_isolate);
if (event == v8::AfterCompile || event == v8::CompileError) {
@@ -593,7 +526,7 @@ void V8InspectorImpl::handleV8DebugEvent(const v8::Debug::EventDetails& eventDet
}
}
-void V8InspectorImpl::handleV8AsyncTaskEvent(v8::Local<v8::Context> context, v8::Local<v8::Object> executionState, v8::Local<v8::Object> eventData)
+void V8Debugger::handleV8AsyncTaskEvent(v8::Local<v8::Context> context, v8::Local<v8::Object> executionState, v8::Local<v8::Object> eventData)
{
if (!m_maxAsyncCallStackDepth)
return;
@@ -613,14 +546,14 @@ void V8InspectorImpl::handleV8AsyncTaskEvent(v8::Local<v8::Context> context, v8:
NOTREACHED();
}
-V8StackTraceImpl* V8InspectorImpl::currentAsyncCallChain()
+V8StackTraceImpl* V8Debugger::currentAsyncCallChain()
{
if (!m_currentStacks.size())
return nullptr;
return m_currentStacks.back().get();
}
-void V8InspectorImpl::compileDebuggerScript()
+void V8Debugger::compileDebuggerScript()
{
if (!m_debuggerScript.IsEmpty()) {
NOTREACHED();
@@ -632,7 +565,7 @@ void V8InspectorImpl::compileDebuggerScript()
v8::Local<v8::String> scriptValue = v8::String::NewFromUtf8(m_isolate, DebuggerScript_js, v8::NewStringType::kInternalized, sizeof(DebuggerScript_js)).ToLocalChecked();
v8::Local<v8::Value> value;
- if (!compileAndRunInternalScript(debuggerContext(), scriptValue).ToLocal(&value)) {
+ if (!m_inspector->compileAndRunInternalScript(debuggerContext(), scriptValue).ToLocal(&value)) {
NOTREACHED();
return;
}
@@ -640,18 +573,13 @@ void V8InspectorImpl::compileDebuggerScript()
m_debuggerScript.Reset(m_isolate, value.As<v8::Object>());
}
-v8::Local<v8::Context> V8InspectorImpl::debuggerContext() const
+v8::Local<v8::Context> V8Debugger::debuggerContext() const
{
DCHECK(!m_debuggerContext.IsEmpty());
return m_debuggerContext.Get(m_isolate);
}
-v8::Local<v8::String> V8InspectorImpl::v8InternalizedString(const char* str) const
-{
- return v8::String::NewFromUtf8(m_isolate, str, v8::NewStringType::kInternalized).ToLocalChecked();
-}
-
-v8::MaybeLocal<v8::Value> V8InspectorImpl::functionScopes(v8::Local<v8::Function> function)
+v8::MaybeLocal<v8::Value> V8Debugger::functionScopes(v8::Local<v8::Function> function)
{
if (!enabled()) {
NOTREACHED();
@@ -672,7 +600,7 @@ v8::MaybeLocal<v8::Value> V8InspectorImpl::functionScopes(v8::Local<v8::Function
return scopes;
}
-v8::MaybeLocal<v8::Array> V8InspectorImpl::internalProperties(v8::Local<v8::Context> context, v8::Local<v8::Value> value)
+v8::MaybeLocal<v8::Array> V8Debugger::internalProperties(v8::Local<v8::Context> context, v8::Local<v8::Value> value)
{
v8::Local<v8::Array> properties;
if (!v8::Debug::GetInternalProperties(m_isolate, value).ToLocal(&properties))
@@ -681,11 +609,11 @@ v8::MaybeLocal<v8::Array> V8InspectorImpl::internalProperties(v8::Local<v8::Cont
v8::Local<v8::Function> function = value.As<v8::Function>();
v8::Local<v8::Value> location = functionLocation(context, function);
if (location->IsObject()) {
- properties->Set(properties->Length(), v8InternalizedString("[[FunctionLocation]]"));
+ properties->Set(properties->Length(), toV8StringInternalized(m_isolate, "[[FunctionLocation]]"));
properties->Set(properties->Length(), location);
}
if (function->IsGeneratorFunction()) {
- properties->Set(properties->Length(), v8InternalizedString("[[IsGenerator]]"));
+ properties->Set(properties->Length(), toV8StringInternalized(m_isolate, "[[IsGenerator]]"));
properties->Set(properties->Length(), v8::True(m_isolate));
}
}
@@ -694,14 +622,14 @@ v8::MaybeLocal<v8::Array> V8InspectorImpl::internalProperties(v8::Local<v8::Cont
if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakSet() || value->IsSetIterator() || value->IsMapIterator()) {
v8::Local<v8::Value> entries = collectionEntries(context, v8::Local<v8::Object>::Cast(value));
if (entries->IsArray()) {
- properties->Set(properties->Length(), v8InternalizedString("[[Entries]]"));
+ properties->Set(properties->Length(), toV8StringInternalized(m_isolate, "[[Entries]]"));
properties->Set(properties->Length(), entries);
}
}
if (value->IsGeneratorObject()) {
v8::Local<v8::Value> location = generatorObjectLocation(v8::Local<v8::Object>::Cast(value));
if (location->IsObject()) {
- properties->Set(properties->Length(), v8InternalizedString("[[GeneratorLocation]]"));
+ properties->Set(properties->Length(), toV8StringInternalized(m_isolate, "[[GeneratorLocation]]"));
properties->Set(properties->Length(), location);
}
}
@@ -710,14 +638,14 @@ v8::MaybeLocal<v8::Array> V8InspectorImpl::internalProperties(v8::Local<v8::Cont
v8::Local<v8::Value> boundFunction = function->GetBoundFunction();
v8::Local<v8::Value> scopes;
if (boundFunction->IsUndefined() && functionScopes(function).ToLocal(&scopes)) {
- properties->Set(properties->Length(), v8InternalizedString("[[Scopes]]"));
+ properties->Set(properties->Length(), toV8StringInternalized(m_isolate, "[[Scopes]]"));
properties->Set(properties->Length(), scopes);
}
}
return properties;
}
-v8::Local<v8::Value> V8InspectorImpl::collectionEntries(v8::Local<v8::Context> context, v8::Local<v8::Object> object)
+v8::Local<v8::Value> V8Debugger::collectionEntries(v8::Local<v8::Context> context, v8::Local<v8::Object> object)
{
if (!enabled()) {
NOTREACHED();
@@ -735,7 +663,7 @@ v8::Local<v8::Value> V8InspectorImpl::collectionEntries(v8::Local<v8::Context> c
return entries;
}
-v8::Local<v8::Value> V8InspectorImpl::generatorObjectLocation(v8::Local<v8::Object> object)
+v8::Local<v8::Value> V8Debugger::generatorObjectLocation(v8::Local<v8::Object> object)
{
if (!enabled()) {
NOTREACHED();
@@ -751,7 +679,7 @@ v8::Local<v8::Value> V8InspectorImpl::generatorObjectLocation(v8::Local<v8::Obje
return location;
}
-v8::Local<v8::Value> V8InspectorImpl::functionLocation(v8::Local<v8::Context> context, v8::Local<v8::Function> function)
+v8::Local<v8::Value> V8Debugger::functionLocation(v8::Local<v8::Context> context, v8::Local<v8::Function> function)
{
int scriptId = function->ScriptId();
if (scriptId == v8::UnboundScript::kNoScriptId)
@@ -761,196 +689,39 @@ v8::Local<v8::Value> V8InspectorImpl::functionLocation(v8::Local<v8::Context> co
if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::Function::kLineOffsetNotFound)
return v8::Null(m_isolate);
v8::Local<v8::Object> location = v8::Object::New(m_isolate);
- if (!location->Set(context, v8InternalizedString("scriptId"), toV8String(m_isolate, String16::fromInteger(scriptId))).FromMaybe(false))
+ if (!location->Set(context, toV8StringInternalized(m_isolate, "scriptId"), toV8String(m_isolate, String16::fromInteger(scriptId))).FromMaybe(false))
return v8::Null(m_isolate);
- if (!location->Set(context, v8InternalizedString("lineNumber"), v8::Integer::New(m_isolate, lineNumber)).FromMaybe(false))
+ if (!location->Set(context, toV8StringInternalized(m_isolate, "lineNumber"), v8::Integer::New(m_isolate, lineNumber)).FromMaybe(false))
return v8::Null(m_isolate);
- if (!location->Set(context, v8InternalizedString("columnNumber"), v8::Integer::New(m_isolate, columnNumber)).FromMaybe(false))
+ if (!location->Set(context, toV8StringInternalized(m_isolate, "columnNumber"), v8::Integer::New(m_isolate, columnNumber)).FromMaybe(false))
return v8::Null(m_isolate);
if (!markAsInternal(context, location, V8InternalValueType::kLocation))
return v8::Null(m_isolate);
return location;
}
-bool V8InspectorImpl::isPaused()
+bool V8Debugger::isPaused()
{
return !m_pausedContext.IsEmpty();
}
-v8::MaybeLocal<v8::Value> V8InspectorImpl::runCompiledScript(v8::Local<v8::Context> context, v8::Local<v8::Script> script)
-{
- // TODO(dgozman): get rid of this check.
- if (!m_client->isExecutionAllowed())
- return v8::MaybeLocal<v8::Value>();
-
- v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicrotasks);
- int groupId = getGroupId(context);
- if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(groupId))
- agent->willExecuteScript(script->GetUnboundScript()->GetId());
- v8::MaybeLocal<v8::Value> result = script->Run(context);
- // Get agent from the map again, since it could have detached during script execution.
- if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(groupId))
- agent->didExecuteScript();
- return result;
-}
-
-v8::MaybeLocal<v8::Value> V8InspectorImpl::callFunction(v8::Local<v8::Function> function, v8::Local<v8::Context> context, v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[])
-{
- // TODO(dgozman): get rid of this check.
- if (!m_client->isExecutionAllowed())
- return v8::MaybeLocal<v8::Value>();
-
- v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kRunMicrotasks);
- int groupId = getGroupId(context);
- if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(groupId))
- agent->willExecuteScript(function->ScriptId());
- v8::MaybeLocal<v8::Value> result = function->Call(context, receiver, argc, info);
- // Get agent from the map again, since it could have detached during script execution.
- if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(groupId))
- agent->didExecuteScript();
- return result;
-}
-
-v8::MaybeLocal<v8::Value> V8InspectorImpl::compileAndRunInternalScript(v8::Local<v8::Context> context, v8::Local<v8::String> source)
-{
- v8::Local<v8::Script> script = compileScript(context, source, String(), true);
- if (script.IsEmpty())
- return v8::MaybeLocal<v8::Value>();
- v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
- return script->Run(context);
-}
-
-v8::Local<v8::Script> V8InspectorImpl::compileScript(v8::Local<v8::Context> context, v8::Local<v8::String> code, const String16& fileName, bool markAsInternal)
-{
- v8::ScriptOrigin origin(
- toV8String(m_isolate, fileName),
- v8::Integer::New(m_isolate, 0),
- v8::Integer::New(m_isolate, 0),
- v8::False(m_isolate), // sharable
- v8::Local<v8::Integer>(),
- v8::Boolean::New(m_isolate, markAsInternal), // internal
- toV8String(m_isolate, String16()), // sourceMap
- v8::True(m_isolate)); // opaqueresource
- v8::ScriptCompiler::Source source(code, origin);
- v8::Local<v8::Script> script;
- if (!v8::ScriptCompiler::Compile(context, &source, v8::ScriptCompiler::kNoCompileOptions).ToLocal(&script))
- return v8::Local<v8::Script>();
- return script;
-}
-
-void V8InspectorImpl::enableStackCapturingIfNeeded()
-{
- if (!m_capturingStackTracesCount)
- V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(m_isolate, true);
- ++m_capturingStackTracesCount;
-}
-
-void V8InspectorImpl::disableStackCapturingIfNeeded()
-{
- if (!(--m_capturingStackTracesCount))
- V8StackTraceImpl::setCaptureStackTraceForUncaughtExceptions(m_isolate, false);
-}
-
-V8ConsoleMessageStorage* V8InspectorImpl::ensureConsoleMessageStorage(int contextGroupId)
-{
- ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGroupId);
- if (storageIt == m_consoleStorageMap.end())
- storageIt = m_consoleStorageMap.insert(std::make_pair(contextGroupId, wrapUnique(new V8ConsoleMessageStorage(this, contextGroupId)))).first;
- return storageIt->second.get();
-}
-
-std::unique_ptr<V8StackTrace> V8InspectorImpl::createStackTrace(v8::Local<v8::StackTrace> stackTrace)
-{
- return createStackTraceImpl(stackTrace);
-}
-
-std::unique_ptr<V8StackTraceImpl> V8InspectorImpl::createStackTraceImpl(v8::Local<v8::StackTrace> stackTrace)
+std::unique_ptr<V8StackTraceImpl> V8Debugger::createStackTrace(v8::Local<v8::StackTrace> stackTrace)
{
int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurrentContext()) : 0;
return V8StackTraceImpl::create(this, contextGroupId, stackTrace, V8StackTraceImpl::maxCallStackSizeToCapture);
}
-std::unique_ptr<V8InspectorSession> V8InspectorImpl::connect(int contextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* client, const String16* state)
-{
- DCHECK(m_sessions.find(contextGroupId) == m_sessions.cend());
- std::unique_ptr<V8InspectorSessionImpl> session =
- V8InspectorSessionImpl::create(this, contextGroupId, channel, client, state);
- m_sessions[contextGroupId] = session.get();
- return std::move(session);
-}
-
-void V8InspectorImpl::disconnect(V8InspectorSessionImpl* session)
-{
- DCHECK(m_sessions.find(session->contextGroupId()) != m_sessions.end());
- m_sessions.erase(session->contextGroupId());
-}
-
-InspectedContext* V8InspectorImpl::getContext(int groupId, int contextId) const
-{
- ContextsByGroupMap::const_iterator contextGroupIt = m_contexts.find(groupId);
- if (contextGroupIt == m_contexts.end())
- return nullptr;
-
- ContextByIdMap::iterator contextIt = contextGroupIt->second->find(contextId);
- if (contextIt == contextGroupIt->second->end())
- return nullptr;
-
- return contextIt->second.get();
-}
-
-void V8InspectorImpl::contextCreated(const V8ContextInfo& info)
+int V8Debugger::markContext(const V8ContextInfo& info)
{
DCHECK(info.context->GetIsolate() == m_isolate);
- // TODO(dgozman): make s_lastContextId non-static.
- int contextId = atomicIncrement(&s_lastContextId);
+ int contextId = ++m_lastContextId;
String16 debugData = String16::fromInteger(info.contextGroupId) + "," + String16::fromInteger(contextId) + "," + (info.isDefault ? "default" : "nondefault");
- v8::HandleScope scope(m_isolate);
v8::Context::Scope contextScope(info.context);
info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData));
-
- ContextsByGroupMap::iterator contextIt = m_contexts.find(info.contextGroupId);
- if (contextIt == m_contexts.end())
- contextIt = m_contexts.insert(std::make_pair(info.contextGroupId, wrapUnique(new ContextByIdMap()))).first;
-
- const auto& contextById = contextIt->second;
-
- DCHECK(contextById->find(contextId) == contextById->cend());
- InspectedContext* context = new InspectedContext(this, info, contextId);
- (*contextById)[contextId] = wrapUnique(context);
- SessionMap::iterator sessionIt = m_sessions.find(info.contextGroupId);
- if (sessionIt != m_sessions.end())
- sessionIt->second->runtimeAgent()->reportExecutionContextCreated(context);
+ return contextId;
}
-void V8InspectorImpl::contextDestroyed(v8::Local<v8::Context> context)
-{
- int contextId = V8InspectorImpl::contextId(context);
- int contextGroupId = getGroupId(context);
-
- ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(contextGroupId);
- if (storageIt != m_consoleStorageMap.end())
- storageIt->second->contextDestroyed(contextId);
-
- InspectedContext* inspectedContext = getContext(contextGroupId, contextId);
- if (!inspectedContext)
- return;
-
- SessionMap::iterator iter = m_sessions.find(contextGroupId);
- if (iter != m_sessions.end())
- iter->second->runtimeAgent()->reportExecutionContextDestroyed(inspectedContext);
- discardInspectedContext(contextGroupId, contextId);
-}
-
-void V8InspectorImpl::resetContextGroup(int contextGroupId)
-{
- m_consoleStorageMap.erase(contextGroupId);
- SessionMap::iterator session = m_sessions.find(contextGroupId);
- if (session != m_sessions.end())
- session->second->reset();
- m_contexts.erase(contextGroupId);
-}
-
-void V8InspectorImpl::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth)
+void V8Debugger::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int depth)
{
if (depth <= 0)
m_maxAsyncCallStackDepthMap.erase(agent);
@@ -970,7 +741,7 @@ void V8InspectorImpl::setAsyncCallStackDepth(V8DebuggerAgentImpl* agent, int dep
allAsyncTasksCanceled();
}
-void V8InspectorImpl::asyncTaskScheduled(const String16& taskName, void* task, bool recurring)
+void V8Debugger::asyncTaskScheduled(const String16& taskName, void* task, bool recurring)
{
if (!m_maxAsyncCallStackDepth)
return;
@@ -984,7 +755,7 @@ void V8InspectorImpl::asyncTaskScheduled(const String16& taskName, void* task, b
}
}
-void V8InspectorImpl::asyncTaskCanceled(void* task)
+void V8Debugger::asyncTaskCanceled(void* task)
{
if (!m_maxAsyncCallStackDepth)
return;
@@ -992,7 +763,7 @@ void V8InspectorImpl::asyncTaskCanceled(void* task)
m_recurringTasks.erase(task);
}
-void V8InspectorImpl::asyncTaskStarted(void* task)
+void V8Debugger::asyncTaskStarted(void* task)
{
if (!m_maxAsyncCallStackDepth)
return;
@@ -1011,7 +782,7 @@ void V8InspectorImpl::asyncTaskStarted(void* task)
m_currentStacks.push_back(std::move(stack));
}
-void V8InspectorImpl::asyncTaskFinished(void* task)
+void V8Debugger::asyncTaskFinished(void* task)
{
if (!m_maxAsyncCallStackDepth)
return;
@@ -1027,7 +798,7 @@ void V8InspectorImpl::asyncTaskFinished(void* task)
m_asyncTaskStacks.erase(task);
}
-void V8InspectorImpl::allAsyncTasksCanceled()
+void V8Debugger::allAsyncTasksCanceled()
{
m_asyncTaskStacks.clear();
m_recurringTasks.clear();
@@ -1035,56 +806,7 @@ void V8InspectorImpl::allAsyncTasksCanceled()
m_currentTasks.clear();
}
-void V8InspectorImpl::willExecuteScript(v8::Local<v8::Context> context, int scriptId)
-{
- if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(context))
- agent->willExecuteScript(scriptId);
-}
-
-void V8InspectorImpl::didExecuteScript(v8::Local<v8::Context> context)
-{
- if (V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(context))
- agent->didExecuteScript();
-}
-
-void V8InspectorImpl::idleStarted()
-{
- m_isolate->GetCpuProfiler()->SetIdle(true);
-}
-
-void V8InspectorImpl::idleFinished()
-{
- m_isolate->GetCpuProfiler()->SetIdle(false);
-}
-
-unsigned V8InspectorImpl::exceptionThrown(v8::Local<v8::Context> context, const String16& message, v8::Local<v8::Value> exception, const String16& detailedMessage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int scriptId)
-{
- int contextGroupId = getGroupId(context);
- if (!contextGroupId)
- return 0;
- std::unique_ptr<V8StackTraceImpl> stackTraceImpl = wrapUnique(static_cast<V8StackTraceImpl*>(stackTrace.release()));
- unsigned exceptionId = ++m_lastExceptionId;
- std::unique_ptr<V8ConsoleMessage> consoleMessage = V8ConsoleMessage::createForException(m_client->currentTimeMS(), detailedMessage, url, lineNumber, columnNumber, std::move(stackTraceImpl), scriptId, m_isolate, message, contextId(context), exception, exceptionId);
- ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage));
- return exceptionId;
-}
-
-void V8InspectorImpl::exceptionRevoked(v8::Local<v8::Context> context, unsigned exceptionId, const String16& message)
-{
- int contextGroupId = getGroupId(context);
- if (!contextGroupId)
- return;
-
- std::unique_ptr<V8ConsoleMessage> consoleMessage = V8ConsoleMessage::createForRevokedException(m_client->currentTimeMS(), message, exceptionId);
- ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMessage));
-}
-
-std::unique_ptr<V8StackTrace> V8InspectorImpl::captureStackTrace(bool fullStack)
-{
- return captureStackTraceImpl(fullStack);
-}
-
-std::unique_ptr<V8StackTraceImpl> V8InspectorImpl::captureStackTraceImpl(bool fullStack)
+std::unique_ptr<V8StackTraceImpl> V8Debugger::captureStackTrace(bool fullStack)
{
if (!m_isolate->InContext())
return nullptr;
@@ -1095,41 +817,10 @@ std::unique_ptr<V8StackTraceImpl> V8InspectorImpl::captureStackTraceImpl(bool fu
return nullptr;
size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture : 1;
- SessionMap::iterator sessionIt = m_sessions.find(contextGroupId);
- if (sessionIt != m_sessions.end() && sessionIt->second->runtimeAgent()->enabled())
+ if (m_inspector->enabledRuntimeAgentForGroup(contextGroupId))
stackSize = V8StackTraceImpl::maxCallStackSizeToCapture;
return V8StackTraceImpl::capture(this, contextGroupId, stackSize);
}
-v8::Local<v8::Context> V8InspectorImpl::regexContext()
-{
- if (m_regexContext.IsEmpty())
- m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate));
- return m_regexContext.Get(m_isolate);
-}
-
-void V8InspectorImpl::discardInspectedContext(int contextGroupId, int contextId)
-{
- if (!getContext(contextGroupId, contextId))
- return;
- m_contexts[contextGroupId]->erase(contextId);
- if (m_contexts[contextGroupId]->empty())
- m_contexts.erase(contextGroupId);
-}
-
-const V8InspectorImpl::ContextByIdMap* V8InspectorImpl::contextGroup(int contextGroupId)
-{
- ContextsByGroupMap::iterator iter = m_contexts.find(contextGroupId);
- return iter == m_contexts.end() ? nullptr : iter->second.get();
-}
-
-V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup(int contextGroupId)
-{
- if (!contextGroupId)
- return nullptr;
- SessionMap::iterator iter = m_sessions.find(contextGroupId);
- return iter == m_sessions.end() ? nullptr : iter->second;
-}
-
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698