| OLD | NEW |
| 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 CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
| 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 static String fromInteger(int number) { | 46 static String fromInteger(int number) { |
| 47 return base::IntToString(number); | 47 return base::IntToString(number); |
| 48 } | 48 } |
| 49 static String fromDouble(double number) { | 49 static String fromDouble(double number) { |
| 50 String s = base::DoubleToString(number); | 50 String s = base::DoubleToString(number); |
| 51 if (!s.empty() && s[0] == '.') | 51 if (!s.empty() && s[0] == '.') |
| 52 s = "0" + s; | 52 s = "0" + s; |
| 53 return s; | 53 return s; |
| 54 } | 54 } |
| 55 static double toDouble(const char* s, size_t len, bool* ok) { |
| 56 double v = 0.0; |
| 57 *ok = base::StringToDouble(std::string(s, len), &v); |
| 58 if (!*ok) |
| 59 v = 0.0; |
| 60 return v; |
| 61 } |
| 55 static size_t find(const String& s, const char* needle) { | 62 static size_t find(const String& s, const char* needle) { |
| 56 return s.find(needle); | 63 return s.find(needle); |
| 57 } | 64 } |
| 58 static size_t find(const String& s, const String& needle) { | 65 static size_t find(const String& s, const String& needle) { |
| 59 return s.find(needle); | 66 return s.find(needle); |
| 60 } | 67 } |
| 61 static const size_t kNotFound = static_cast<size_t>(-1); | 68 static const size_t kNotFound = static_cast<size_t>(-1); |
| 62 static void builderAppend(StringBuilder& builder, const String& s) { | 69 static void builderAppend(StringBuilder& builder, const String& s) { |
| 63 builder.append(s); | 70 builder.append(s); |
| 64 } | 71 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 78 }; | 85 }; |
| 79 | 86 |
| 80 std::unique_ptr<protocol::Value> toProtocolValue( | 87 std::unique_ptr<protocol::Value> toProtocolValue( |
| 81 const base::Value* value, int depth); | 88 const base::Value* value, int depth); |
| 82 std::unique_ptr<base::Value> toBaseValue(protocol::Value* value, int depth); | 89 std::unique_ptr<base::Value> toBaseValue(protocol::Value* value, int depth); |
| 83 | 90 |
| 84 } // namespace protocol | 91 } // namespace protocol |
| 85 } // namespace content | 92 } // namespace content |
| 86 | 93 |
| 87 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H | 94 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
| OLD | NEW |