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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 std::unique_ptr<base::Value> toBaseValue( | 72 std::unique_ptr<base::Value> toBaseValue( |
73 protocol::Value* value, int depth) { | 73 protocol::Value* value, int depth) { |
74 if (!value || !depth) | 74 if (!value || !depth) |
75 return nullptr; | 75 return nullptr; |
76 if (value->type() == protocol::Value::TypeNull) | 76 if (value->type() == protocol::Value::TypeNull) |
77 return base::Value::CreateNullValue(); | 77 return base::Value::CreateNullValue(); |
78 if (value->type() == protocol::Value::TypeBoolean) { | 78 if (value->type() == protocol::Value::TypeBoolean) { |
79 bool inner; | 79 bool inner; |
80 value->asBoolean(&inner); | 80 value->asBoolean(&inner); |
81 return base::WrapUnique(new base::FundamentalValue(inner)); | 81 return base::WrapUnique(new base::Value(inner)); |
82 } | 82 } |
83 if (value->type() == protocol::Value::TypeInteger) { | 83 if (value->type() == protocol::Value::TypeInteger) { |
84 int inner; | 84 int inner; |
85 value->asInteger(&inner); | 85 value->asInteger(&inner); |
86 return base::WrapUnique(new base::FundamentalValue(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::FundamentalValue(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::StringValue(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++) { |
(...skipping 45 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 |