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 #include "content/browser/devtools/protocol_string.h" | 5 #include "content/browser/devtools/protocol_string.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "content/browser/devtools/protocol/protocol.h" | 10 #include "content/browser/devtools/protocol/protocol.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return base::WrapUnique(new base::Value(inner)); | 86 return base::WrapUnique(new base::Value(inner)); |
87 } | 87 } |
88 if (value->type() == protocol::Value::TypeDouble) { | 88 if (value->type() == protocol::Value::TypeDouble) { |
89 double inner; | 89 double inner; |
90 value->asDouble(&inner); | 90 value->asDouble(&inner); |
91 return base::WrapUnique(new base::Value(inner)); | 91 return base::WrapUnique(new base::Value(inner)); |
92 } | 92 } |
93 if (value->type() == protocol::Value::TypeString) { | 93 if (value->type() == protocol::Value::TypeString) { |
94 std::string inner; | 94 std::string inner; |
95 value->asString(&inner); | 95 value->asString(&inner); |
96 return base::WrapUnique(new base::StringValue(inner)); | 96 return base::WrapUnique(new base::Value(inner)); |
97 } | 97 } |
98 if (value->type() == protocol::Value::TypeArray) { | 98 if (value->type() == protocol::Value::TypeArray) { |
99 protocol::ListValue* list = protocol::ListValue::cast(value); | 99 protocol::ListValue* list = protocol::ListValue::cast(value); |
100 std::unique_ptr<base::ListValue> result(new base::ListValue()); | 100 std::unique_ptr<base::ListValue> result(new base::ListValue()); |
101 for (size_t i = 0; i < list->size(); i++) { | 101 for (size_t i = 0; i < list->size(); i++) { |
102 std::unique_ptr<base::Value> converted = | 102 std::unique_ptr<base::Value> converted = |
103 toBaseValue(list->at(i), depth - 1); | 103 toBaseValue(list->at(i), depth - 1); |
104 if (converted) | 104 if (converted) |
105 result->Append(std::move(converted)); | 105 result->Append(std::move(converted)); |
106 } | 106 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 std::string StringBuilder::toString() { | 147 std::string StringBuilder::toString() { |
148 return string_; | 148 return string_; |
149 } | 149 } |
150 | 150 |
151 void StringBuilder::reserveCapacity(size_t capacity) { | 151 void StringBuilder::reserveCapacity(size_t capacity) { |
152 string_.reserve(capacity); | 152 string_.reserve(capacity); |
153 } | 153 } |
154 | 154 |
155 } // namespace protocol | 155 } // namespace protocol |
156 } // namespace content | 156 } // namespace content |
OLD | NEW |