0

Migrate to new StatisticsProvider API.

Use new getters introduced in crrev.com/c/3963072. The new getters
return optional string piece instead of returning bool and copying
result into string provided as a pointer argument.

Handling optional in callers code makes caller explicitly handle missing
statistic.

Usage of base::StringPiece reduces number of copies for both keys and
returned statistics. Callers have to make an explicit copy if needed.

This CL was uploaded by git cl split.

R=sdefresne@chromium.org

Bug: b:213325251
Test: unit_tests
Test: browser_tests
Change-Id: I731baea102e9d574743500808a63f9317283903a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4031029
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Auto-Submit: Artem Sumaneev <asumaneev@google.com>
Cr-Commit-Position: refs/heads/main@{#1072241}
This commit is contained in:
Artem Sumaneev
2022-11-16 16:00:24 +00:00
committed by Chromium LUCI CQ
parent 6f9bc02df4
commit 096c8881d5

@ -379,9 +379,9 @@ bool RlzValueStoreChromeOS::IsStatefulEvent(Product product,
if (strcmp(event_rlz, "CAF") == 0) {
chromeos::system::StatisticsProvider* stats =
chromeos::system::StatisticsProvider::GetInstance();
std::string should_send_rlz_ping_value;
if (stats->GetMachineStatistic(chromeos::system::kShouldSendRlzPingKey,
&should_send_rlz_ping_value)) {
if (const absl::optional<base::StringPiece> should_send_rlz_ping_value =
stats->GetMachineStatistic(
chromeos::system::kShouldSendRlzPingKey)) {
if (should_send_rlz_ping_value ==
chromeos::system::kShouldSendRlzPingValueFalse) {
return true;
@ -389,7 +389,7 @@ bool RlzValueStoreChromeOS::IsStatefulEvent(Product product,
chromeos::system::kShouldSendRlzPingValueTrue) {
LOG(WARNING) << chromeos::system::kShouldSendRlzPingKey
<< " has an unexpected value: "
<< should_send_rlz_ping_value << ". Treat it as "
<< should_send_rlz_ping_value.value() << ". Treat it as "
<< chromeos::system::kShouldSendRlzPingValueFalse
<< " to avoid sending duplicate rlz ping.";
return true;