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

Side by Side Diff: components/policy/core/common/schema.cc

Issue 658993002: Convert ARRAYSIZE_UNSAFE -> arraysize in components/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 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 #include "components/policy/core/common/schema.h" 5 #include "components/policy/core/common/schema.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <climits> 8 #include <climits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 base::Value::Type value_type; 69 base::Value::Type value_type;
70 } kSchemaToValueTypeMap[] = { 70 } kSchemaToValueTypeMap[] = {
71 { schema::kArray, base::Value::TYPE_LIST }, 71 { schema::kArray, base::Value::TYPE_LIST },
72 { schema::kBoolean, base::Value::TYPE_BOOLEAN }, 72 { schema::kBoolean, base::Value::TYPE_BOOLEAN },
73 { schema::kInteger, base::Value::TYPE_INTEGER }, 73 { schema::kInteger, base::Value::TYPE_INTEGER },
74 { schema::kNull, base::Value::TYPE_NULL }, 74 { schema::kNull, base::Value::TYPE_NULL },
75 { schema::kNumber, base::Value::TYPE_DOUBLE }, 75 { schema::kNumber, base::Value::TYPE_DOUBLE },
76 { schema::kObject, base::Value::TYPE_DICTIONARY }, 76 { schema::kObject, base::Value::TYPE_DICTIONARY },
77 { schema::kString, base::Value::TYPE_STRING }, 77 { schema::kString, base::Value::TYPE_STRING },
78 }; 78 };
79 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSchemaToValueTypeMap); ++i) { 79 for (size_t i = 0; i < arraysize(kSchemaToValueTypeMap); ++i) {
80 if (kSchemaToValueTypeMap[i].schema_type == type_string) { 80 if (kSchemaToValueTypeMap[i].schema_type == type_string) {
81 *type = kSchemaToValueTypeMap[i].value_type; 81 *type = kSchemaToValueTypeMap[i].value_type;
82 return true; 82 return true;
83 } 83 }
84 } 84 }
85 return false; 85 return false;
86 } 86 }
87 87
88 bool StrategyAllowInvalidOnTopLevel(SchemaOnErrorStrategy strategy) { 88 bool StrategyAllowInvalidOnTopLevel(SchemaOnErrorStrategy strategy) {
89 return strategy == SCHEMA_ALLOW_INVALID || 89 return strategy == SCHEMA_ALLOW_INVALID ||
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 return false; 1099 return false;
1100 } else { 1100 } else {
1101 int index = rnode->string_pattern_restriction.pattern_index; 1101 int index = rnode->string_pattern_restriction.pattern_index;
1102 DCHECK(index == rnode->string_pattern_restriction.pattern_index_backup); 1102 DCHECK(index == rnode->string_pattern_restriction.pattern_index_backup);
1103 re2::RE2* regex = storage_->CompileRegex(*storage_->string_enums(index)); 1103 re2::RE2* regex = storage_->CompileRegex(*storage_->string_enums(index));
1104 return re2::RE2::PartialMatch(str, *regex); 1104 return re2::RE2::PartialMatch(str, *regex);
1105 } 1105 }
1106 } 1106 }
1107 1107
1108 } // namespace policy 1108 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_validator.cc ('k') | components/policy/core/common/schema_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698