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

Side by Side Diff: base/values.cc

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase Created 3 years, 8 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
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/values.h" 5 #include "base/values.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 static_cast<const DictionaryValue&>(node)); 69 static_cast<const DictionaryValue&>(node));
70 70
71 default: 71 default:
72 return MakeUnique<Value>(node); 72 return MakeUnique<Value>(node);
73 } 73 }
74 } 74 }
75 75
76 } // namespace 76 } // namespace
77 77
78 // static 78 // static
79 std::unique_ptr<Value> Value::CreateNullValue() {
80 return WrapUnique(new Value(Type::NONE));
81 }
82
83 // static
84 std::unique_ptr<BinaryValue> BinaryValue::CreateWithCopiedBuffer( 79 std::unique_ptr<BinaryValue> BinaryValue::CreateWithCopiedBuffer(
85 const char* buffer, 80 const char* buffer,
86 size_t size) { 81 size_t size) {
87 return MakeUnique<BinaryValue>(std::vector<char>(buffer, buffer + size)); 82 return MakeUnique<BinaryValue>(std::vector<char>(buffer, buffer + size));
88 } 83 }
89 84
90 Value::Value(const Value& that) { 85 Value::Value(const Value& that) {
91 InternalCopyConstructFrom(that); 86 InternalCopyConstructFrom(that);
92 } 87 }
93 88
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 return Set(index, WrapUnique(in_value)); 1079 return Set(index, WrapUnique(in_value));
1085 } 1080 }
1086 1081
1087 bool ListValue::Set(size_t index, std::unique_ptr<Value> in_value) { 1082 bool ListValue::Set(size_t index, std::unique_ptr<Value> in_value) {
1088 if (!in_value) 1083 if (!in_value)
1089 return false; 1084 return false;
1090 1085
1091 if (index >= list_->size()) { 1086 if (index >= list_->size()) {
1092 // Pad out any intermediate indexes with null settings 1087 // Pad out any intermediate indexes with null settings
1093 while (index > list_->size()) 1088 while (index > list_->size())
1094 Append(CreateNullValue()); 1089 Append(MakeUnique<Value>());
1095 Append(std::move(in_value)); 1090 Append(std::move(in_value));
1096 } else { 1091 } else {
1097 // TODO(dcheng): remove this DCHECK once the raw pointer version is removed? 1092 // TODO(dcheng): remove this DCHECK once the raw pointer version is removed?
1098 DCHECK((*list_)[index] != in_value); 1093 DCHECK((*list_)[index] != in_value);
1099 (*list_)[index] = std::move(in_value); 1094 (*list_)[index] = std::move(in_value);
1100 } 1095 }
1101 return true; 1096 return true;
1102 } 1097 }
1103 1098
1104 bool ListValue::Get(size_t index, const Value** out_value) const { 1099 bool ListValue::Get(size_t index, const Value** out_value) const {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1342 } 1337 }
1343 1338
1344 std::ostream& operator<<(std::ostream& out, const Value::Type& type) { 1339 std::ostream& operator<<(std::ostream& out, const Value::Type& type) {
1345 if (static_cast<int>(type) < 0 || 1340 if (static_cast<int>(type) < 0 ||
1346 static_cast<size_t>(type) >= arraysize(kTypeNames)) 1341 static_cast<size_t>(type) >= arraysize(kTypeNames))
1347 return out << "Invalid Type (index = " << static_cast<int>(type) << ")"; 1342 return out << "Invalid Type (index = " << static_cast<int>(type) << ")";
1348 return out << Value::GetTypeName(type); 1343 return out << Value::GetTypeName(type);
1349 } 1344 }
1350 1345
1351 } // namespace base 1346 } // namespace base
OLDNEW
« no previous file with comments | « base/values.h ('k') | base/values_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698