1*635a8641SAndroid Build Coastguard Worker// Copyright 2018 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker// Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker// found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Workermodule mojo_base.mojom; 6*635a8641SAndroid Build Coastguard Worker 7*635a8641SAndroid Build Coastguard Worker// Value represents a value that can be serialized to/from JSON. 8*635a8641SAndroid Build Coastguard Worker// 9*635a8641SAndroid Build Coastguard Worker// One notable caveat is that Value supports arbitrary binary data, which JSON 10*635a8641SAndroid Build Coastguard Worker// does not support natively. 11*635a8641SAndroid Build Coastguard Workerunion Value { 12*635a8641SAndroid Build Coastguard Worker // Null type placeholder. This field is never used. 13*635a8641SAndroid Build Coastguard Worker uint8 null_value; 14*635a8641SAndroid Build Coastguard Worker // Primitive types. 15*635a8641SAndroid Build Coastguard Worker bool bool_value; 16*635a8641SAndroid Build Coastguard Worker int32 int_value; 17*635a8641SAndroid Build Coastguard Worker double double_value; 18*635a8641SAndroid Build Coastguard Worker // Unicode string. 19*635a8641SAndroid Build Coastguard Worker string string_value; 20*635a8641SAndroid Build Coastguard Worker // Binary blob with arbitrary bytes. Not supported for JSON. 21*635a8641SAndroid Build Coastguard Worker array<uint8> binary_value; 22*635a8641SAndroid Build Coastguard Worker // Basic container support for lists and maps. 23*635a8641SAndroid Build Coastguard Worker DictionaryValue dictionary_value; 24*635a8641SAndroid Build Coastguard Worker ListValue list_value; 25*635a8641SAndroid Build Coastguard Worker}; 26*635a8641SAndroid Build Coastguard Worker 27*635a8641SAndroid Build Coastguard Worker// Interfaces that only want to handle a value of dictionary or list type 28*635a8641SAndroid Build Coastguard Worker// should use base.mojom.DictionaryValue or base.mojom.ListValue in the method 29*635a8641SAndroid Build Coastguard Worker// declaration. Though both of these types are mapped to base::Value in C++, 30*635a8641SAndroid Build Coastguard Worker// the generated deserialization will guarantee that the method is only invoked 31*635a8641SAndroid Build Coastguard Worker// with a base::Value of the correct subtype. 32*635a8641SAndroid Build Coastguard Workerstruct DictionaryValue { 33*635a8641SAndroid Build Coastguard Worker map<string, Value> storage; 34*635a8641SAndroid Build Coastguard Worker}; 35*635a8641SAndroid Build Coastguard Worker 36*635a8641SAndroid Build Coastguard Workerstruct ListValue { 37*635a8641SAndroid Build Coastguard Worker array<Value> storage; 38*635a8641SAndroid Build Coastguard Worker}; 39