0

forest: Cache secret key result

Otherwise we will get lots of logs.
"Provided secret key does not match with the expected one."

Test: manual
Bug: none
Change-Id: Id1fcbdffb81391ed6017019c928f46ca1f972e23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5473662
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1290904}
This commit is contained in:
Sammie Quon
2024-04-22 21:43:54 +00:00
committed by Chromium LUCI CQ
parent f19d8b8f64
commit a97c4e80ab

@ -12,6 +12,15 @@
namespace ash {
namespace {
// Caches the result of `switches::IsForestSecretKeyMatched()` which not only
// has to fetch and compare strings, but will log an error everytime if they do
// not match.
std::optional<bool> g_cache_secret_key_matched;
}
bool IsForestFeatureFlagEnabled() {
return base::FeatureList::IsEnabled(features::kForestFeature);
}
@ -32,7 +41,11 @@ bool IsForestFeatureEnabled() {
return true;
}
return switches::IsForestSecretKeyMatched();
if (!g_cache_secret_key_matched) {
g_cache_secret_key_matched = switches::IsForestSecretKeyMatched();
}
return *g_cache_secret_key_matched;
}
} // namespace ash