OnOptInPreferenceChanged might be called several times.
OOBE show this is reproducible in 100%. We have code OnIsSyncingChanged which is
called when profile is synced. From this callback we call
OnOptInPreferenceChanged. syncing profile is async
method which happens after initializing arc session manager.
So following happens in case OOBE flow:
* Initialize ArcSessionManager::OnPrimary...
* Show Arc OOBE
* Set arc.enabled - OnOptInPreferenceChanged is called.
* ARC OOBE is shown to user.
* Profile is synced, OnIsSyncingChanged called and OnOptInPreferenceChanged is
called from it. This is second call of OnOptInPreferenceChanged and without this
fix we call StartTermsOfServiceNegotiation twice which is wrong.
Non-OOBE case.
1. Initialize ArcSessionManager::OnPrimary...
2. Profile is synced, OnIsSyncingChanged called but OnOptInPreferenceChanged is
not called because arc.enabled is not set.
3. User activates Arc, let say via settings. arc.enabled is set and
OnOptInPreferenceChanged is called and StartTermsOfServiceNegotiation is called
once only.
Next is variation of Non-OOBE case.
2a. User activates Arc before OnIsSyncingChanged. OnOptInPreferenceChanged is
called and we show OptIn.
3a. While Terms are shown profile is actually synced and OnIsSyncingChanged
called. Now we have similar problem with OOBE case.
Last case is quite rare but I personally saw it few times.
Yet one more case when arc.enabled is set to true for arc.enabled managed case. Setting this also calls OnOptInPreferenceChanged
Comment 1 by efoo@chromium.org
, Jul 6