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

Side by Side Diff: components/ui_devtools/string_util.h

Issue 2846113002: Roll third_party/inspector_protocol to efefa86c3183d307f0a0e53bf568fe57c5b58849 (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | content/browser/devtools/protocol_string.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ 5 #ifndef COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_
6 #define COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ 6 #define COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 27 matching lines...) Expand all
38 38
39 class StringUtil { 39 class StringUtil {
40 public: 40 public:
41 static String substring(const String& s, unsigned pos, unsigned len) { 41 static String substring(const String& s, unsigned pos, unsigned len) {
42 return s.substr(pos, len); 42 return s.substr(pos, len);
43 } 43 }
44 static String fromInteger(int number) { return base::IntToString(number); } 44 static String fromInteger(int number) { return base::IntToString(number); }
45 static String fromDouble(double number) { 45 static String fromDouble(double number) {
46 return base::DoubleToString(number); 46 return base::DoubleToString(number);
47 } 47 }
48 static double toDouble(const char* s, size_t len, bool* ok) {
49 double v = 0.0;
50 *ok = base::StringToDouble(std::string(s, len), &v);
51 if (!*ok)
52 v = 0.0;
dgozman 2017/04/27 23:06:31 nit: return *ok ? v : 0.0;
kozy 2017/04/28 00:16:45 Done.
53 return v;
54 }
48 static void builderAppend(StringBuilder& builder, const String& s) { 55 static void builderAppend(StringBuilder& builder, const String& s) {
49 builder.append(s); 56 builder.append(s);
50 } 57 }
51 static void builderAppend(StringBuilder& builder, char c) { 58 static void builderAppend(StringBuilder& builder, char c) {
52 builder.append(c); 59 builder.append(c);
53 } 60 }
54 static void builderAppend(StringBuilder& builder, const char* s, size_t len) { 61 static void builderAppend(StringBuilder& builder, const char* s, size_t len) {
55 builder.append(s, len); 62 builder.append(s, len);
56 } 63 }
57 static void builderReserve(StringBuilder& builder, unsigned capacity) { 64 static void builderReserve(StringBuilder& builder, unsigned capacity) {
(...skipping 10 matching lines...) Expand all
68 } 75 }
69 static const size_t kNotFound = static_cast<size_t>(-1); 76 static const size_t kNotFound = static_cast<size_t>(-1);
70 static std::unique_ptr<Value> parseJSON(const String& string); 77 static std::unique_ptr<Value> parseJSON(const String& string);
71 }; 78 };
72 79
73 } // namespace protocol 80 } // namespace protocol
74 } // namespace devtools 81 } // namespace devtools
75 } // namespace ui 82 } // namespace ui
76 83
77 #endif // COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_ 84 #endif // COMPONENTS_UI_DEVTOOLS_STRING_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/devtools/protocol_string.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698