Eliminate DictionaryValue::GetInteger in net/
Bug: 1187034
Change-Id: I1ce3af08e998b640fe6d4c5bf4733f9155dc5382
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3222808
Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Cr-Commit-Position: refs/heads/main@{#933375}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
df4c4fe8f0
commit
0a22563071
net
cert
network_error_logging
reporting
@@ -226,14 +226,11 @@ bool CRLSet::Parse(base::StringPiece data, scoped_refptr<CRLSet>* out_crl_set) {
|
|||||||
if (contents != "CRLSet")
|
if (contents != "CRLSet")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int version;
|
if (header_dict->FindIntKey("Version") != kCurrentFileVersion)
|
||||||
if (!header_dict->GetInteger("Version", &version) ||
|
|
||||||
version != kCurrentFileVersion) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
int sequence;
|
absl::optional<int> sequence = header_dict->FindIntKey("Sequence");
|
||||||
if (!header_dict->GetInteger("Sequence", &sequence))
|
if (!sequence)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// NotAfter is optional for now.
|
// NotAfter is optional for now.
|
||||||
@@ -242,7 +239,7 @@ bool CRLSet::Parse(base::StringPiece data, scoped_refptr<CRLSet>* out_crl_set) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
scoped_refptr<CRLSet> crl_set(new CRLSet());
|
scoped_refptr<CRLSet> crl_set(new CRLSet());
|
||||||
crl_set->sequence_ = static_cast<uint32_t>(sequence);
|
crl_set->sequence_ = static_cast<uint32_t>(*sequence);
|
||||||
crl_set->not_after_ = static_cast<uint64_t>(not_after);
|
crl_set->not_after_ = static_cast<uint64_t>(not_after);
|
||||||
crl_set->crls_.reserve(64); // Value observed experimentally.
|
crl_set->crls_.reserve(64); // Value observed experimentally.
|
||||||
|
|
||||||
|
@@ -220,8 +220,8 @@ void ExpectDictDoubleValue(double expected_value,
|
|||||||
const base::DictionaryValue& value,
|
const base::DictionaryValue& value,
|
||||||
const std::string& key) {
|
const std::string& key) {
|
||||||
absl::optional<double> double_value = value.FindDoubleKey(key);
|
absl::optional<double> double_value = value.FindDoubleKey(key);
|
||||||
EXPECT_TRUE(double_value.has_value()) << key;
|
ASSERT_TRUE(double_value) << key;
|
||||||
EXPECT_DOUBLE_EQ(expected_value, double_value.value_or(0.0)) << key;
|
EXPECT_DOUBLE_EQ(expected_value, *double_value) << key;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(NetworkErrorLoggingServiceTest, CreateService) {
|
TEST_P(NetworkErrorLoggingServiceTest, CreateService) {
|
||||||
|
@@ -92,15 +92,21 @@ bool ProcessEndpoint(ReportingDelegate* delegate,
|
|||||||
endpoint_info_out->url = std::move(endpoint_url);
|
endpoint_info_out->url = std::move(endpoint_url);
|
||||||
|
|
||||||
int priority = ReportingEndpoint::EndpointInfo::kDefaultPriority;
|
int priority = ReportingEndpoint::EndpointInfo::kDefaultPriority;
|
||||||
if (dict->HasKey(kPriorityKey) && !dict->GetInteger(kPriorityKey, &priority))
|
if (const base::Value* value = dict->FindKey(kPriorityKey)) {
|
||||||
return false;
|
if (!value->is_int())
|
||||||
|
return false;
|
||||||
|
priority = value->GetInt();
|
||||||
|
}
|
||||||
if (priority < 0)
|
if (priority < 0)
|
||||||
return false;
|
return false;
|
||||||
endpoint_info_out->priority = priority;
|
endpoint_info_out->priority = priority;
|
||||||
|
|
||||||
int weight = ReportingEndpoint::EndpointInfo::kDefaultWeight;
|
int weight = ReportingEndpoint::EndpointInfo::kDefaultWeight;
|
||||||
if (dict->HasKey(kWeightKey) && !dict->GetInteger(kWeightKey, &weight))
|
if (const base::Value* value = dict->FindKey(kWeightKey)) {
|
||||||
return false;
|
if (!value->is_int())
|
||||||
|
return false;
|
||||||
|
weight = value->GetInt();
|
||||||
|
}
|
||||||
if (weight < 0)
|
if (weight < 0)
|
||||||
return false;
|
return false;
|
||||||
endpoint_info_out->weight = weight;
|
endpoint_info_out->weight = weight;
|
||||||
@@ -133,11 +139,7 @@ bool ProcessEndpointGroup(ReportingDelegate* delegate,
|
|||||||
group_name);
|
group_name);
|
||||||
parsed_endpoint_group_out->group_key = group_key;
|
parsed_endpoint_group_out->group_key = group_key;
|
||||||
|
|
||||||
int ttl_sec = -1;
|
int ttl_sec = dict->FindIntKey(kMaxAgeKey).value_or(-1);
|
||||||
if (!dict->HasKey(kMaxAgeKey))
|
|
||||||
return false;
|
|
||||||
if (!dict->GetInteger(kMaxAgeKey, &ttl_sec))
|
|
||||||
return false;
|
|
||||||
if (ttl_sec < 0)
|
if (ttl_sec < 0)
|
||||||
return false;
|
return false;
|
||||||
// max_age: 0 signifies removal of the endpoint group.
|
// max_age: 0 signifies removal of the endpoint group.
|
||||||
|
Reference in New Issue
Block a user