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

Unified Diff: src/inspector/v8-console-message.cc

Issue 2784713002: [inspector] console get all information from inspector when needed (Closed)
Patch Set: fixed last test Created 3 years, 9 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
« no previous file with comments | « src/inspector/v8-console-message.h ('k') | test/inspector/console/memory-setter-in-strict-mode.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/inspector/v8-console-message.cc
diff --git a/src/inspector/v8-console-message.cc b/src/inspector/v8-console-message.cc
index 73f74e4f67988221150dab285fb4afa2b0c128e7..22fe18137ede9a1cb1bda927634321fc7affd259 100644
--- a/src/inspector/v8-console-message.cc
+++ b/src/inspector/v8-console-message.cc
@@ -353,15 +353,11 @@ ConsoleAPIType V8ConsoleMessage::type() const { return m_type; }
// static
std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
- double timestamp, ConsoleAPIType type,
+ v8::Local<v8::Context> v8Context, int contextId, int groupId,
+ V8InspectorImpl* inspector, double timestamp, ConsoleAPIType type,
const std::vector<v8::Local<v8::Value>>& arguments,
- std::unique_ptr<V8StackTraceImpl> stackTrace,
- InspectedContext* inspectedContext) {
- v8::Isolate* isolate = inspectedContext->isolate();
- int contextId = inspectedContext->contextId();
- int contextGroupId = inspectedContext->contextGroupId();
- V8InspectorImpl* inspector = inspectedContext->inspector();
- v8::Local<v8::Context> context = inspectedContext->context();
+ std::unique_ptr<V8StackTraceImpl> stackTrace) {
+ v8::Isolate* isolate = v8Context->GetIsolate();
std::unique_ptr<V8ConsoleMessage> message(
new V8ConsoleMessage(V8MessageOrigin::kConsole, timestamp, String16()));
@@ -380,7 +376,8 @@ std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
v8::debug::EstimatedValueSize(isolate, arguments.at(i));
}
if (arguments.size())
- message->m_message = V8ValueStringBuilder::toString(arguments[0], context);
+ message->m_message =
+ V8ValueStringBuilder::toString(arguments[0], v8Context);
v8::Isolate::MessageErrorLevel clientLevel = v8::Isolate::kMessageInfo;
if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount ||
@@ -397,7 +394,7 @@ std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
if (type != ConsoleAPIType::kClear) {
inspector->client()->consoleAPIMessage(
- contextGroupId, clientLevel, toStringView(message->m_message),
+ groupId, clientLevel, toStringView(message->m_message),
toStringView(message->m_url), message->m_lineNumber,
message->m_columnNumber, message->m_stackTrace.get());
}
@@ -490,8 +487,37 @@ void V8ConsoleMessageStorage::clear() {
m_messages.clear();
m_estimatedSize = 0;
if (V8InspectorSessionImpl* session =
- m_inspector->sessionForContextGroup(m_contextGroupId))
+ m_inspector->sessionForContextGroup(m_contextGroupId)) {
session->releaseObjectGroup("console");
+ }
+ m_data.clear();
+}
+
+bool V8ConsoleMessageStorage::shouldReportDeprecationMessage(
+ int contextId, const String16& method) {
+ std::set<String16>& reportedDeprecationMessages =
+ m_data[contextId].m_reportedDeprecationMessages;
+ auto it = reportedDeprecationMessages.find(method);
+ if (it != reportedDeprecationMessages.end()) return false;
+ reportedDeprecationMessages.insert(it, method);
+ return true;
+}
+
+int V8ConsoleMessageStorage::count(int contextId, const String16& id) {
+ return ++m_data[contextId].m_count[id];
+}
+
+void V8ConsoleMessageStorage::time(int contextId, const String16& id) {
+ m_data[contextId].m_time[id] = m_inspector->client()->currentTimeMS();
+}
+
+double V8ConsoleMessageStorage::timeEnd(int contextId, const String16& id) {
+ std::map<String16, double>& time = m_data[contextId].m_time;
+ auto it = time.find(id);
+ if (it == time.end()) return 0.0;
+ double elapsed = m_inspector->client()->currentTimeMS() - it->second;
+ time.erase(it);
+ return elapsed;
}
void V8ConsoleMessageStorage::contextDestroyed(int contextId) {
@@ -500,6 +526,8 @@ void V8ConsoleMessageStorage::contextDestroyed(int contextId) {
m_messages[i]->contextDestroyed(contextId);
m_estimatedSize += m_messages[i]->estimatedSize();
}
+ auto it = m_data.find(contextId);
+ if (it != m_data.end()) m_data.erase(contextId);
}
} // namespace v8_inspector
« no previous file with comments | « src/inspector/v8-console-message.h ('k') | test/inspector/console/memory-setter-in-strict-mode.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698