| 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 #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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 sizes.string_enums != storage->string_enums_.size()) { | 323 sizes.string_enums != storage->string_enums_.size()) { |
| 324 *error = "Failed to parse the schema due to a Chrome bug. Please file a " | 324 *error = "Failed to parse the schema due to a Chrome bug. Please file a " |
| 325 "new issue at http://crbug.com"; | 325 "new issue at http://crbug.com"; |
| 326 return NULL; | 326 return NULL; |
| 327 } | 327 } |
| 328 | 328 |
| 329 if (!ResolveReferences(id_map, reference_list, error)) | 329 if (!ResolveReferences(id_map, reference_list, error)) |
| 330 return NULL; | 330 return NULL; |
| 331 | 331 |
| 332 SchemaData* data = &storage->schema_data_; | 332 SchemaData* data = &storage->schema_data_; |
| 333 data->schema_nodes = vector_as_array(&storage->schema_nodes_); | 333 data->schema_nodes = storage->schema_nodes_.data(); |
| 334 data->property_nodes = vector_as_array(&storage->property_nodes_); | 334 data->property_nodes = storage->property_nodes_.data(); |
| 335 data->properties_nodes = vector_as_array(&storage->properties_nodes_); | 335 data->properties_nodes = storage->properties_nodes_.data(); |
| 336 data->restriction_nodes = vector_as_array(&storage->restriction_nodes_); | 336 data->restriction_nodes = storage->restriction_nodes_.data(); |
| 337 data->int_enums = vector_as_array(&storage->int_enums_); | 337 data->int_enums = storage->int_enums_.data(); |
| 338 data->string_enums = vector_as_array(&storage->string_enums_); | 338 data->string_enums = storage->string_enums_.data(); |
| 339 return storage; | 339 return storage; |
| 340 } | 340 } |
| 341 | 341 |
| 342 re2::RE2* Schema::InternalStorage::CompileRegex( | 342 re2::RE2* Schema::InternalStorage::CompileRegex( |
| 343 const std::string& pattern) const { | 343 const std::string& pattern) const { |
| 344 base::ScopedPtrMap<std::string, scoped_ptr<re2::RE2>>::const_iterator it = | 344 base::ScopedPtrMap<std::string, scoped_ptr<re2::RE2>>::const_iterator it = |
| 345 regex_cache_.find(pattern); | 345 regex_cache_.find(pattern); |
| 346 if (it == regex_cache_.end()) { | 346 if (it == regex_cache_.end()) { |
| 347 scoped_ptr<re2::RE2> compiled(new re2::RE2(pattern)); | 347 scoped_ptr<re2::RE2> compiled(new re2::RE2(pattern)); |
| 348 re2::RE2* compiled_ptr = compiled.get(); | 348 re2::RE2* compiled_ptr = compiled.get(); |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 return false; | 1100 return false; |
| 1101 } else { | 1101 } else { |
| 1102 int index = rnode->string_pattern_restriction.pattern_index; | 1102 int index = rnode->string_pattern_restriction.pattern_index; |
| 1103 DCHECK(index == rnode->string_pattern_restriction.pattern_index_backup); | 1103 DCHECK(index == rnode->string_pattern_restriction.pattern_index_backup); |
| 1104 re2::RE2* regex = storage_->CompileRegex(*storage_->string_enums(index)); | 1104 re2::RE2* regex = storage_->CompileRegex(*storage_->string_enums(index)); |
| 1105 return re2::RE2::PartialMatch(str, *regex); | 1105 return re2::RE2::PartialMatch(str, *regex); |
| 1106 } | 1106 } |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 } // namespace policy | 1109 } // namespace policy |
| OLD | NEW |