DeviceSyncClient::SetSoftwareFeatureState() provides a way to toggle a feature on/off. However, its success/failure callback returns as soon as the call completes. This leaves us vulnerable to the following situation:
(1) DeviceSyncClient::SoftwareFeatureState() called to turn on feature A for device A.
(2) Call returns from Mojo service.
(3) Call returns to the client of DeviceSyncClient.
(4) Client calls GetSyncedDevices() and gets back a list of devices. In that list, device A does *NOT* have feature A enabled.
(5) Mojo service notifies DeviceSyncClient of synced devices.
(6) DeviceSyncClient updates its list of synced devices.
After step 4, the "new devices synced" callback will occur, but by that point, it may be too late. The client may have already synchronously accessed the synced devices during the small window where they were out of sync.
To correct this issue, we should wait until the success callback comes back from the Mojo service, then wait until the new synced devices list comes in, then invoke the original client's callback. We should also introduce a timeout here so that if there is some error in the service (i.e., Mojo service says that the original request was successful but a new sync never occurs), we do not tell the original client that the call was successful.
Comment 1 by khorimoto@chromium.org
, Aug 1