| 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 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 | 15 |
| 16 namespace base { |
| 17 class Value; |
| 18 } |
| 19 |
| 16 namespace content { | 20 namespace content { |
| 17 namespace protocol { | 21 namespace protocol { |
| 18 | 22 |
| 19 class Value; | 23 class Value; |
| 20 | 24 |
| 21 using String = std::string; | 25 using String = std::string; |
| 22 | 26 |
| 23 class CONTENT_EXPORT StringBuilder { | 27 class CONTENT_EXPORT StringBuilder { |
| 24 public: | 28 public: |
| 25 StringBuilder(); | 29 StringBuilder(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 | 40 |
| 37 class CONTENT_EXPORT StringUtil { | 41 class CONTENT_EXPORT StringUtil { |
| 38 public: | 42 public: |
| 39 static String substring(const String& s, unsigned pos, unsigned len) { | 43 static String substring(const String& s, unsigned pos, unsigned len) { |
| 40 return s.substr(pos, len); | 44 return s.substr(pos, len); |
| 41 } | 45 } |
| 42 static String fromInteger(int number) { | 46 static String fromInteger(int number) { |
| 43 return base::IntToString(number); | 47 return base::IntToString(number); |
| 44 } | 48 } |
| 45 static String fromDouble(double number) { | 49 static String fromDouble(double number) { |
| 46 return base::DoubleToString(number); | 50 String s = base::DoubleToString(number); |
| 51 if (!s.empty() && s[0] == '.') |
| 52 s = "0" + s; |
| 53 return s; |
| 47 } | 54 } |
| 48 static const size_t kNotFound = static_cast<size_t>(-1); | 55 static const size_t kNotFound = static_cast<size_t>(-1); |
| 49 static void builderReserve(StringBuilder& builder, unsigned capacity) { | 56 static void builderReserve(StringBuilder& builder, unsigned capacity) { |
| 50 builder.reserveCapacity(capacity); | 57 builder.reserveCapacity(capacity); |
| 51 } | 58 } |
| 52 static std::unique_ptr<protocol::Value> parseJSON(const String&); | 59 static std::unique_ptr<protocol::Value> parseJSON(const String&); |
| 53 }; | 60 }; |
| 54 | 61 |
| 62 std::unique_ptr<protocol::Value> toProtocolValue( |
| 63 const base::Value* value, int depth); |
| 64 std::unique_ptr<base::Value> toBaseValue(protocol::Value* value, int depth); |
| 65 |
| 55 } // namespace protocol | 66 } // namespace protocol |
| 56 } // namespace content | 67 } // namespace content |
| 57 | 68 |
| 58 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H | 69 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_STRING_H |
| OLD | NEW |