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 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1048 void V8DebuggerImpl::idleStarted() | 1050 void V8DebuggerImpl::idleStarted() |
1049 { | 1051 { |
1050 m_isolate->GetCpuProfiler()->SetIdle(true); | 1052 m_isolate->GetCpuProfiler()->SetIdle(true); |
1051 } | 1053 } |
1052 | 1054 |
1053 void V8DebuggerImpl::idleFinished() | 1055 void V8DebuggerImpl::idleFinished() |
1054 { | 1056 { |
1055 m_isolate->GetCpuProfiler()->SetIdle(false); | 1057 m_isolate->GetCpuProfiler()->SetIdle(false); |
1056 } | 1058 } |
1057 | 1059 |
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 { | |
1060 ensureConsoleMessageStorage(contextGroupId)->addMessage(V8ConsoleMessage::cr
eateExternal(m_client->currentTimeMS(), source, level, message, url, lineNumber,
columnNumber, std::move(stackTrace), scriptId, requestIdentifier, workerId)); | |
1061 } | |
1062 | |
1063 void V8DebuggerImpl::logToConsole(v8::Local<v8::Context> context, v8::Local<v8::
Value> arg1, v8::Local<v8::Value> arg2) | 1060 void V8DebuggerImpl::logToConsole(v8::Local<v8::Context> context, v8::Local<v8::
Value> arg1, v8::Local<v8::Value> arg2) |
1064 { | 1061 { |
1065 int contextGroupId = getGroupId(context); | 1062 int contextGroupId = getGroupId(context); |
1066 InspectedContext* inspectedContext = getContext(contextGroupId, contextId(co
ntext)); | 1063 InspectedContext* inspectedContext = getContext(contextGroupId, contextId(co
ntext)); |
1067 if (!inspectedContext) | 1064 if (!inspectedContext) |
1068 return; | 1065 return; |
1069 std::vector<v8::Local<v8::Value>> arguments; | 1066 std::vector<v8::Local<v8::Value>> arguments; |
1070 if (!arg1.IsEmpty()) | 1067 if (!arg1.IsEmpty()) |
1071 arguments.push_back(arg1); | 1068 arguments.push_back(arg1); |
1072 if (!arg2.IsEmpty()) | 1069 if (!arg2.IsEmpty()) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 if (!m_isolate->InContext()) | 1104 if (!m_isolate->InContext()) |
1108 return nullptr; | 1105 return nullptr; |
1109 | 1106 |
1110 v8::HandleScope handles(m_isolate); | 1107 v8::HandleScope handles(m_isolate); |
1111 int contextGroupId = getGroupId(m_isolate->GetCurrentContext()); | 1108 int contextGroupId = getGroupId(m_isolate->GetCurrentContext()); |
1112 if (!contextGroupId) | 1109 if (!contextGroupId) |
1113 return nullptr; | 1110 return nullptr; |
1114 | 1111 |
1115 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; | 1112 size_t stackSize = fullStack ? V8StackTraceImpl::maxCallStackSizeToCapture :
1; |
1116 SessionMap::iterator sessionIt = m_sessions.find(contextGroupId); | 1113 SessionMap::iterator sessionIt = m_sessions.find(contextGroupId); |
1117 if (sessionIt != m_sessions.end() && sessionIt->second->consoleAgent()->enab
led()) | 1114 if (sessionIt != m_sessions.end() && sessionIt->second->runtimeAgent()->enab
led()) |
1118 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; | 1115 stackSize = V8StackTraceImpl::maxCallStackSizeToCapture; |
1119 | 1116 |
1120 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); | 1117 return V8StackTraceImpl::capture(this, contextGroupId, stackSize); |
1121 } | 1118 } |
1122 | 1119 |
1123 v8::Local<v8::Context> V8DebuggerImpl::regexContext() | 1120 v8::Local<v8::Context> V8DebuggerImpl::regexContext() |
1124 { | 1121 { |
1125 if (m_regexContext.IsEmpty()) | 1122 if (m_regexContext.IsEmpty()) |
1126 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); | 1123 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); |
1127 return m_regexContext.Get(m_isolate); | 1124 return m_regexContext.Get(m_isolate); |
(...skipping 16 matching lines...) Expand all Loading... |
1144 | 1141 |
1145 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI
d) | 1142 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI
d) |
1146 { | 1143 { |
1147 if (!contextGroupId) | 1144 if (!contextGroupId) |
1148 return nullptr; | 1145 return nullptr; |
1149 SessionMap::iterator iter = m_sessions.find(contextGroupId); | 1146 SessionMap::iterator iter = m_sessions.find(contextGroupId); |
1150 return iter == m_sessions.end() ? nullptr : iter->second; | 1147 return iter == m_sessions.end() ? nullptr : iter->second; |
1151 } | 1148 } |
1152 | 1149 |
1153 } // namespace blink | 1150 } // namespace blink |
OLD | NEW |