| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_ |
| 6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_ |
| 7 | 7 |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "components/policy/policy_export.h" | 9 #include "components/policy/policy_export.h" |
| 10 | 10 |
| 11 namespace policy { | 11 namespace policy { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 // These types are used internally by the SchemaOwner parser, and by the | 14 // These types are used internally by the SchemaOwner parser, and by the |
| 15 // compile-time code generator. They shouldn't be used directly. | 15 // compile-time code generator. They shouldn't be used directly. |
| 16 | 16 |
| 17 // Represents the type of one policy, or an item of a list policy, or a |
| 18 // property of a map policy. |
| 17 struct POLICY_EXPORT SchemaNode { | 19 struct POLICY_EXPORT SchemaNode { |
| 20 // The policy type. |
| 18 base::Value::Type type; | 21 base::Value::Type type; |
| 19 | 22 |
| 20 // If |type| is TYPE_LIST then this is a SchemaNode* describing the | 23 // If |type| is TYPE_DICTIONARY then |extra| is an offset into |
| 21 // element type. | 24 // SchemaData::properties_nodes that indexes the PropertiesNode describing |
| 25 // the entries of this dictionary. |
| 22 // | 26 // |
| 23 // If |type| is TYPE_DICTIONARY then this is a PropertiesNode* that can | 27 // If |type| is TYPE_LIST then |extra| is an offset into |
| 24 // contain any number of named properties and optionally a SchemaNode* for | 28 // SchemaData::schema_nodes that indexes the SchemaNode describing the items |
| 25 // additional properties. | 29 // of this list. |
| 26 // | 30 // |
| 27 // This is NULL if |type| has any other values. | 31 // Otherwise extra is -1 and is invalid. |
| 28 const void* extra; | 32 int extra; |
| 29 }; | 33 }; |
| 30 | 34 |
| 35 // Represents an entry of a map policy. |
| 31 struct POLICY_EXPORT PropertyNode { | 36 struct POLICY_EXPORT PropertyNode { |
| 37 // The entry key. |
| 32 const char* key; | 38 const char* key; |
| 33 const SchemaNode* schema; | 39 |
| 40 // An offset into SchemaData::schema_nodes that indexes the SchemaNode |
| 41 // describing the structure of this key. |
| 42 int schema; |
| 34 }; | 43 }; |
| 35 | 44 |
| 45 // Represents the list of keys of a map policy. |
| 36 struct POLICY_EXPORT PropertiesNode { | 46 struct POLICY_EXPORT PropertiesNode { |
| 37 const PropertyNode* begin; | 47 // An offset into SchemaData::property_nodes that indexes the PropertyNode |
| 38 const PropertyNode* end; | 48 // describing the first known property of this map policy. |
| 39 const SchemaNode* additional; | 49 int begin; |
| 50 |
| 51 // An offset into SchemaData::property_nodes that indexes the PropertyNode |
| 52 // right beyond the last known property of this map policy. |
| 53 // |
| 54 // If |begin == end| then the map policy that this PropertiesNode corresponds |
| 55 // to does not have known properties. |
| 56 // |
| 57 // Note that the range [begin, end) is sorted by PropertyNode::key, so that |
| 58 // properties can be looked up by binary searching in the range. |
| 59 int end; |
| 60 |
| 61 // If this map policy supports keys with any value (besides the well-known |
| 62 // values described in the range [begin, end)) then |additional| is an offset |
| 63 // into SchemaData::schema_nodes that indexes the SchemaNode describing the |
| 64 // structure of the values for those keys. Otherwise |additional| is -1 and |
| 65 // is invalid. |
| 66 int additional; |
| 67 }; |
| 68 |
| 69 // Contains arrays of related nodes. All of the offsets in these nodes reference |
| 70 // other nodes in these arrays. |
| 71 struct POLICY_EXPORT SchemaData { |
| 72 const SchemaNode* schema_nodes; |
| 73 const PropertyNode* property_nodes; |
| 74 const PropertiesNode* properties_nodes; |
| 40 }; | 75 }; |
| 41 | 76 |
| 42 } // namespace internal | 77 } // namespace internal |
| 43 } // namespace policy | 78 } // namespace policy |
| 44 | 79 |
| 45 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_ | 80 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_INTERNAL_H_ |
| OLD | NEW |