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 2260233002: [DevTools] Migrate v8_inspector/public from String16 to String{View,Buffer}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: styling Created 4 years, 3 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/v8_inspector/V8Debugger.h" 7 #include "platform/v8_inspector/V8Debugger.h"
8 #include "platform/v8_inspector/V8StringUtil.h" 8 #include "platform/v8_inspector/V8StringUtil.h"
9 9
10 #include <v8-debug.h> 10 #include <v8-debug.h>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 , m_description(description) 178 , m_description(description)
179 , m_parent(std::move(parent)) 179 , m_parent(std::move(parent))
180 { 180 {
181 m_frames.swap(frames); 181 m_frames.swap(frames);
182 } 182 }
183 183
184 V8StackTraceImpl::~V8StackTraceImpl() 184 V8StackTraceImpl::~V8StackTraceImpl()
185 { 185 {
186 } 186 }
187 187
188 String16 V8StackTraceImpl::topSourceURL() const 188 StringView V8StackTraceImpl::topSourceURL() const
189 { 189 {
190 DCHECK(m_frames.size()); 190 DCHECK(m_frames.size());
191 return m_frames[0].m_scriptName; 191 return toStringView(m_frames[0].m_scriptName);
192 } 192 }
193 193
194 int V8StackTraceImpl::topLineNumber() const 194 int V8StackTraceImpl::topLineNumber() const
195 { 195 {
196 DCHECK(m_frames.size()); 196 DCHECK(m_frames.size());
197 return m_frames[0].m_lineNumber; 197 return m_frames[0].m_lineNumber;
198 } 198 }
199 199
200 int V8StackTraceImpl::topColumnNumber() const 200 int V8StackTraceImpl::topColumnNumber() const
201 { 201 {
202 DCHECK(m_frames.size()); 202 DCHECK(m_frames.size());
203 return m_frames[0].m_columnNumber; 203 return m_frames[0].m_columnNumber;
204 } 204 }
205 205
206 String16 V8StackTraceImpl::topFunctionName() const 206 StringView V8StackTraceImpl::topFunctionName() const
207 { 207 {
208 DCHECK(m_frames.size()); 208 DCHECK(m_frames.size());
209 return m_frames[0].m_functionName; 209 return toStringView(m_frames[0].m_functionName);
210 } 210 }
211 211
212 String16 V8StackTraceImpl::topScriptId() const 212 StringView V8StackTraceImpl::topScriptId() const
213 { 213 {
214 DCHECK(m_frames.size()); 214 DCHECK(m_frames.size());
215 return m_frames[0].m_scriptId; 215 return toStringView(m_frames[0].m_scriptId);
216 } 216 }
217 217
218 std::unique_ptr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorO bjectImpl() const 218 std::unique_ptr<protocol::Runtime::StackTrace> V8StackTraceImpl::buildInspectorO bjectImpl() const
219 { 219 {
220 std::unique_ptr<protocol::Array<protocol::Runtime::CallFrame>> frames = prot ocol::Array<protocol::Runtime::CallFrame>::create(); 220 std::unique_ptr<protocol::Array<protocol::Runtime::CallFrame>> frames = prot ocol::Array<protocol::Runtime::CallFrame>::create();
221 for (size_t i = 0; i < m_frames.size(); i++) 221 for (size_t i = 0; i < m_frames.size(); i++)
222 frames->addItem(m_frames.at(i).buildInspectorObject()); 222 frames->addItem(m_frames.at(i).buildInspectorObject());
223 223
224 std::unique_ptr<protocol::Runtime::StackTrace> stackTrace = protocol::Runtim e::StackTrace::create() 224 std::unique_ptr<protocol::Runtime::StackTrace> stackTrace = protocol::Runtim e::StackTrace::create()
225 .setCallFrames(std::move(frames)).build(); 225 .setCallFrames(std::move(frames)).build();
(...skipping 12 matching lines...) Expand all
238 if (!fullChain || !fullChain->m_parent) 238 if (!fullChain || !fullChain->m_parent)
239 return nullptr; 239 return nullptr;
240 return fullChain->m_parent->buildInspectorObjectImpl(); 240 return fullChain->m_parent->buildInspectorObjectImpl();
241 } 241 }
242 242
243 std::unique_ptr<protocol::Runtime::API::StackTrace> V8StackTraceImpl::buildInspe ctorObject() const 243 std::unique_ptr<protocol::Runtime::API::StackTrace> V8StackTraceImpl::buildInspe ctorObject() const
244 { 244 {
245 return buildInspectorObjectImpl(); 245 return buildInspectorObjectImpl();
246 } 246 }
247 247
248 String16 V8StackTraceImpl::toString() const 248 std::unique_ptr<StringBuffer> V8StackTraceImpl::toString() const
249 { 249 {
250 String16Builder stackTrace; 250 String16Builder stackTrace;
251 for (size_t i = 0; i < m_frames.size(); ++i) { 251 for (size_t i = 0; i < m_frames.size(); ++i) {
252 const Frame& frame = m_frames[i]; 252 const Frame& frame = m_frames[i];
253 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)")); 253 stackTrace.append("\n at " + (frame.functionName().length() ? frame.f unctionName() : "(anonymous function)"));
254 stackTrace.append(" ("); 254 stackTrace.append(" (");
255 stackTrace.append(frame.sourceURL()); 255 stackTrace.append(frame.sourceURL());
256 stackTrace.append(':'); 256 stackTrace.append(':');
257 stackTrace.append(String16::fromInteger(frame.lineNumber())); 257 stackTrace.append(String16::fromInteger(frame.lineNumber()));
258 stackTrace.append(':'); 258 stackTrace.append(':');
259 stackTrace.append(String16::fromInteger(frame.columnNumber())); 259 stackTrace.append(String16::fromInteger(frame.columnNumber()));
260 stackTrace.append(')'); 260 stackTrace.append(')');
261 } 261 }
262 return stackTrace.toString(); 262 String16 string = stackTrace.toString();
263 return StringBufferImpl::adopt(string);
263 } 264 }
264 265
265 } // namespace v8_inspector 266 } // namespace v8_inspector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698