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

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

Issue 2238423002: [DevTools] Generate all files in inspector_protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2240663003
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "platform/inspector_protocol/ErrorSupport.h"
6
7 #include "platform/inspector_protocol/String16.h"
8
9 namespace blink {
10 namespace protocol {
11
12 ErrorSupport::ErrorSupport() : m_errorString(nullptr) { }
13 ErrorSupport::ErrorSupport(String16* errorString) : m_errorString(errorString) { }
14 ErrorSupport::~ErrorSupport()
15 {
16 if (m_errorString && hasErrors()) {
17 String16Builder builder;
18 builder.append("Internal error(s): ");
19 builder.append(errors());
20 *m_errorString = builder.toString();
21 }
22 }
23
24 void ErrorSupport::setName(const String16& name)
25 {
26 DCHECK(m_path.size());
27 m_path[m_path.size() - 1] = name;
28 }
29
30 void ErrorSupport::push()
31 {
32 m_path.push_back(String16());
33 }
34
35 void ErrorSupport::pop()
36 {
37 m_path.pop_back();
38 }
39
40 void ErrorSupport::addError(const String16& error)
41 {
42 String16Builder builder;
43 for (size_t i = 0; i < m_path.size(); ++i) {
44 if (i)
45 builder.append('.');
46 builder.append(m_path[i]);
47 }
48 builder.append(": ");
49 builder.append(error);
50 m_errors.push_back(builder.toString());
51 }
52
53 bool ErrorSupport::hasErrors()
54 {
55 return m_errors.size();
56 }
57
58 String16 ErrorSupport::errors()
59 {
60 String16Builder builder;
61 for (size_t i = 0; i < m_errors.size(); ++i) {
62 if (i)
63 builder.append("; ");
64 builder.append(m_errors[i]);
65 }
66 return builder.toString();
67 }
68
69 } // namespace protocol
70 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698