Commit 5f8498df authored by Felipe Andrade's avatar Felipe Andrade Committed by Commit Bot

Fix Kerberos accounts changes notification

Kerberos credentials manager should notify observers if at least one of the
account addition succeed. Howerver, there should be at most one notification
for a given list of accounts added. This CL adds a flag to manage this
notifications.

Change-Id: I6f40ed930dd98e9f760a9de9869452d94cec4295
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1871881
Commit-Queue: Felipe Andrade <fsandrade@chromium.org>
Reviewed-by: default avatarLutz Justen <ljusten@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708203}
parent d7c23e0c
...@@ -468,10 +468,15 @@ void KerberosCredentialsManager::OnAddAccountRunnerDone( ...@@ -468,10 +468,15 @@ void KerberosCredentialsManager::OnAddAccountRunnerDone(
else if (GetActivePrincipalName() == updated_principal) else if (GetActivePrincipalName() == updated_principal)
GetKerberosFiles(); GetKerberosFiles();
// Bring the merry news to the observers, but only if there is no // Observers should be notified if at least one of the additions succeed.
// outstanding query, so we don't spam observers. should_notify_accounts_changes_ = true;
if (add_account_runners_.empty()) }
NotifyAccountsChanged();
// Bring the merry news to the observers, but only if there is no outstanding
// query, so we don't spam observers.
if (add_account_runners_.empty() && should_notify_accounts_changes_) {
should_notify_accounts_changes_ = false;
NotifyAccountsChanged();
} }
std::move(callback).Run(error); std::move(callback).Run(error);
......
...@@ -257,6 +257,9 @@ class KerberosCredentialsManager : public policy::PolicyService::Observer { ...@@ -257,6 +257,9 @@ class KerberosCredentialsManager : public policy::PolicyService::Observer {
// Keeps track of accounts currently being added. // Keeps track of accounts currently being added.
std::vector<std::unique_ptr<KerberosAddAccountRunner>> add_account_runners_; std::vector<std::unique_ptr<KerberosAddAccountRunner>> add_account_runners_;
// Will be true if one of the current account additions succeed.
bool should_notify_accounts_changes_ = false;
// Variable expander for the principal name (replaces ${LOGIN_ID} etc.). // Variable expander for the principal name (replaces ${LOGIN_ID} etc.).
std::unique_ptr<VariableExpander> principal_expander_; std::unique_ptr<VariableExpander> principal_expander_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment