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

Side by Side Diff: mojo/common/values_struct_traits.h

Issue 2839753005: Remove base::Value::GetAsBinary (Closed)
Patch Set: Created 3 years, 7 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 MOJO_COMMON_VALUES_STRUCT_TRAITS_H_ 5 #ifndef MOJO_COMMON_VALUES_STRUCT_TRAITS_H_
6 #define MOJO_COMMON_VALUES_STRUCT_TRAITS_H_ 6 #define MOJO_COMMON_VALUES_STRUCT_TRAITS_H_
7 7
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "mojo/common/values.mojom.h" 9 #include "mojo/common/values.mojom.h"
10 #include "mojo/public/cpp/bindings/array_traits.h" 10 #include "mojo/public/cpp/bindings/array_traits.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 static base::StringPiece string_value(const base::Value& value) { 168 static base::StringPiece string_value(const base::Value& value) {
169 base::StringPiece string_piece; 169 base::StringPiece string_piece;
170 if (!value.GetAsString(&string_piece)) 170 if (!value.GetAsString(&string_piece))
171 NOTREACHED(); 171 NOTREACHED();
172 return string_piece; 172 return string_piece;
173 } 173 }
174 174
175 static mojo::ConstCArray<uint8_t> binary_value(const base::Value& value) { 175 static mojo::ConstCArray<uint8_t> binary_value(const base::Value& value) {
176 const base::Value* binary_value = nullptr; 176 if (!value.is_blob())
jdoerrie 2017/04/25 12:49:16 Technically this if-clause is not required either
Robert Sesek 2017/04/25 14:06:42 I'd keep it given the pattern in the rest of the f
jdoerrie 2017/04/25 14:14:33 Acknowledged.
177 if (!value.GetAsBinary(&binary_value))
178 NOTREACHED(); 177 NOTREACHED();
179 return mojo::ConstCArray<uint8_t>( 178 return mojo::ConstCArray<uint8_t>(
180 binary_value->GetBlob().size(), 179 value.GetBlob().size(),
181 reinterpret_cast<const uint8_t*>(binary_value->GetBlob().data())); 180 reinterpret_cast<const uint8_t*>(value.GetBlob().data()));
182 } 181 }
183 182
184 static const base::ListValue& list_value(const base::Value& value) { 183 static const base::ListValue& list_value(const base::Value& value) {
185 const base::ListValue* list_value = nullptr; 184 const base::ListValue* list_value = nullptr;
186 if (!value.GetAsList(&list_value)) 185 if (!value.GetAsList(&list_value))
187 NOTREACHED(); 186 NOTREACHED();
188 return *list_value; 187 return *list_value;
189 } 188 }
190 static const base::DictionaryValue& dictionary_value( 189 static const base::DictionaryValue& dictionary_value(
191 const base::Value& value) { 190 const base::Value& value) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 base::Value>::dictionary_value(*value); 247 base::Value>::dictionary_value(*value);
249 } 248 }
250 249
251 static bool Read(common::mojom::ValueDataView data, 250 static bool Read(common::mojom::ValueDataView data,
252 std::unique_ptr<base::Value>* value); 251 std::unique_ptr<base::Value>* value);
253 }; 252 };
254 253
255 } // namespace mojo 254 } // namespace mojo
256 255
257 #endif // MOJO_COMMON_VALUES_STRUCT_TRAITS_H_ 256 #endif // MOJO_COMMON_VALUES_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698