diff options
author | jdoerrie <jdoerrie@chromium.org> | 2017-11-22 19:39:32 +0900 |
---|---|---|
committer | Qijiang Fan <fqj@google.com> | 2020-06-05 07:50:49 +0900 |
commit | 9c4a952e6df86d0052bde4c25d7b71cae6e8ae30 (patch) | |
tree | f705c6693bd2884641ee8cf5a630bcb15cf94b07 /components | |
parent | e90fed947cb1cde7bb34f1d5be8c157d6084a707 (diff) | |
download | libchrome-9c4a952e6df86d0052bde4c25d7b71cae6e8ae30.tar.gz |
Remove base::Value::IsType() in //components
This change removes the deprecated base::Value::IsType() in //components
in favor of using is_{none,bool,...}() directly.
Bug: 646113
Change-Id: Id03d55287eefbb262aa19da2a9eea01474901d06
Reviewed-on: https://chromium-review.googlesource.com/781663
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518598}
CrOS-Libchrome-Original-Commit: f39c2a7c033e851ba1ea64f39304c188847dc332
Diffstat (limited to 'components')
-rw-r--r-- | components/json_schema/json_schema_validator.cc | 10 | ||||
-rw-r--r-- | components/json_schema/json_schema_validator_unittest_base.cc | 2 | ||||
-rw-r--r-- | components/policy/core/common/registry_dict.cc | 4 | ||||
-rw-r--r-- | components/policy/core/common/schema.cc | 10 |
4 files changed, 11 insertions, 15 deletions
diff --git a/components/json_schema/json_schema_validator.cc b/components/json_schema/json_schema_validator.cc index 080f4d7372..c5f260fee0 100644 --- a/components/json_schema/json_schema_validator.cc +++ b/components/json_schema/json_schema_validator.cc @@ -172,9 +172,8 @@ bool IsValidSchema(const base::DictionaryValue* dict, } // Integer can be converted to double. - if (!(it.value().IsType(entry->type) || - (it.value().IsType(base::Value::Type::INTEGER) && - entry->type == base::Value::Type::DOUBLE))) { + if (!(it.value().type() == entry->type || + (it.value().is_int() && entry->type == base::Value::Type::DOUBLE))) { *error = base::StringPrintf("Invalid value for %s attribute", it.key().c_str()); return false; @@ -182,7 +181,7 @@ bool IsValidSchema(const base::DictionaryValue* dict, // base::Value::Type::INTEGER attributes must be >= 0. // This applies to "minItems", "maxItems", "minLength" and "maxLength". - if (it.value().IsType(base::Value::Type::INTEGER)) { + if (it.value().is_int()) { int integer_value; it.value().GetAsInteger(&integer_value); if (integer_value < 0) { @@ -563,8 +562,7 @@ void JSONSchemaValidator::ValidateEnum(const base::Value* instance, case base::Value::Type::INTEGER: case base::Value::Type::DOUBLE: - if (instance->IsType(base::Value::Type::INTEGER) || - instance->IsType(base::Value::Type::DOUBLE)) { + if (instance->is_int() || instance->is_double()) { if (GetNumberValue(choice) == GetNumberValue(instance)) return; } diff --git a/components/json_schema/json_schema_validator_unittest_base.cc b/components/json_schema/json_schema_validator_unittest_base.cc index 15e6f76848..a4097bf82a 100644 --- a/components/json_schema/json_schema_validator_unittest_base.cc +++ b/components/json_schema/json_schema_validator_unittest_base.cc @@ -49,7 +49,7 @@ base::Value* LoadValue(const std::string& filename, base::Value::Type type) { std::unique_ptr<base::Value> result(LoadValue(filename)); if (!result.get()) return nullptr; - if (!result->IsType(type)) { + if (result->type() != type) { ADD_FAILURE() << "Expected type " << type << ", got: " << result->type(); return nullptr; } diff --git a/components/policy/core/common/registry_dict.cc b/components/policy/core/common/registry_dict.cc index f591cb6a49..d2b1d6c926 100644 --- a/components/policy/core/common/registry_dict.cc +++ b/components/policy/core/common/registry_dict.cc @@ -42,7 +42,7 @@ std::unique_ptr<base::Value> ConvertValue(const base::Value& value, return value.CreateDeepCopy(); // If the type is good already, go with it. - if (value.IsType(schema.type())) { + if (value.type() == schema.type()) { // Recurse for complex types. const base::DictionaryValue* dict = nullptr; const base::ListValue* list = nullptr; @@ -129,7 +129,7 @@ std::unique_ptr<base::Value> ConvertValue(const base::Value& value, if (value.GetAsString(&string_value)) { std::unique_ptr<base::Value> result = base::JSONReader::Read(string_value); - if (result && result->IsType(schema.type())) + if (result && result->type() == schema.type()) return result; } break; diff --git a/components/policy/core/common/schema.cc b/components/policy/core/common/schema.cc index 4cd6ed61c1..3f2e27e238 100644 --- a/components/policy/core/common/schema.cc +++ b/components/policy/core/common/schema.cc @@ -782,11 +782,10 @@ bool Schema::Validate(const base::Value& value, return false; } - if (!value.IsType(type())) { + if (value.type() != type()) { // Allow the integer to double promotion. Note that range restriction on // double is not supported now. - if (value.IsType(base::Value::Type::INTEGER) && - type() == base::Value::Type::DOUBLE) { + if (value.is_int() && type() == base::Value::Type::DOUBLE) { return true; } @@ -861,11 +860,10 @@ bool Schema::Normalize(base::Value* value, return false; } - if (!value->IsType(type())) { + if (value->type() != type()) { // Allow the integer to double promotion. Note that range restriction on // double is not supported now. - if (value->IsType(base::Value::Type::INTEGER) && - type() == base::Value::Type::DOUBLE) { + if (value->is_int() && type() == base::Value::Type::DOUBLE) { return true; } |