blob: 31a6e0fff499f9e9bab31329ba5daa14c4bd8395 [file] [log] [blame] [edit]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module mojo_base.mojom;
// Value represents a value that can be serialized to/from JSON.
//
// One notable caveat is that Value supports arbitrary binary data, which JSON
// does not support natively.
union Value {
// Null type placeholder. This field is never used.
uint8 null_value;
// Primitive types.
bool bool_value;
int32 int_value;
double double_value;
// Unicode string.
string string_value;
// Binary blob with arbitrary bytes. Not supported for JSON.
array<uint8> binary_value;
// Basic container support for lists and maps.
DictionaryValue dictionary_value;
ListValue list_value;
};
// Interfaces that only want to handle a value of dictionary or list type
// should use base.mojom.DictionaryValue or base.mojom.ListValue in the method
// declaration. Currently, both of these are typemapped to base::Value, though
// once all existing usage is swapped over to the deprecated versions below,
// the typemap will be updated to deserialize as a base::Value::Dict and
// base::Value::List respectively instead.
struct DictionaryValue {
map<string, Value> storage;
};
struct ListValue {
array<Value> storage;
};
// Legacy versions of the above dictionary and list value types. Both are
// unconditionally typemapped to base::Value. Though the typemap ensures that
// the deserialized base::Value has a matching subtype, use of these will be
// removed in the future due to lack of type safety.
struct DeprecatedDictionaryValue {
map<string, Value> storage;
};
struct DeprecatedListValue {
array<Value> storage;
};