Commit 76e31da4 authored by pfeldman's avatar pfeldman Committed by Commit bot

V8 Inspector: remove V8ConsoleAPIType from the API, reuse v8::Isolate::MessageErrorLevel instead.

BUG=chromium:682521

Review-Url: https://codereview.chromium.org/2656613004
Cr-Commit-Position: refs/heads/master@{#42666}
parent 64b9aec0
......@@ -189,10 +189,16 @@ class V8_EXPORT V8InspectorClient {
virtual void installAdditionalCommandLineAPI(v8::Local<v8::Context>,
v8::Local<v8::Object>) {}
// Deprecated, to be replaced with v8::Isolate::MessageErrorLevel version.
virtual void consoleAPIMessage(int contextGroupId, V8ConsoleAPIType,
const StringView& message,
const StringView& url, unsigned lineNumber,
unsigned columnNumber, V8StackTrace*) {}
virtual void consoleAPIMessage(int contextGroupId,
v8::Isolate::MessageErrorLevel level,
const StringView& message,
const StringView& url, unsigned lineNumber,
unsigned columnNumber, V8StackTrace*) {}
virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*,
v8::Local<v8::Context>) {
return v8::MaybeLocal<v8::Value>();
......@@ -201,6 +207,7 @@ class V8_EXPORT V8InspectorClient {
virtual void consoleTime(const StringView& title) {}
virtual void consoleTimeEnd(const StringView& title) {}
virtual void consoleTimeStamp(const StringView& title) {}
virtual void consoleClear(int contextGroupId) {}
virtual double currentTimeMS() { return 0; }
typedef void (*TimerCallback)(void*);
virtual void startRepeatingTimer(double, TimerCallback, void* data) {}
......
......@@ -383,7 +383,7 @@
"name": "consoleAPICalled",
"description": "Issued when console API was called.",
"parameters": [
{ "name": "type", "type": "string", "enum": ["log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd"], "description": "Type of the call." },
{ "name": "type", "type": "string", "enum": ["log", "debug", "info", "error", "warning", "dir", "dirxml", "table", "trace", "clear", "startGroup", "startGroupCollapsed", "endGroup", "assert", "profile", "profileEnd", "count", "timeEnd"], "description": "Type of the call." },
{ "name": "args", "type": "array", "items": { "$ref": "RemoteObject" }, "description": "Call arguments." },
{ "name": "executionContextId", "$ref": "ExecutionContextId", "description": "Identifier of the context where the call was made." },
{ "name": "timestamp", "$ref": "Timestamp", "description": "Call timestamp." },
......
......@@ -50,9 +50,9 @@ String16 consoleAPITypeValue(ConsoleAPIType type) {
case ConsoleAPIType::kAssert:
return protocol::Runtime::ConsoleAPICalled::TypeEnum::Assert;
case ConsoleAPIType::kTimeEnd:
return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug;
return protocol::Runtime::ConsoleAPICalled::TypeEnum::TimeEnd;
case ConsoleAPIType::kCount:
return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug;
return protocol::Runtime::ConsoleAPICalled::TypeEnum::Count;
}
return protocol::Runtime::ConsoleAPICalled::TypeEnum::Log;
}
......@@ -378,22 +378,37 @@ std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
message->m_message = V8ValueStringBuilder::toString(arguments[0], context);
V8ConsoleAPIType clientType = V8ConsoleAPIType::kLog;
v8::Isolate::MessageErrorLevel clientLevel = v8::Isolate::kMessageInfo;
if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount ||
type == ConsoleAPIType::kTimeEnd)
type == ConsoleAPIType::kTimeEnd) {
clientType = V8ConsoleAPIType::kDebug;
else if (type == ConsoleAPIType::kError || type == ConsoleAPIType::kAssert)
clientLevel = v8::Isolate::kMessageDebug;
} else if (type == ConsoleAPIType::kError ||
type == ConsoleAPIType::kAssert) {
clientType = V8ConsoleAPIType::kError;
else if (type == ConsoleAPIType::kWarning)
clientLevel = v8::Isolate::kMessageError;
} else if (type == ConsoleAPIType::kWarning) {
clientType = V8ConsoleAPIType::kWarning;
else if (type == ConsoleAPIType::kInfo)
clientLevel = v8::Isolate::kMessageWarning;
} else if (type == ConsoleAPIType::kInfo || type == ConsoleAPIType::kLog) {
clientType = V8ConsoleAPIType::kInfo;
else if (type == ConsoleAPIType::kClear)
clientLevel = v8::Isolate::kMessageInfo;
} else if (type == ConsoleAPIType::kClear) {
clientType = V8ConsoleAPIType::kClear;
}
inspector->client()->consoleAPIMessage(
contextGroupId, clientType, toStringView(message->m_message),
toStringView(message->m_url), message->m_lineNumber,
message->m_columnNumber, message->m_stackTrace.get());
if (type != ConsoleAPIType::kClear) {
inspector->client()->consoleAPIMessage(
contextGroupId, clientLevel, toStringView(message->m_message),
toStringView(message->m_url), message->m_lineNumber,
message->m_columnNumber, message->m_stackTrace.get());
}
return message;
}
......
......@@ -336,7 +336,13 @@ void V8Console::groupEndCallback(
}
void V8Console::clearCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kClear,
ConsoleHelper helper(info);
InspectedContext* context = helper.ensureInspectedContext();
if (!context) return;
int contextGroupId = context->contextGroupId();
if (V8InspectorClient* client = helper.ensureDebuggerClient())
client->consoleClear(contextGroupId);
helper.reportCallWithDefaultArgument(ConsoleAPIType::kClear,
String16("console.clear"));
}
......
......@@ -51,7 +51,7 @@ set locale to fr_CA.UTF-8 (has comma as separator)
]
}
timestamp : <timestamp>
type : debug
type : timeEnd
}
}
......@@ -134,6 +134,6 @@ set locale to fr_CA.UTF-8 (has comma as separator)
]
}
timestamp : <timestamp>
type : debug
type : timeEnd
}
}
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