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 HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_ | 5 #ifndef HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_ |
6 #define HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_ | 6 #define HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 struct FromValue<std::vector<T>> { | 144 struct FromValue<std::vector<T>> { |
145 static std::vector<T> Parse(const base::Value& value, ErrorReporter* errors) { | 145 static std::vector<T> Parse(const base::Value& value, ErrorReporter* errors) { |
146 std::vector<T> result; | 146 std::vector<T> result; |
147 const base::ListValue* list; | 147 const base::ListValue* list; |
148 if (!value.GetAsList(&list)) { | 148 if (!value.GetAsList(&list)) { |
149 errors->AddError("list value expected"); | 149 errors->AddError("list value expected"); |
150 return result; | 150 return result; |
151 } | 151 } |
152 errors->Push(); | 152 errors->Push(); |
153 for (const auto& item : *list) | 153 for (const auto& item : *list) |
154 result.push_back(FromValue<T>::Parse(*item, errors)); | 154 result.push_back(FromValue<T>::Parse(item, errors)); |
155 errors->Pop(); | 155 errors->Pop(); |
156 return result; | 156 return result; |
157 } | 157 } |
158 }; | 158 }; |
159 | 159 |
160 } // namespace internal | 160 } // namespace internal |
161 } // namespace headless | 161 } // namespace headless |
162 | 162 |
163 #endif // HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_ | 163 #endif // HEADLESS_PUBLIC_INTERNAL_VALUE_CONVERSIONS_H_ |
OLD | NEW |