Commit fc99e404 authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[BackgroundSync] Check for connectivity before creating ready list.

When BackgroundSyncManager is notified of a change in network
connectivity, we immediately proceed to calculate two lists of one-shot
and periodic Background Sync registrations that we're ready to fire events for.

For each registration, we individually check whether there is connectivity.
This is wasteful. This CL adds a check before calling FireReadyEvents() and bails out
if there is no connectivity.

Bug: 574478
Change-Id: Iaf1bfe8552edbfbfbef8e6d8ffb0ab1acacaf341
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816569
Auto-Submit: Mugdha Lakhani <nator@chromium.org>
Reviewed-by: default avatarRayan Kanso <rayankans@chromium.org>
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699298}
parent 69c469cb
...@@ -2331,6 +2331,9 @@ void BackgroundSyncManager::OnStorageWipedImpl(base::OnceClosure callback) { ...@@ -2331,6 +2331,9 @@ void BackgroundSyncManager::OnStorageWipedImpl(base::OnceClosure callback) {
void BackgroundSyncManager::OnNetworkChanged() { void BackgroundSyncManager::OnNetworkChanged() {
DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId()); DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId());
if (!AreOptionConditionsMet())
return;
FireReadyEvents(BackgroundSyncType::ONE_SHOT, /* reschedule= */ true, FireReadyEvents(BackgroundSyncType::ONE_SHOT, /* reschedule= */ true,
base::DoNothing::Once()); base::DoNothing::Once());
FireReadyEvents(BackgroundSyncType::PERIODIC, /* reschedule= */ true, FireReadyEvents(BackgroundSyncType::PERIODIC, /* reschedule= */ true,
......
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