Commit 545f99d0 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] convert V8Console static methods into members

This step is required to implement console as builtin which calls console delegate methods.

BUG=v8:6175
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2783073002
Cr-Original-Commit-Position: refs/heads/master@{#44283}
Committed: https://chromium.googlesource.com/v8/v8/+/fe27dccd873024213b16d1e9810dda6a6c705571
Review-Url: https://codereview.chromium.org/2783073002
Cr-Commit-Position: refs/heads/master@{#44285}
parent 5b306f72
...@@ -406,9 +406,12 @@ Response InjectedScript::wrapEvaluateResult( ...@@ -406,9 +406,12 @@ Response InjectedScript::wrapEvaluateResult(
} }
v8::Local<v8::Object> InjectedScript::commandLineAPI() { v8::Local<v8::Object> InjectedScript::commandLineAPI() {
if (m_commandLineAPI.IsEmpty()) if (m_commandLineAPI.IsEmpty()) {
m_commandLineAPI.Reset(m_context->isolate(), m_commandLineAPI.Reset(
V8Console::createCommandLineAPI(m_context)); m_context->isolate(),
m_context->inspector()->console()->createCommandLineAPI(
m_context->context()));
}
return m_commandLineAPI.Get(m_context->isolate()); return m_commandLineAPI.Get(m_context->isolate());
} }
......
...@@ -28,9 +28,10 @@ InspectedContext::InspectedContext(V8InspectorImpl* inspector, ...@@ -28,9 +28,10 @@ InspectedContext::InspectedContext(V8InspectorImpl* inspector,
info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex),
v8::Int32::New(isolate, contextId)); v8::Int32::New(isolate, contextId));
v8::Local<v8::Object> global = info.context->Global(); v8::Local<v8::Object> global = info.context->Global();
v8::Local<v8::Object> console = V8Console::createConsole(this); v8::Local<v8::Object> console =
m_inspector->console()->createConsole(info.context);
if (info.hasMemoryOnConsole) { if (info.hasMemoryOnConsole) {
V8Console::installMemoryGetter(m_inspector, info.context, console); m_inspector->console()->installMemoryGetter(info.context, console);
} }
if (!global if (!global
->Set(info.context, toV8StringInternalized(isolate, "console"), ->Set(info.context, toV8StringInternalized(isolate, "console"),
......
...@@ -25,17 +25,14 @@ namespace { ...@@ -25,17 +25,14 @@ namespace {
class ConsoleHelper { class ConsoleHelper {
public: public:
explicit ConsoleHelper(const v8::FunctionCallbackInfo<v8::Value>& info) explicit ConsoleHelper(const v8::FunctionCallbackInfo<v8::Value>& info,
V8InspectorImpl* inspector)
: m_info(info), : m_info(info),
m_isolate(info.GetIsolate()), m_isolate(info.GetIsolate()),
m_context(info.GetIsolate()->GetCurrentContext()), m_context(info.GetIsolate()->GetCurrentContext()),
m_contextId(InspectedContext::contextId(m_context)) { m_inspector(inspector),
m_inspector = static_cast<V8InspectorImpl*>( m_contextId(InspectedContext::contextId(m_context)),
m_info.Data().As<v8::External>()->Value()); m_groupId(m_inspector->contextGroupId(m_contextId)) {}
m_groupId = m_inspector->contextGroupId(m_contextId);
}
V8InspectorImpl* inspector() { return m_inspector; }
int contextId() const { return m_contextId; } int contextId() const { return m_contextId; }
int groupId() const { return m_groupId; } int groupId() const { return m_groupId; }
...@@ -47,7 +44,7 @@ class ConsoleHelper { ...@@ -47,7 +44,7 @@ class ConsoleHelper {
} }
V8ConsoleMessageStorage* consoleMessageStorage() { V8ConsoleMessageStorage* consoleMessageStorage() {
return inspector()->ensureConsoleMessageStorage(m_groupId); return m_inspector->ensureConsoleMessageStorage(m_groupId);
} }
void reportCall(ConsoleAPIType type) { void reportCall(ConsoleAPIType type) {
...@@ -151,7 +148,6 @@ class ConsoleHelper { ...@@ -151,7 +148,6 @@ class ConsoleHelper {
const v8::FunctionCallbackInfo<v8::Value>& m_info; const v8::FunctionCallbackInfo<v8::Value>& m_info;
v8::Isolate* m_isolate; v8::Isolate* m_isolate;
v8::Local<v8::Context> m_context; v8::Local<v8::Context> m_context;
v8::Local<v8::Object> m_console;
V8InspectorImpl* m_inspector = nullptr; V8InspectorImpl* m_inspector = nullptr;
int m_contextId; int m_contextId;
int m_groupId; int m_groupId;
...@@ -192,76 +188,82 @@ void createBoundFunctionProperty(v8::Local<v8::Context> context, ...@@ -192,76 +188,82 @@ void createBoundFunctionProperty(v8::Local<v8::Context> context,
} // namespace } // namespace
V8Console::V8Console(V8InspectorImpl* inspector) : m_inspector(inspector) {}
void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCall(ConsoleAPIType::kDebug); ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDebug);
} }
void V8Console::errorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::errorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCall(ConsoleAPIType::kError); ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kError);
} }
void V8Console::infoCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::infoCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCall(ConsoleAPIType::kInfo); ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kInfo);
} }
void V8Console::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCall(ConsoleAPIType::kLog); ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kLog);
} }
void V8Console::warnCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::warnCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCall(ConsoleAPIType::kWarning); ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kWarning);
} }
void V8Console::dirCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::dirCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCall(ConsoleAPIType::kDir); ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDir);
} }
void V8Console::dirxmlCallback( void V8Console::dirxmlCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCall(ConsoleAPIType::kDirXML); ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDirXML);
} }
void V8Console::tableCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::tableCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCall(ConsoleAPIType::kTable); ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kTable);
} }
void V8Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kTrace, ConsoleHelper(info, m_inspector)
String16("console.trace")); .reportCallWithDefaultArgument(ConsoleAPIType::kTrace,
String16("console.trace"));
} }
void V8Console::groupCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::groupCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kStartGroup, ConsoleHelper(info, m_inspector)
String16("console.group")); .reportCallWithDefaultArgument(ConsoleAPIType::kStartGroup,
String16("console.group"));
} }
void V8Console::groupCollapsedCallback( void V8Console::groupCollapsedCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCallWithDefaultArgument( ConsoleHelper(info, m_inspector)
ConsoleAPIType::kStartGroupCollapsed, String16("console.groupCollapsed")); .reportCallWithDefaultArgument(ConsoleAPIType::kStartGroupCollapsed,
String16("console.groupCollapsed"));
} }
void V8Console::groupEndCallback( void V8Console::groupEndCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCallWithDefaultArgument( ConsoleHelper(info, m_inspector)
ConsoleAPIType::kEndGroup, String16("console.groupEnd")); .reportCallWithDefaultArgument(ConsoleAPIType::kEndGroup,
String16("console.groupEnd"));
} }
void V8Console::clearCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::clearCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
if (!helper.groupId()) return; if (!helper.groupId()) return;
helper.inspector()->client()->consoleClear(helper.groupId()); m_inspector->client()->consoleClear(helper.groupId());
helper.reportCallWithDefaultArgument(ConsoleAPIType::kClear, helper.reportCallWithDefaultArgument(ConsoleAPIType::kClear,
String16("console.clear")); String16("console.clear"));
} }
void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
String16 title = helper.firstArgToString(String16()); String16 title = helper.firstArgToString(String16());
String16 identifier; String16 identifier;
if (title.isEmpty()) { if (title.isEmpty()) {
std::unique_ptr<V8StackTraceImpl> stackTrace = std::unique_ptr<V8StackTraceImpl> stackTrace =
V8StackTraceImpl::capture(helper.inspector()->debugger(), 0, 1); V8StackTraceImpl::capture(m_inspector->debugger(), 0, 1);
if (stackTrace && !stackTrace->isEmpty()) { if (stackTrace && !stackTrace->isEmpty()) {
identifier = toString16(stackTrace->topSourceURL()) + ":" + identifier = toString16(stackTrace->topSourceURL()) + ":" +
String16::fromInteger(stackTrace->topLineNumber()); String16::fromInteger(stackTrace->topLineNumber());
...@@ -280,7 +282,7 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { ...@@ -280,7 +282,7 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
void V8Console::assertCallback( void V8Console::assertCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
if (helper.firstArgToBoolean(false)) return; if (helper.firstArgToBoolean(false)) return;
std::vector<v8::Local<v8::Value>> arguments; std::vector<v8::Local<v8::Value>> arguments;
...@@ -297,44 +299,43 @@ void V8Console::assertCallback( ...@@ -297,44 +299,43 @@ void V8Console::assertCallback(
void V8Console::markTimelineCallback( void V8Console::markTimelineCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportDeprecatedCall("V8Console#markTimelineDeprecated", ConsoleHelper(info, m_inspector)
"'console.markTimeline' is " .reportDeprecatedCall("V8Console#markTimelineDeprecated",
"deprecated. Please use " "'console.markTimeline' is "
"'console.timeStamp' instead."); "deprecated. Please use "
"'console.timeStamp' instead.");
timeStampCallback(info); timeStampCallback(info);
} }
void V8Console::profileCallback( void V8Console::profileCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent()) if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent())
profilerAgent->consoleProfile(helper.firstArgToString(String16())); profilerAgent->consoleProfile(helper.firstArgToString(String16()));
} }
void V8Console::profileEndCallback( void V8Console::profileEndCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent()) if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent())
profilerAgent->consoleProfileEnd(helper.firstArgToString(String16())); profilerAgent->consoleProfileEnd(helper.firstArgToString(String16()));
} }
static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info, static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info,
bool timelinePrefix) { bool timelinePrefix, V8InspectorImpl* inspector) {
ConsoleHelper helper(info); ConsoleHelper helper(info, inspector);
V8InspectorClient* client = helper.inspector()->client();
String16 protocolTitle = helper.firstArgToString("default"); String16 protocolTitle = helper.firstArgToString("default");
if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'";
client->consoleTime(toStringView(protocolTitle)); inspector->client()->consoleTime(toStringView(protocolTitle));
helper.consoleMessageStorage()->time(helper.contextId(), protocolTitle); helper.consoleMessageStorage()->time(helper.contextId(), protocolTitle);
} }
static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info, static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info,
bool timelinePrefix) { bool timelinePrefix, V8InspectorImpl* inspector) {
ConsoleHelper helper(info); ConsoleHelper helper(info, inspector);
V8InspectorClient* client = helper.inspector()->client();
String16 protocolTitle = helper.firstArgToString("default"); String16 protocolTitle = helper.firstArgToString("default");
if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'";
client->consoleTimeEnd(toStringView(protocolTitle)); inspector->client()->consoleTimeEnd(toStringView(protocolTitle));
double elapsed = helper.consoleMessageStorage()->timeEnd(helper.contextId(), double elapsed = helper.consoleMessageStorage()->timeEnd(helper.contextId(),
protocolTitle); protocolTitle);
String16 message = String16 message =
...@@ -344,42 +345,43 @@ static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info, ...@@ -344,42 +345,43 @@ static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info,
void V8Console::timelineCallback( void V8Console::timelineCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportDeprecatedCall( ConsoleHelper(info, m_inspector)
"V8Console#timeline", .reportDeprecatedCall("V8Console#timeline",
"'console.timeline' is deprecated. Please use 'console.time' instead."); "'console.timeline' is deprecated. Please use "
timeFunction(info, true); "'console.time' instead.");
timeFunction(info, true, m_inspector);
} }
void V8Console::timelineEndCallback( void V8Console::timelineEndCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportDeprecatedCall("V8Console#timelineEnd", ConsoleHelper(info, m_inspector)
"'console.timelineEnd' is " .reportDeprecatedCall("V8Console#timelineEnd",
"deprecated. Please use " "'console.timelineEnd' is "
"'console.timeEnd' instead."); "deprecated. Please use "
timeEndFunction(info, true); "'console.timeEnd' instead.");
timeEndFunction(info, true, m_inspector);
} }
void V8Console::timeCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::timeCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
timeFunction(info, false); timeFunction(info, false, m_inspector);
} }
void V8Console::timeEndCallback( void V8Console::timeEndCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
timeEndFunction(info, false); timeEndFunction(info, false, m_inspector);
} }
void V8Console::timeStampCallback( void V8Console::timeStampCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
String16 title = helper.firstArgToString(String16()); String16 title = helper.firstArgToString(String16());
helper.inspector()->client()->consoleTimeStamp(toStringView(title)); m_inspector->client()->consoleTimeStamp(toStringView(title));
} }
void V8Console::memoryGetterCallback( void V8Console::memoryGetterCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
V8InspectorClient* client = ConsoleHelper(info).inspector()->client();
v8::Local<v8::Value> memoryValue; v8::Local<v8::Value> memoryValue;
if (!client if (!m_inspector->client()
->memoryInfo(info.GetIsolate(), ->memoryInfo(info.GetIsolate(),
info.GetIsolate()->GetCurrentContext()) info.GetIsolate()->GetCurrentContext())
.ToLocal(&memoryValue)) .ToLocal(&memoryValue))
...@@ -398,7 +400,7 @@ void V8Console::keysCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { ...@@ -398,7 +400,7 @@ void V8Console::keysCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate(); v8::Isolate* isolate = info.GetIsolate();
info.GetReturnValue().Set(v8::Array::New(isolate)); info.GetReturnValue().Set(v8::Array::New(isolate));
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
v8::Local<v8::Object> obj; v8::Local<v8::Object> obj;
if (!helper.firstArgAsObject().ToLocal(&obj)) return; if (!helper.firstArgAsObject().ToLocal(&obj)) return;
v8::Local<v8::Array> names; v8::Local<v8::Array> names;
...@@ -412,7 +414,7 @@ void V8Console::valuesCallback( ...@@ -412,7 +414,7 @@ void V8Console::valuesCallback(
v8::Isolate* isolate = info.GetIsolate(); v8::Isolate* isolate = info.GetIsolate();
info.GetReturnValue().Set(v8::Array::New(isolate)); info.GetReturnValue().Set(v8::Array::New(isolate));
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
v8::Local<v8::Object> obj; v8::Local<v8::Object> obj;
if (!helper.firstArgAsObject().ToLocal(&obj)) return; if (!helper.firstArgAsObject().ToLocal(&obj)) return;
v8::Local<v8::Array> names; v8::Local<v8::Array> names;
...@@ -451,7 +453,7 @@ static void setFunctionBreakpoint(ConsoleHelper& helper, ...@@ -451,7 +453,7 @@ static void setFunctionBreakpoint(ConsoleHelper& helper,
void V8Console::debugFunctionCallback( void V8Console::debugFunctionCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
v8::Local<v8::Function> function; v8::Local<v8::Function> function;
if (!helper.firstArgAsFunction().ToLocal(&function)) return; if (!helper.firstArgAsFunction().ToLocal(&function)) return;
setFunctionBreakpoint(helper, function, setFunctionBreakpoint(helper, function,
...@@ -461,7 +463,7 @@ void V8Console::debugFunctionCallback( ...@@ -461,7 +463,7 @@ void V8Console::debugFunctionCallback(
void V8Console::undebugFunctionCallback( void V8Console::undebugFunctionCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
v8::Local<v8::Function> function; v8::Local<v8::Function> function;
if (!helper.firstArgAsFunction().ToLocal(&function)) return; if (!helper.firstArgAsFunction().ToLocal(&function)) return;
setFunctionBreakpoint(helper, function, setFunctionBreakpoint(helper, function,
...@@ -471,7 +473,7 @@ void V8Console::undebugFunctionCallback( ...@@ -471,7 +473,7 @@ void V8Console::undebugFunctionCallback(
void V8Console::monitorFunctionCallback( void V8Console::monitorFunctionCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
v8::Local<v8::Function> function; v8::Local<v8::Function> function;
if (!helper.firstArgAsFunction().ToLocal(&function)) return; if (!helper.firstArgAsFunction().ToLocal(&function)) return;
v8::Local<v8::Value> name = function->GetName(); v8::Local<v8::Value> name = function->GetName();
...@@ -494,7 +496,7 @@ void V8Console::monitorFunctionCallback( ...@@ -494,7 +496,7 @@ void V8Console::monitorFunctionCallback(
void V8Console::unmonitorFunctionCallback( void V8Console::unmonitorFunctionCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
v8::Local<v8::Function> function; v8::Local<v8::Function> function;
if (!helper.firstArgAsFunction().ToLocal(&function)) return; if (!helper.firstArgAsFunction().ToLocal(&function)) return;
setFunctionBreakpoint(helper, function, setFunctionBreakpoint(helper, function,
...@@ -504,18 +506,18 @@ void V8Console::unmonitorFunctionCallback( ...@@ -504,18 +506,18 @@ void V8Console::unmonitorFunctionCallback(
void V8Console::lastEvaluationResultCallback( void V8Console::lastEvaluationResultCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
InjectedScript* injectedScript = helper.injectedScript(); InjectedScript* injectedScript = helper.injectedScript();
if (!injectedScript) return; if (!injectedScript) return;
info.GetReturnValue().Set(injectedScript->lastEvaluationResult()); info.GetReturnValue().Set(injectedScript->lastEvaluationResult());
} }
static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info, static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
bool copyToClipboard) { bool copyToClipboard, V8InspectorImpl* inspector) {
if (info.Length() < 1) return; if (info.Length() < 1) return;
if (!copyToClipboard) info.GetReturnValue().Set(info[0]); if (!copyToClipboard) info.GetReturnValue().Set(info[0]);
ConsoleHelper helper(info); ConsoleHelper helper(info, inspector);
InjectedScript* injectedScript = helper.injectedScript(); InjectedScript* injectedScript = helper.injectedScript();
if (!injectedScript) return; if (!injectedScript) return;
std::unique_ptr<protocol::Runtime::RemoteObject> wrappedObject; std::unique_ptr<protocol::Runtime::RemoteObject> wrappedObject;
...@@ -535,17 +537,17 @@ static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info, ...@@ -535,17 +537,17 @@ static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
void V8Console::inspectCallback( void V8Console::inspectCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
inspectImpl(info, false); inspectImpl(info, false, m_inspector);
} }
void V8Console::copyCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { void V8Console::copyCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
inspectImpl(info, true); inspectImpl(info, true, m_inspector);
} }
void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info, void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info,
unsigned num) { unsigned num) {
DCHECK(num < V8InspectorSessionImpl::kInspectedObjectBufferSize); DCHECK(num < V8InspectorSessionImpl::kInspectedObjectBufferSize);
ConsoleHelper helper(info); ConsoleHelper helper(info, m_inspector);
if (V8InspectorSessionImpl* session = helper.currentSession()) { if (V8InspectorSessionImpl* session = helper.currentSession()) {
V8InspectorSession::Inspectable* object = session->inspectedObject(num); V8InspectorSession::Inspectable* object = session->inspectedObject(num);
v8::Isolate* isolate = info.GetIsolate(); v8::Isolate* isolate = info.GetIsolate();
...@@ -556,9 +558,7 @@ void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info, ...@@ -556,9 +558,7 @@ void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info,
} }
} }
v8::Local<v8::Object> V8Console::createConsole( v8::Local<v8::Object> V8Console::createConsole(v8::Local<v8::Context> context) {
InspectedContext* inspectedContext) {
v8::Local<v8::Context> context = inspectedContext->context();
v8::Context::Scope contextScope(context); v8::Context::Scope contextScope(context);
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope microtasksScope(isolate,
...@@ -570,76 +570,78 @@ v8::Local<v8::Object> V8Console::createConsole( ...@@ -570,76 +570,78 @@ v8::Local<v8::Object> V8Console::createConsole(
DCHECK(success); DCHECK(success);
USE(success); USE(success);
v8::Local<v8::External> data = v8::Local<v8::External> data = v8::External::New(isolate, this);
v8::External::New(isolate, inspectedContext->inspector());
createBoundFunctionProperty(context, console, data, "debug", createBoundFunctionProperty(context, console, data, "debug",
V8Console::debugCallback); &V8Console::call<&V8Console::debugCallback>);
createBoundFunctionProperty(context, console, data, "error", createBoundFunctionProperty(context, console, data, "error",
V8Console::errorCallback); &V8Console::call<&V8Console::errorCallback>);
createBoundFunctionProperty(context, console, data, "info", createBoundFunctionProperty(context, console, data, "info",
V8Console::infoCallback); &V8Console::call<&V8Console::infoCallback>);
createBoundFunctionProperty(context, console, data, "log", createBoundFunctionProperty(context, console, data, "log",
V8Console::logCallback); &V8Console::call<&V8Console::logCallback>);
createBoundFunctionProperty(context, console, data, "warn", createBoundFunctionProperty(context, console, data, "warn",
V8Console::warnCallback); &V8Console::call<&V8Console::warnCallback>);
createBoundFunctionProperty(context, console, data, "dir", createBoundFunctionProperty(context, console, data, "dir",
V8Console::dirCallback); &V8Console::call<&V8Console::dirCallback>);
createBoundFunctionProperty(context, console, data, "dirxml", createBoundFunctionProperty(context, console, data, "dirxml",
V8Console::dirxmlCallback); &V8Console::call<&V8Console::dirxmlCallback>);
createBoundFunctionProperty(context, console, data, "table", createBoundFunctionProperty(context, console, data, "table",
V8Console::tableCallback); &V8Console::call<&V8Console::tableCallback>);
createBoundFunctionProperty(context, console, data, "trace", createBoundFunctionProperty(context, console, data, "trace",
V8Console::traceCallback); &V8Console::call<&V8Console::traceCallback>);
createBoundFunctionProperty(context, console, data, "group", createBoundFunctionProperty(context, console, data, "group",
V8Console::groupCallback); &V8Console::call<&V8Console::groupCallback>);
createBoundFunctionProperty(context, console, data, "groupCollapsed", createBoundFunctionProperty(
V8Console::groupCollapsedCallback); context, console, data, "groupCollapsed",
&V8Console::call<&V8Console::groupCollapsedCallback>);
createBoundFunctionProperty(context, console, data, "groupEnd", createBoundFunctionProperty(context, console, data, "groupEnd",
V8Console::groupEndCallback); &V8Console::call<&V8Console::groupEndCallback>);
createBoundFunctionProperty(context, console, data, "clear", createBoundFunctionProperty(context, console, data, "clear",
V8Console::clearCallback); &V8Console::call<&V8Console::clearCallback>);
createBoundFunctionProperty(context, console, data, "count", createBoundFunctionProperty(context, console, data, "count",
V8Console::countCallback); &V8Console::call<&V8Console::countCallback>);
createBoundFunctionProperty(context, console, data, "assert", createBoundFunctionProperty(context, console, data, "assert",
V8Console::assertCallback); &V8Console::call<&V8Console::assertCallback>);
createBoundFunctionProperty(context, console, data, "markTimeline", createBoundFunctionProperty(
V8Console::markTimelineCallback); context, console, data, "markTimeline",
&V8Console::call<&V8Console::markTimelineCallback>);
createBoundFunctionProperty(context, console, data, "profile", createBoundFunctionProperty(context, console, data, "profile",
V8Console::profileCallback); &V8Console::call<&V8Console::profileCallback>);
createBoundFunctionProperty(context, console, data, "profileEnd", createBoundFunctionProperty(context, console, data, "profileEnd",
V8Console::profileEndCallback); &V8Console::call<&V8Console::profileEndCallback>);
createBoundFunctionProperty(context, console, data, "timeline", createBoundFunctionProperty(context, console, data, "timeline",
V8Console::timelineCallback); &V8Console::call<&V8Console::timelineCallback>);
createBoundFunctionProperty(context, console, data, "timelineEnd", createBoundFunctionProperty(
V8Console::timelineEndCallback); context, console, data, "timelineEnd",
&V8Console::call<&V8Console::timelineEndCallback>);
createBoundFunctionProperty(context, console, data, "time", createBoundFunctionProperty(context, console, data, "time",
V8Console::timeCallback); &V8Console::call<&V8Console::timeCallback>);
createBoundFunctionProperty(context, console, data, "timeEnd", createBoundFunctionProperty(context, console, data, "timeEnd",
V8Console::timeEndCallback); &V8Console::call<&V8Console::timeEndCallback>);
createBoundFunctionProperty(context, console, data, "timeStamp", createBoundFunctionProperty(context, console, data, "timeStamp",
V8Console::timeStampCallback); &V8Console::call<&V8Console::timeStampCallback>);
return console; return console;
} }
void V8Console::installMemoryGetter(V8InspectorImpl* inspector, void V8Console::installMemoryGetter(v8::Local<v8::Context> context,
v8::Local<v8::Context> context,
v8::Local<v8::Object> console) { v8::Local<v8::Object> console) {
v8::Local<v8::External> data = v8::Isolate* isolate = context->GetIsolate();
v8::External::New(inspector->isolate(), inspector); v8::Local<v8::External> data = v8::External::New(isolate, this);
console->SetAccessorProperty( console->SetAccessorProperty(
toV8StringInternalized(inspector->isolate(), "memory"), toV8StringInternalized(isolate, "memory"),
v8::Function::New(context, V8Console::memoryGetterCallback, data, 0, v8::Function::New(context,
v8::ConstructorBehavior::kThrow) &V8Console::call<&V8Console::memoryGetterCallback>,
data, 0, v8::ConstructorBehavior::kThrow)
.ToLocalChecked(), .ToLocalChecked(),
v8::Function::New(context, V8Console::memorySetterCallback, data, 0, v8::Function::New(context,
v8::ConstructorBehavior::kThrow) &V8Console::call<&V8Console::memorySetterCallback>,
data, 0, v8::ConstructorBehavior::kThrow)
.ToLocalChecked(), .ToLocalChecked(),
static_cast<v8::PropertyAttribute>(v8::None), v8::DEFAULT); static_cast<v8::PropertyAttribute>(v8::None), v8::DEFAULT);
} }
v8::Local<v8::Object> V8Console::createCommandLineAPI( v8::Local<v8::Object> V8Console::createCommandLineAPI(
InspectedContext* inspectedContext) { v8::Local<v8::Context> context) {
v8::Local<v8::Context> context = inspectedContext->context();
v8::Isolate* isolate = context->GetIsolate(); v8::Isolate* isolate = context->GetIsolate();
v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope microtasksScope(isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks); v8::MicrotasksScope::kDoNotRunMicrotasks);
...@@ -650,70 +652,73 @@ v8::Local<v8::Object> V8Console::createCommandLineAPI( ...@@ -650,70 +652,73 @@ v8::Local<v8::Object> V8Console::createCommandLineAPI(
DCHECK(success); DCHECK(success);
USE(success); USE(success);
v8::Local<v8::External> data = v8::Local<v8::External> data = v8::External::New(isolate, this);
v8::External::New(isolate, inspectedContext->inspector());
createBoundFunctionProperty(context, commandLineAPI, data, "dir", createBoundFunctionProperty(context, commandLineAPI, data, "dir",
V8Console::dirCallback, &V8Console::call<&V8Console::dirCallback>,
"function dir(value) { [Command Line API] }"); "function dir(value) { [Command Line API] }");
createBoundFunctionProperty(context, commandLineAPI, data, "dirxml", createBoundFunctionProperty(context, commandLineAPI, data, "dirxml",
V8Console::dirxmlCallback, &V8Console::call<&V8Console::dirxmlCallback>,
"function dirxml(value) { [Command Line API] }"); "function dirxml(value) { [Command Line API] }");
createBoundFunctionProperty(context, commandLineAPI, data, "profile", createBoundFunctionProperty(context, commandLineAPI, data, "profile",
V8Console::profileCallback, &V8Console::call<&V8Console::profileCallback>,
"function profile(title) { [Command Line API] }"); "function profile(title) { [Command Line API] }");
createBoundFunctionProperty( createBoundFunctionProperty(
context, commandLineAPI, data, "profileEnd", context, commandLineAPI, data, "profileEnd",
V8Console::profileEndCallback, &V8Console::call<&V8Console::profileEndCallback>,
"function profileEnd(title) { [Command Line API] }"); "function profileEnd(title) { [Command Line API] }");
createBoundFunctionProperty(context, commandLineAPI, data, "clear", createBoundFunctionProperty(context, commandLineAPI, data, "clear",
V8Console::clearCallback, &V8Console::call<&V8Console::clearCallback>,
"function clear() { [Command Line API] }"); "function clear() { [Command Line API] }");
createBoundFunctionProperty( createBoundFunctionProperty(
context, commandLineAPI, data, "table", V8Console::tableCallback, context, commandLineAPI, data, "table",
&V8Console::call<&V8Console::tableCallback>,
"function table(data, [columns]) { [Command Line API] }"); "function table(data, [columns]) { [Command Line API] }");
createBoundFunctionProperty(context, commandLineAPI, data, "keys", createBoundFunctionProperty(context, commandLineAPI, data, "keys",
V8Console::keysCallback, &V8Console::call<&V8Console::keysCallback>,
"function keys(object) { [Command Line API] }"); "function keys(object) { [Command Line API] }");
createBoundFunctionProperty(context, commandLineAPI, data, "values", createBoundFunctionProperty(context, commandLineAPI, data, "values",
V8Console::valuesCallback, &V8Console::call<&V8Console::valuesCallback>,
"function values(object) { [Command Line API] }"); "function values(object) { [Command Line API] }");
createBoundFunctionProperty( createBoundFunctionProperty(
context, commandLineAPI, data, "debug", V8Console::debugFunctionCallback, context, commandLineAPI, data, "debug",
&V8Console::call<&V8Console::debugFunctionCallback>,
"function debug(function) { [Command Line API] }"); "function debug(function) { [Command Line API] }");
createBoundFunctionProperty( createBoundFunctionProperty(
context, commandLineAPI, data, "undebug", context, commandLineAPI, data, "undebug",
V8Console::undebugFunctionCallback, &V8Console::call<&V8Console::undebugFunctionCallback>,
"function undebug(function) { [Command Line API] }"); "function undebug(function) { [Command Line API] }");
createBoundFunctionProperty( createBoundFunctionProperty(
context, commandLineAPI, data, "monitor", context, commandLineAPI, data, "monitor",
V8Console::monitorFunctionCallback, &V8Console::call<&V8Console::monitorFunctionCallback>,
"function monitor(function) { [Command Line API] }"); "function monitor(function) { [Command Line API] }");
createBoundFunctionProperty( createBoundFunctionProperty(
context, commandLineAPI, data, "unmonitor", context, commandLineAPI, data, "unmonitor",
V8Console::unmonitorFunctionCallback, &V8Console::call<&V8Console::unmonitorFunctionCallback>,
"function unmonitor(function) { [Command Line API] }"); "function unmonitor(function) { [Command Line API] }");
createBoundFunctionProperty( createBoundFunctionProperty(
context, commandLineAPI, data, "inspect", V8Console::inspectCallback, context, commandLineAPI, data, "inspect",
&V8Console::call<&V8Console::inspectCallback>,
"function inspect(object) { [Command Line API] }"); "function inspect(object) { [Command Line API] }");
createBoundFunctionProperty(context, commandLineAPI, data, "copy", createBoundFunctionProperty(context, commandLineAPI, data, "copy",
V8Console::copyCallback, &V8Console::call<&V8Console::copyCallback>,
"function copy(value) { [Command Line API] }"); "function copy(value) { [Command Line API] }");
createBoundFunctionProperty(context, commandLineAPI, data, "$_", createBoundFunctionProperty(
V8Console::lastEvaluationResultCallback); context, commandLineAPI, data, "$_",
&V8Console::call<&V8Console::lastEvaluationResultCallback>);
createBoundFunctionProperty(context, commandLineAPI, data, "$0", createBoundFunctionProperty(context, commandLineAPI, data, "$0",
V8Console::inspectedObject0); &V8Console::call<&V8Console::inspectedObject0>);
createBoundFunctionProperty(context, commandLineAPI, data, "$1", createBoundFunctionProperty(context, commandLineAPI, data, "$1",
V8Console::inspectedObject1); &V8Console::call<&V8Console::inspectedObject1>);
createBoundFunctionProperty(context, commandLineAPI, data, "$2", createBoundFunctionProperty(context, commandLineAPI, data, "$2",
V8Console::inspectedObject2); &V8Console::call<&V8Console::inspectedObject2>);
createBoundFunctionProperty(context, commandLineAPI, data, "$3", createBoundFunctionProperty(context, commandLineAPI, data, "$3",
V8Console::inspectedObject3); &V8Console::call<&V8Console::inspectedObject3>);
createBoundFunctionProperty(context, commandLineAPI, data, "$4", createBoundFunctionProperty(context, commandLineAPI, data, "$4",
V8Console::inspectedObject4); &V8Console::call<&V8Console::inspectedObject4>);
inspectedContext->inspector()->client()->installAdditionalCommandLineAPI( m_inspector->client()->installAdditionalCommandLineAPI(context,
context, commandLineAPI); commandLineAPI);
return commandLineAPI; return commandLineAPI;
} }
......
...@@ -18,11 +18,10 @@ class V8InspectorImpl; ...@@ -18,11 +18,10 @@ class V8InspectorImpl;
// https://console.spec.whatwg.org/#console-interface // https://console.spec.whatwg.org/#console-interface
class V8Console { class V8Console {
public: public:
static v8::Local<v8::Object> createConsole(InspectedContext*); v8::Local<v8::Object> createConsole(v8::Local<v8::Context> context);
static v8::Local<v8::Object> createCommandLineAPI(InspectedContext*); v8::Local<v8::Object> createCommandLineAPI(v8::Local<v8::Context> context);
static void installMemoryGetter(V8InspectorImpl* inspector, void installMemoryGetter(v8::Local<v8::Context> context,
v8::Local<v8::Context> context, v8::Local<v8::Object> console);
v8::Local<v8::Object> console);
class CommandLineAPIScope { class CommandLineAPIScope {
public: public:
...@@ -47,72 +46,74 @@ class V8Console { ...@@ -47,72 +46,74 @@ class V8Console {
DISALLOW_COPY_AND_ASSIGN(CommandLineAPIScope); DISALLOW_COPY_AND_ASSIGN(CommandLineAPIScope);
}; };
explicit V8Console(V8InspectorImpl* inspector);
private: private:
static void debugCallback(const v8::FunctionCallbackInfo<v8::Value>&); void debugCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void errorCallback(const v8::FunctionCallbackInfo<v8::Value>&); void errorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void infoCallback(const v8::FunctionCallbackInfo<v8::Value>&); void infoCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void logCallback(const v8::FunctionCallbackInfo<v8::Value>&); void logCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void warnCallback(const v8::FunctionCallbackInfo<v8::Value>&); void warnCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void dirCallback(const v8::FunctionCallbackInfo<v8::Value>&); void dirCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void dirxmlCallback(const v8::FunctionCallbackInfo<v8::Value>&); void dirxmlCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void tableCallback(const v8::FunctionCallbackInfo<v8::Value>&); void tableCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void traceCallback(const v8::FunctionCallbackInfo<v8::Value>&); void traceCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void groupCallback(const v8::FunctionCallbackInfo<v8::Value>&); void groupCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void groupCollapsedCallback( void groupCollapsedCallback(const v8::FunctionCallbackInfo<v8::Value>&);
const v8::FunctionCallbackInfo<v8::Value>&); void groupEndCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void groupEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); void clearCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void clearCallback(const v8::FunctionCallbackInfo<v8::Value>&); void countCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void countCallback(const v8::FunctionCallbackInfo<v8::Value>&); void assertCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void assertCallback(const v8::FunctionCallbackInfo<v8::Value>&); void markTimelineCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void markTimelineCallback(const v8::FunctionCallbackInfo<v8::Value>&); void profileCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void profileCallback(const v8::FunctionCallbackInfo<v8::Value>&); void profileEndCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void profileEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); void timelineCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void timelineCallback(const v8::FunctionCallbackInfo<v8::Value>&); void timelineEndCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void timelineEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); void timeCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void timeCallback(const v8::FunctionCallbackInfo<v8::Value>&); void timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>&); void timeStampCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void timeStampCallback(const v8::FunctionCallbackInfo<v8::Value>&);
template <void (V8Console::*func)(const v8::FunctionCallbackInfo<v8::Value>&)>
static void call(const v8::FunctionCallbackInfo<v8::Value>& info) {
V8Console* console =
static_cast<V8Console*>(info.Data().As<v8::External>()->Value());
(console->*func)(info);
}
// TODO(foolip): There is no spec for the Memory Info API, see blink-dev: // TODO(foolip): There is no spec for the Memory Info API, see blink-dev:
// https://groups.google.com/a/chromium.org/d/msg/blink-dev/g5YRCGpC9vs/b4OJz71NmPwJ // https://groups.google.com/a/chromium.org/d/msg/blink-dev/g5YRCGpC9vs/b4OJz71NmPwJ
static void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); void memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&); void memorySetterCallback(const v8::FunctionCallbackInfo<v8::Value>&);
// CommandLineAPI // CommandLineAPI
static void keysCallback(const v8::FunctionCallbackInfo<v8::Value>&); void keysCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void valuesCallback(const v8::FunctionCallbackInfo<v8::Value>&); void valuesCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&); void debugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void undebugFunctionCallback( void undebugFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&);
const v8::FunctionCallbackInfo<v8::Value>&); void monitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void monitorFunctionCallback( void unmonitorFunctionCallback(const v8::FunctionCallbackInfo<v8::Value>&);
const v8::FunctionCallbackInfo<v8::Value>&); void lastEvaluationResultCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void unmonitorFunctionCallback( void inspectCallback(const v8::FunctionCallbackInfo<v8::Value>&);
const v8::FunctionCallbackInfo<v8::Value>&); void copyCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void lastEvaluationResultCallback( void inspectedObject(const v8::FunctionCallbackInfo<v8::Value>&,
const v8::FunctionCallbackInfo<v8::Value>&); unsigned num);
static void inspectCallback(const v8::FunctionCallbackInfo<v8::Value>&); void inspectedObject0(const v8::FunctionCallbackInfo<v8::Value>& info) {
static void copyCallback(const v8::FunctionCallbackInfo<v8::Value>&);
static void inspectedObject(const v8::FunctionCallbackInfo<v8::Value>&,
unsigned num);
static void inspectedObject0(
const v8::FunctionCallbackInfo<v8::Value>& info) {
inspectedObject(info, 0); inspectedObject(info, 0);
} }
static void inspectedObject1( void inspectedObject1(const v8::FunctionCallbackInfo<v8::Value>& info) {
const v8::FunctionCallbackInfo<v8::Value>& info) {
inspectedObject(info, 1); inspectedObject(info, 1);
} }
static void inspectedObject2( void inspectedObject2(const v8::FunctionCallbackInfo<v8::Value>& info) {
const v8::FunctionCallbackInfo<v8::Value>& info) {
inspectedObject(info, 2); inspectedObject(info, 2);
} }
static void inspectedObject3( void inspectedObject3(const v8::FunctionCallbackInfo<v8::Value>& info) {
const v8::FunctionCallbackInfo<v8::Value>& info) {
inspectedObject(info, 3); inspectedObject(info, 3);
} }
static void inspectedObject4( void inspectedObject4(const v8::FunctionCallbackInfo<v8::Value>& info) {
const v8::FunctionCallbackInfo<v8::Value>& info) {
inspectedObject(info, 4); inspectedObject(info, 4);
} }
V8InspectorImpl* m_inspector;
}; };
} // namespace v8_inspector } // namespace v8_inspector
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "src/inspector/string-util.h" #include "src/inspector/string-util.h"
#include "src/inspector/v8-console-agent-impl.h" #include "src/inspector/v8-console-agent-impl.h"
#include "src/inspector/v8-console-message.h" #include "src/inspector/v8-console-message.h"
#include "src/inspector/v8-console.h"
#include "src/inspector/v8-debugger-agent-impl.h" #include "src/inspector/v8-debugger-agent-impl.h"
#include "src/inspector/v8-debugger.h" #include "src/inspector/v8-debugger.h"
#include "src/inspector/v8-inspector-session-impl.h" #include "src/inspector/v8-inspector-session-impl.h"
...@@ -335,4 +336,9 @@ V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup( ...@@ -335,4 +336,9 @@ V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup(
return iter == m_sessions.end() ? nullptr : iter->second; return iter == m_sessions.end() ? nullptr : iter->second;
} }
V8Console* V8InspectorImpl::console() {
if (!m_console) m_console.reset(new V8Console(this));
return m_console.get();
}
} // namespace v8_inspector } // namespace v8_inspector
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
namespace v8_inspector { namespace v8_inspector {
class InspectedContext; class InspectedContext;
class V8Console;
class V8ConsoleMessageStorage; class V8ConsoleMessageStorage;
class V8Debugger; class V8Debugger;
class V8DebuggerAgentImpl; class V8DebuggerAgentImpl;
...@@ -111,6 +112,7 @@ class V8InspectorImpl : public V8Inspector { ...@@ -111,6 +112,7 @@ class V8InspectorImpl : public V8Inspector {
V8DebuggerAgentImpl* enabledDebuggerAgentForGroup(int contextGroupId); V8DebuggerAgentImpl* enabledDebuggerAgentForGroup(int contextGroupId);
V8RuntimeAgentImpl* enabledRuntimeAgentForGroup(int contextGroupId); V8RuntimeAgentImpl* enabledRuntimeAgentForGroup(int contextGroupId);
V8ProfilerAgentImpl* enabledProfilerAgentForGroup(int contextGroupId); V8ProfilerAgentImpl* enabledProfilerAgentForGroup(int contextGroupId);
V8Console* console();
private: private:
v8::Isolate* m_isolate; v8::Isolate* m_isolate;
...@@ -137,6 +139,8 @@ class V8InspectorImpl : public V8Inspector { ...@@ -137,6 +139,8 @@ class V8InspectorImpl : public V8Inspector {
protocol::HashMap<int, int> m_contextIdToGroupIdMap; protocol::HashMap<int, int> m_contextIdToGroupIdMap;
std::unique_ptr<V8Console> m_console;
DISALLOW_COPY_AND_ASSIGN(V8InspectorImpl); DISALLOW_COPY_AND_ASSIGN(V8InspectorImpl);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment