| 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 14 matching lines...) Expand all Loading... |
| 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); |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 // ToValueImpl is a helper used by the ToValue template for dispatching into | 30 // ToValueImpl is a helper used by the ToValue template for dispatching into |
| 31 // type-specific serializers. It uses a dummy |T*| argument as a way to | 31 // type-specific serializers. It uses a dummy |T*| argument as a way to |
| 32 // partially specialize vector types. | 32 // partially specialize vector types. |
| 33 template <typename T> | 33 template <typename T> |
| 34 std::unique_ptr<base::Value> ToValueImpl(int value, T*) { | 34 std::unique_ptr<base::Value> ToValueImpl(int value, T*) { |
| 35 return base::WrapUnique(new base::FundamentalValue(value)); | 35 return base::MakeUnique<base::FundamentalValue>(value); |
| 36 } | 36 } |
| 37 | 37 |
| 38 template <typename T> | 38 template <typename T> |
| 39 std::unique_ptr<base::Value> ToValueImpl(double value, T*) { | 39 std::unique_ptr<base::Value> ToValueImpl(double value, T*) { |
| 40 return base::WrapUnique(new base::FundamentalValue(value)); | 40 return base::MakeUnique<base::FundamentalValue>(value); |
| 41 } | 41 } |
| 42 | 42 |
| 43 template <typename T> | 43 template <typename T> |
| 44 std::unique_ptr<base::Value> ToValueImpl(bool value, T*) { | 44 std::unique_ptr<base::Value> ToValueImpl(bool value, T*) { |
| 45 return base::WrapUnique(new base::FundamentalValue(value)); | 45 return base::MakeUnique<base::FundamentalValue>(value); |
| 46 } | 46 } |
| 47 | 47 |
| 48 template <typename T> | 48 template <typename T> |
| 49 std::unique_ptr<base::Value> ToValueImpl(const std::string& value, T*) { | 49 std::unique_ptr<base::Value> ToValueImpl(const std::string& value, T*) { |
| 50 return base::WrapUnique(new base::StringValue(value)); | 50 return base::MakeUnique<base::StringValue>(value); |
| 51 } | 51 } |
| 52 | 52 |
| 53 template <typename T> | 53 template <typename T> |
| 54 std::unique_ptr<base::Value> ToValueImpl(const base::Value& value, T*) { | 54 std::unique_ptr<base::Value> ToValueImpl(const base::Value& value, T*) { |
| 55 return value.CreateDeepCopy(); | 55 return value.CreateDeepCopy(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 template <typename T> | 58 template <typename T> |
| 59 std::unique_ptr<base::Value> ToValueImpl(const std::vector<T>& vector, | 59 std::unique_ptr<base::Value> ToValueImpl(const std::vector<T>& vector, |
| 60 const std::vector<T>*) { | 60 const std::vector<T>*) { |
| (...skipping 93 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 |