| OLD | NEW |
| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 m_debuggerContext.Reset(); | 114 m_debuggerContext.Reset(); |
| 115 allAsyncTasksCanceled(); | 115 allAsyncTasksCanceled(); |
| 116 v8::Debug::SetDebugEventListener(m_isolate, nullptr); | 116 v8::Debug::SetDebugEventListener(m_isolate, nullptr); |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool V8DebuggerImpl::enabled() const | 119 bool V8DebuggerImpl::enabled() const |
| 120 { | 120 { |
| 121 return !m_debuggerScript.IsEmpty(); | 121 return !m_debuggerScript.IsEmpty(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 // static |
| 124 int V8DebuggerImpl::contextId(v8::Local<v8::Context> context) | 125 int V8DebuggerImpl::contextId(v8::Local<v8::Context> context) |
| 125 { | 126 { |
| 126 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co
ntext::kDebugIdIndex)); | 127 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co
ntext::kDebugIdIndex)); |
| 127 if (data.IsEmpty() || !data->IsString()) | 128 if (data.IsEmpty() || !data->IsString()) |
| 128 return 0; | 129 return 0; |
| 129 String16 dataString = toProtocolString(data.As<v8::String>()); | 130 String16 dataString = toProtocolString(data.As<v8::String>()); |
| 130 if (dataString.isEmpty()) | 131 if (dataString.isEmpty()) |
| 131 return 0; | 132 return 0; |
| 132 size_t commaPos = dataString.find(","); | 133 size_t commaPos = dataString.find(","); |
| 133 if (commaPos == kNotFound) | 134 if (commaPos == kNotFound) |
| 134 return 0; | 135 return 0; |
| 135 size_t commaPos2 = dataString.find(",", commaPos + 1); | 136 size_t commaPos2 = dataString.find(",", commaPos + 1); |
| 136 if (commaPos2 == kNotFound) | 137 if (commaPos2 == kNotFound) |
| 137 return 0; | 138 return 0; |
| 138 return dataString.substring(commaPos + 1, commaPos2 - commaPos - 1).toInt(); | 139 return dataString.substring(commaPos + 1, commaPos2 - commaPos - 1).toInt(); |
| 139 } | 140 } |
| 140 | 141 |
| 141 static int getGroupId(v8::Local<v8::Context> context) | 142 // static |
| 143 int V8DebuggerImpl::getGroupId(v8::Local<v8::Context> context) |
| 142 { | 144 { |
| 143 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co
ntext::kDebugIdIndex)); | 145 v8::Local<v8::Value> data = context->GetEmbedderData(static_cast<int>(v8::Co
ntext::kDebugIdIndex)); |
| 144 if (data.IsEmpty() || !data->IsString()) | 146 if (data.IsEmpty() || !data->IsString()) |
| 145 return 0; | 147 return 0; |
| 146 String16 dataString = toProtocolString(data.As<v8::String>()); | 148 String16 dataString = toProtocolString(data.As<v8::String>()); |
| 147 if (dataString.isEmpty()) | 149 if (dataString.isEmpty()) |
| 148 return 0; | 150 return 0; |
| 149 size_t commaPos = dataString.find(","); | 151 size_t commaPos = dataString.find(","); |
| 150 if (commaPos == kNotFound) | 152 if (commaPos == kNotFound) |
| 151 return 0; | 153 return 0; |
| (...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 void V8DebuggerImpl::idleStarted() | 1051 void V8DebuggerImpl::idleStarted() |
| 1050 { | 1052 { |
| 1051 m_isolate->GetCpuProfiler()->SetIdle(true); | 1053 m_isolate->GetCpuProfiler()->SetIdle(true); |
| 1052 } | 1054 } |
| 1053 | 1055 |
| 1054 void V8DebuggerImpl::idleFinished() | 1056 void V8DebuggerImpl::idleFinished() |
| 1055 { | 1057 { |
| 1056 m_isolate->GetCpuProfiler()->SetIdle(false); | 1058 m_isolate->GetCpuProfiler()->SetIdle(false); |
| 1057 } | 1059 } |
| 1058 | 1060 |
| 1059 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) | |
| 1060 { | |
| 1061 ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::cr
eateExternal(m_client->currentTimeMS(), source, level, message, url, lineNumber,
columnNumber, std::move(stackTrace), scriptId, requestIdentifier, workerId)); | |
| 1062 } | |
| 1063 | |
| 1064 void V8DebuggerImpl::logToConsole(v8::Local<v8::Context> context, v8::Local<v8::
Value> arg1, v8::Local<v8::Value> arg2) | 1061 void V8DebuggerImpl::logToConsole(v8::Local<v8::Context> context, v8::Local<v8::
Value> arg1, v8::Local<v8::Value> arg2) |
| 1065 { | 1062 { |
| 1066 int contextGroupId = getGroupId(context); | 1063 int contextGroupId = getGroupId(context); |
| 1067 InspectedContext* inspectedContext = getContext(contextGroupId, contextId(co
ntext)); | 1064 InspectedContext* inspectedContext = getContext(contextGroupId, contextId(co
ntext)); |
| 1068 if (!inspectedContext) | 1065 if (!inspectedContext) |
| 1069 return; | 1066 return; |
| 1070 std::vector<v8::Local<v8::Value>> arguments; | 1067 std::vector<v8::Local<v8::Value>> arguments; |
| 1071 if (!arg1.IsEmpty()) | 1068 if (!arg1.IsEmpty()) |
| 1072 arguments.push_back(arg1); | 1069 arguments.push_back(arg1); |
| 1073 if (!arg2.IsEmpty()) | 1070 if (!arg2.IsEmpty()) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 if (!m_isolate->InContext()) | 1105 if (!m_isolate->InContext()) |
| 1109 return nullptr; | 1106 return nullptr; |
| 1110 | 1107 |
| 1111 v8::HandleScope handles(m_isolate); | 1108 v8::HandleScope handles(m_isolate); |
| 1112 int contextGroupId = getGroupId(m_isolate->GetCurrentContext()); | 1109 int contextGroupId = getGroupId(m_isolate->GetCurrentContext()); |
| 1113 if (!contextGroupId) | 1110 if (!contextGroupId) |
| 1114 return nullptr; | 1111 return nullptr; |
| 1115 | 1112 |
| 1116 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; | 1113 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; |
| 1117 SessionMap::iterator sessionIt = m_sessions.find(contextGroupId); | 1114 SessionMap::iterator sessionIt = m_sessions.find(contextGroupId); |
| 1118 if (sessionIt != m_sessions.end() && sessionIt->second->consoleAgent()->enab
led()) | 1115 if (sessionIt != m_sessions.end() && sessionIt->second->runtimeAgent()->enab
led()) |
| 1119 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 1116 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
| 1120 | 1117 |
| 1121 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 1118 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
| 1122 } | 1119 } |
| 1123 | 1120 |
| 1124 v8::Local<v8::Context> V8DebuggerImpl::regexContext() | 1121 v8::Local<v8::Context> V8DebuggerImpl::regexContext() |
| 1125 { | 1122 { |
| 1126 if (m_regexContext.IsEmpty()) | 1123 if (m_regexContext.IsEmpty()) |
| 1127 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); | 1124 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); |
| 1128 return m_regexContext.Get(m_isolate); | 1125 return m_regexContext.Get(m_isolate); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1145 | 1142 |
| 1146 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI
d) | 1143 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI
d) |
| 1147 { | 1144 { |
| 1148 if (!contextGroupId) | 1145 if (!contextGroupId) |
| 1149 return nullptr; | 1146 return nullptr; |
| 1150 SessionMap::iterator iter = m_sessions.find(contextGroupId); | 1147 SessionMap::iterator iter = m_sessions.find(contextGroupId); |
| 1151 return iter == m_sessions.end() ? nullptr : iter->second; | 1148 return iter == m_sessions.end() ? nullptr : iter->second; |
| 1152 } | 1149 } |
| 1153 | 1150 |
| 1154 } // namespace blink | 1151 } // namespace blink |
| OLD | NEW |