Push API: Don't wait for network when unsubscribing
pushSubscription.unsubscribe() used to delete local state then hang for
up to 10 minutes until we managed to tell GCM servers about the
unsubscription (the 10 minutes is due to exponential backoff retries on
desktop, if the device is offline or on a flaky connection).
So unsubscribing offline would never resolve the Promise if the
tab/Service Worker was closed before 10 minutes, as is common, however
the unsubscription would in fact have succeeded to the extent that
subscribe()/getSubscription() correctly appear unsubscribed, and
messages are no longer be delivered.
This patch resolves the unsubscribe() promise as soon as the local state
has been deleted, without waiting for network requests to GCM servers.
Since we no longer use the results of those network requests directly,
UMA logging is added to track them.
To allow testing offline behavior, FakeGCMProfileService can now provide
a coarse simulation of being offline, and I refactored it a little to
simplify things.
BUG=669095,448500
Review-Url: https://codereview.chromium.org/2675293003
Cr-Commit-Position: refs/heads/master@{#449343}
9 files changed