Commit cf4ce552 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[base] Add usage advice for List and Dictionary Values

This change adds a comment that existing usages of base::ListValue
should be replaced by std::vector<base::Value>.

Bug: 646113
Change-Id: I7f2210f7f68d3bac5aa220041411e37db88ab097
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502021Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821230}
parent 5be9df2e
...@@ -80,6 +80,15 @@ class Value; ...@@ -80,6 +80,15 @@ class Value;
// dict.SetKey("mykey", base::Value(foo)); // dict.SetKey("mykey", base::Value(foo));
// return dict; // return dict;
// } // }
//
// The new design tries to avoid losing type information. Thus when migrating
// off deprecated types, existing usages of base::ListValue should be replaced
// by std::vector<base::Value>.
//
// Furthermore, existing usages of base::DictionaryValue should eventually be
// replaced with base::flat_map<std::string, base::Value>. However, this
// requires breaking changing the mapped type of Value::DictStorage first, and
// thus usages of base::DictionaryValue should be kept for the time being.
class BASE_EXPORT Value { class BASE_EXPORT Value {
public: public:
using BlobStorage = std::vector<uint8_t>; using BlobStorage = std::vector<uint8_t>;
...@@ -769,6 +778,7 @@ class BASE_EXPORT DictionaryValue : public Value { ...@@ -769,6 +778,7 @@ class BASE_EXPORT DictionaryValue : public Value {
}; };
// This type of Value represents a list of other Value values. // This type of Value represents a list of other Value values.
// DEPRECATED: Use std::vector<base::Value> instead.
class BASE_EXPORT ListValue : public Value { class BASE_EXPORT ListValue : public Value {
public: public:
using const_iterator = ListView::const_iterator; using const_iterator = ListView::const_iterator;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment