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

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

Issue 2159633002: [DevTools] Generate public versions of protocol classes to be exposed in v8_inspector/public. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra files Created 4 years, 4 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8StackTraceImpl.h" 5 #include "platform/v8_inspector/V8StackTraceImpl.h"
6 6
7 #include "platform/inspector_protocol/Platform.h" 7 #include "platform/inspector_protocol/Platform.h"
8 #include "platform/inspector_protocol/String16.h" 8 #include "platform/inspector_protocol/String16.h"
9 #include "platform/v8_inspector/V8DebuggerImpl.h" 9 #include "platform/v8_inspector/V8DebuggerImpl.h"
10 #include "platform/v8_inspector/V8StringUtil.h" 10 #include "platform/v8_inspector/V8StringUtil.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 DCHECK(m_frames.size()); 220 DCHECK(m_frames.size());
221 return m_frames[0].m_functionName; 221 return m_frames[0].m_functionName;
222 } 222 }
223 223
224 String16 V8StackTraceImpl::topScriptId() const 224 String16 V8StackTraceImpl::topScriptId() const
225 { 225 {
226 DCHECK(m_frames.size()); 226 DCHECK(m_frames.size());
227 return m_frames[0].m_scriptId; 227 return m_frames[0].m_scriptId;
228 } 228 }
229 229
230 std::unique_ptr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorO bject() const 230 std::unique_ptr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorO bjectImpl() const
231 { 231 {
232 std::unique_ptr<protocol::Array<protocol::Runtime::CallFrame>> frames = prot ocol::Array<protocol::Runtime::CallFrame>::create(); 232 std::unique_ptr<protocol::Array<protocol::Runtime::CallFrame>> frames = prot ocol::Array<protocol::Runtime::CallFrame>::create();
233 for (size_t i = 0; i < m_frames.size(); i++) 233 for (size_t i = 0; i < m_frames.size(); i++)
234 frames->addItem(m_frames.at(i).buildInspectorObject()); 234 frames->addItem(m_frames.at(i).buildInspectorObject());
235 235
236 std::unique_ptr<protocol::Runtime::StackTrace> stackTrace = protocol::Runtim e::StackTrace::create() 236 std::unique_ptr<protocol::Runtime::StackTrace> stackTrace = protocol::Runtim e::StackTrace::create()
237 .setCallFrames(std::move(frames)).build(); 237 .setCallFrames(std::move(frames)).build();
238 if (!m_description.isEmpty()) 238 if (!m_description.isEmpty())
239 stackTrace->setDescription(m_description); 239 stackTrace->setDescription(m_description);
240 if (m_parent) 240 if (m_parent)
241 stackTrace->setParent(m_parent->buildInspectorObject()); 241 stackTrace->setParent(m_parent->buildInspectorObjectImpl());
242 return stackTrace; 242 return stackTrace;
243 } 243 }
244 244
245 std::unique_ptr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorO bjectForTail(V8DebuggerImpl* debugger) const 245 std::unique_ptr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorO bjectForTail(V8DebuggerImpl* debugger) const
246 { 246 {
247 v8::HandleScope handleScope(v8::Isolate::GetCurrent()); 247 v8::HandleScope handleScope(v8::Isolate::GetCurrent());
248 // Next call collapses possible empty stack and ensures maxAsyncCallChainDep th. 248 // Next call collapses possible empty stack and ensures maxAsyncCallChainDep th.
249 std::unique_ptr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create(debug ger, m_contextGroupId, v8::Local<v8::StackTrace>(), V8StackTraceImpl::maxCallSta ckSizeToCapture); 249 std::unique_ptr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create(debug ger, m_contextGroupId, v8::Local<v8::StackTrace>(), V8StackTraceImpl::maxCallSta ckSizeToCapture);
250 if (!fullChain || !fullChain->m_parent) 250 if (!fullChain || !fullChain->m_parent)
251 return nullptr; 251 return nullptr;
252 return fullChain->m_parent->buildInspectorObject(); 252 return fullChain->m_parent->buildInspectorObjectImpl();
253 }
254
255 std::unique_ptr<protocol::Runtime::API::StackTrace> V8StackTraceImpl::buildInspe ctorObject() const
256 {
257 return buildInspectorObjectImpl();
253 } 258 }
254 259
255 String16 V8StackTraceImpl::toString() const 260 String16 V8StackTraceImpl::toString() const
256 { 261 {
257 String16Builder stackTrace; 262 String16Builder stackTrace;
258 for (size_t i = 0; i < m_frames.size(); ++i) { 263 for (size_t i = 0; i < m_frames.size(); ++i) {
259 const Frame& frame = m_frames[i]; 264 const Frame& frame = m_frames[i];
260 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)")); 265 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)"));
261 stackTrace.append(" ("); 266 stackTrace.append(" (");
262 stackTrace.append(frame.sourceURL()); 267 stackTrace.append(frame.sourceURL());
263 stackTrace.append(':'); 268 stackTrace.append(':');
264 stackTrace.appendNumber(frame.lineNumber()); 269 stackTrace.appendNumber(frame.lineNumber());
265 stackTrace.append(':'); 270 stackTrace.append(':');
266 stackTrace.appendNumber(frame.columnNumber()); 271 stackTrace.appendNumber(frame.columnNumber());
267 stackTrace.append(')'); 272 stackTrace.append(')');
268 } 273 }
269 return stackTrace.toString(); 274 return stackTrace.toString();
270 } 275 }
271 276
272 } // namespace blink 277 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698