Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: headless/public/internal/value_conversions.h

Issue 2255133002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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_
OLDNEW
« no previous file with comments | « headless/lib/headless_browser_context_browsertest.cc ('k') | headless/test/headless_browser_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698