| 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" |
| 11 #include "headless/public/util/error_reporter.h" | 11 #include "headless/public/util/error_reporter.h" |
| 12 | 12 |
| 13 namespace headless { | 13 namespace headless { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 // Generic conversion from a type to a base::Value. Implemented in | 16 // Generic conversion from a type to a base::Value. Implemented in |
| 17 // type_conversions.h after all type-specific ToValueImpls have been defined. | 17 // types_DOMAIN.cc after all type-specific ToValueImpls have been defined. |
| 18 template <typename T> | 18 template <typename T> |
| 19 std::unique_ptr<base::Value> ToValue(const T& value); | 19 std::unique_ptr<base::Value> ToValue(const T& value); |
| 20 | 20 |
| 21 // Generic conversion from a base::Value to a type. Note that this generic | 21 // Generic conversion from a base::Value to a type. Note that this generic |
| 22 // variant is never defined. Instead, we declare a specific template | 22 // variant is never defined. Instead, we declare a specific template |
| 23 // specialization for all the used types. | 23 // specialization for all the used types. |
| 24 template <typename T> | 24 template <typename T> |
| 25 struct FromValue { | 25 struct FromValue { |
| 26 static std::unique_ptr<T> Parse(const base::Value& value, | 26 static std::unique_ptr<T> Parse(const base::Value& value, |
| 27 ErrorReporter* errors); | 27 ErrorReporter* errors); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |