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:

committed by
Chromium LUCI CQ

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