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

Side by Side Diff: third_party/WebKit/Source/platform/inspector_protocol/ErrorSupport.cpp

Issue 1767883002: DevTools: generate string16-based handlers for v8_inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing 2 Created 4 years, 9 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/inspector_protocol/ErrorSupport.h" 5 #include "platform/inspector_protocol/ErrorSupport.h"
6 6
7 #include "wtf/text/StringBuilder.h" 7 #include "platform/inspector_protocol/String16.h"
8 8
9 namespace blink { 9 namespace blink {
10 namespace protocol { 10 namespace protocol {
11 11
12 ErrorSupport::ErrorSupport() : m_errorString(nullptr) { } 12 ErrorSupport::ErrorSupport() : m_errorString(nullptr) { }
13 ErrorSupport::ErrorSupport(String* errorString) : m_errorString(errorString) { } 13 ErrorSupport::ErrorSupport(String16* errorString) : m_errorString(errorString) { }
14 ErrorSupport::~ErrorSupport() 14 ErrorSupport::~ErrorSupport()
15 { 15 {
16 if (m_errorString && hasErrors()) 16 if (m_errorString && hasErrors())
17 *m_errorString = "Internal error(s): " + errors(); 17 *m_errorString = "Internal error(s): " + errors();
18 } 18 }
19 19
20 void ErrorSupport::setName(const String& name) 20 void ErrorSupport::setName(const String16& name)
21 { 21 {
22 ASSERT(m_path.size()); 22 ASSERT(m_path.size());
23 m_path[m_path.size() - 1] = name; 23 m_path[m_path.size() - 1] = name;
24 } 24 }
25 25
26 void ErrorSupport::push() 26 void ErrorSupport::push()
27 { 27 {
28 m_path.append(String()); 28 m_path.append(String16());
29 } 29 }
30 30
31 void ErrorSupport::pop() 31 void ErrorSupport::pop()
32 { 32 {
33 m_path.removeLast(); 33 m_path.removeLast();
34 } 34 }
35 35
36 void ErrorSupport::addError(const String& error) 36 void ErrorSupport::addError(const String16& error)
37 { 37 {
38 StringBuilder builder; 38 String16Builder builder;
39 for (size_t i = 0; i < m_path.size(); ++i) { 39 for (size_t i = 0; i < m_path.size(); ++i) {
40 if (i) 40 if (i)
41 builder.append("."); 41 builder.append(".");
42 builder.append(m_path[i]); 42 builder.append(m_path[i]);
43 } 43 }
44 builder.append(": "); 44 builder.append(": ");
45 builder.append(error); 45 builder.append(error);
46 m_errors.append(builder.toString()); 46 m_errors.append(builder.toString());
47 } 47 }
48 48
49 bool ErrorSupport::hasErrors() 49 bool ErrorSupport::hasErrors()
50 { 50 {
51 return m_errors.size(); 51 return m_errors.size();
52 } 52 }
53 53
54 String ErrorSupport::errors() 54 String16 ErrorSupport::errors()
55 { 55 {
56 StringBuilder builder; 56 String16Builder builder;
57 for (size_t i = 0; i < m_errors.size(); ++i) { 57 for (size_t i = 0; i < m_errors.size(); ++i) {
58 if (i) 58 if (i)
59 builder.append("; "); 59 builder.append("; ");
60 builder.append(m_errors[i]); 60 builder.append(m_errors[i]);
61 } 61 }
62 return builder.toString(); 62 return builder.toString();
63 } 63 }
64 64
65 } // namespace protocol 65 } // namespace protocol
66 } // namespace blink 66 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698