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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp

Issue 2139543002: [DevTools] Report console API calls through Runtime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 void V8DebuggerImpl::idleFinished() 1053 void V8DebuggerImpl::idleFinished()
1054 { 1054 {
1055 m_isolate->GetCpuProfiler()->SetIdle(false); 1055 m_isolate->GetCpuProfiler()->SetIdle(false);
1056 } 1056 }
1057 1057
1058 void V8DebuggerImpl::addConsoleMessage(int contextGroupId, MessageSource source, MessageLevel level, const String16& message, const String16& url, unsigned line Number, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int scr iptId, const String16& requestIdentifier, const String16& workerId) 1058 void V8DebuggerImpl::addConsoleMessage(int contextGroupId, MessageSource source, MessageLevel level, const String16& message, const String16& url, unsigned line Number, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int scr iptId, const String16& requestIdentifier, const String16& workerId)
1059 { 1059 {
1060 ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::cr eateExternal(m_client->currentTimeMS(), source, level, message, url, lineNumber, columnNumber, std::move(stackTrace), scriptId, requestIdentifier, workerId)); 1060 ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::cr eateExternal(m_client->currentTimeMS(), source, level, message, url, lineNumber, columnNumber, std::move(stackTrace), scriptId, requestIdentifier, workerId));
1061 } 1061 }
1062 1062
1063 void V8DebuggerImpl::logToConsole(v8::Local<v8::Context> context, const String16 & message, v8::Local<v8::Value> arg1, v8::Local<v8::Value> arg2) 1063 void V8DebuggerImpl::logToConsole(v8::Local<v8::Context> context, v8::Local<v8:: Value> arg1, v8::Local<v8::Value> arg2)
1064 { 1064 {
1065 int contextGroupId = getGroupId(context); 1065 int contextGroupId = getGroupId(context);
1066 InspectedContext* inspectedContext = getContext(contextGroupId, contextId(co ntext)); 1066 InspectedContext* inspectedContext = getContext(contextGroupId, contextId(co ntext));
1067 if (!inspectedContext) 1067 if (!inspectedContext)
1068 return; 1068 return;
1069 std::vector<v8::Local<v8::Value>> arguments; 1069 std::vector<v8::Local<v8::Value>> arguments;
1070 if (!arg1.IsEmpty()) 1070 if (!arg1.IsEmpty())
1071 arguments.push_back(arg1); 1071 arguments.push_back(arg1);
1072 if (!arg2.IsEmpty()) 1072 if (!arg2.IsEmpty())
1073 arguments.push_back(arg2); 1073 arguments.push_back(arg2);
1074 ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::cr eateForConsoleAPI(m_client->currentTimeMS(), ConsoleAPIType::kLog, LogMessageLev el, message, arguments.size() ? &arguments : nullptr, captureStackTrace(false), inspectedContext)); 1074 ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::cr eateForConsoleAPI(m_client->currentTimeMS(), ConsoleAPIType::kLog, arguments, ca ptureStackTrace(false), inspectedContext));
1075 } 1075 }
1076 1076
1077 void V8DebuggerImpl::exceptionThrown(int contextGroupId, const String16& errorMe ssage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::uni que_ptr<V8StackTrace> stackTrace, int scriptId) 1077 void V8DebuggerImpl::exceptionThrown(int contextGroupId, const String16& errorMe ssage, const String16& url, unsigned lineNumber, unsigned columnNumber, std::uni que_ptr<V8StackTrace> stackTrace, int scriptId)
1078 { 1078 {
1079 m_client->messageAddedToConsole(contextGroupId, JSMessageSource, ErrorMessag eLevel, errorMessage, url, lineNumber, columnNumber, stackTrace.get());
1080 unsigned exceptionId = ++m_lastExceptionId; 1079 unsigned exceptionId = ++m_lastExceptionId;
1081 std::unique_ptr<V8ConsoleMessage> consoleMessage = V8ConsoleMessage::createF orException(m_client->currentTimeMS(), errorMessage, url, lineNumber, columnNumb er, std::move(stackTrace), scriptId, m_isolate, 0, v8::Local<v8::Value>(), excep tionId); 1080 std::unique_ptr<V8ConsoleMessage> consoleMessage = V8ConsoleMessage::createF orException(m_client->currentTimeMS(), errorMessage, url, lineNumber, columnNumb er, std::move(stackTrace), scriptId, m_isolate, 0, v8::Local<v8::Value>(), excep tionId);
1082 ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMes sage)); 1081 ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMes sage));
1083 } 1082 }
1084 1083
1085 unsigned V8DebuggerImpl::promiseRejected(v8::Local<v8::Context> context, const S tring16& errorMessage, v8::Local<v8::Value> exception, const String16& url, unsi gned lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace , int scriptId) 1084 unsigned V8DebuggerImpl::promiseRejected(v8::Local<v8::Context> context, const S tring16& errorMessage, v8::Local<v8::Value> exception, const String16& url, unsi gned lineNumber, unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace , int scriptId)
1086 { 1085 {
1087 int contextGroupId = getGroupId(context); 1086 int contextGroupId = getGroupId(context);
1088 if (!contextGroupId) 1087 if (!contextGroupId)
1089 return 0; 1088 return 0;
1090
1091 const String16 defaultMessage = "Uncaught (in promise)";
1092 String16 message = errorMessage;
1093 if (message.isEmpty())
1094 message = defaultMessage;
1095 else if (message.startWith("Uncaught "))
1096 message = message.substring(0, 8) + " (in promise)" + message.substring( 8);
1097
1098 m_client->messageAddedToConsole(contextGroupId, JSMessageSource, ErrorMessag eLevel, message, url, lineNumber, columnNumber, stackTrace.get());
1099 unsigned exceptionId = ++m_lastExceptionId; 1089 unsigned exceptionId = ++m_lastExceptionId;
1100 std::unique_ptr<V8ConsoleMessage> consoleMessage = V8ConsoleMessage::createF orException(m_client->currentTimeMS(), message, url, lineNumber, columnNumber, s td::move(stackTrace), scriptId, m_isolate, contextId(context), exception, except ionId); 1090 std::unique_ptr<V8ConsoleMessage> consoleMessage = V8ConsoleMessage::createF orException(m_client->currentTimeMS(), errorMessage, url, lineNumber, columnNumb er, std::move(stackTrace), scriptId, m_isolate, contextId(context), exception, e xceptionId);
1101 ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMes sage)); 1091 ensureConsoleMessageStorage(contextGroupId)->addMessage(std::move(consoleMes sage));
1102 return exceptionId; 1092 return exceptionId;
1103 } 1093 }
1104 1094
1105 void V8DebuggerImpl::promiseRejectionRevoked(v8::Local<v8::Context> context, uns igned promiseRejectionId) 1095 void V8DebuggerImpl::promiseRejectionRevoked(v8::Local<v8::Context> context, uns igned promiseRejectionId)
1106 { 1096 {
1107 int contextGroupId = getGroupId(context); 1097 int contextGroupId = getGroupId(context);
1108 if (!contextGroupId) 1098 if (!contextGroupId)
1109 return; 1099 return;
1110 1100
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 1158
1169 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d) 1159 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d)
1170 { 1160 {
1171 if (!contextGroupId) 1161 if (!contextGroupId)
1172 return nullptr; 1162 return nullptr;
1173 SessionMap::iterator iter = m_sessions.find(contextGroupId); 1163 SessionMap::iterator iter = m_sessions.find(contextGroupId);
1174 return iter == m_sessions.end() ? nullptr : iter->second; 1164 return iter == m_sessions.end() ? nullptr : iter->second;
1175 } 1165 }
1176 1166
1177 } // namespace blink 1167 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698