[Extension SW] Fix a race in EventAckData
When EventAckData sees an event dispatch in IncrementInflightEvent on
UI [1] thread, it hops to IO thread to start the associated worker
and then returns to UI[2] to *record* that the event needs an ack from
the renderer process. Event ACKs arriving between UI[1] and
UI[2] would incorrectly fail to find the associated data in the
*record*. This results in bad message termination.
Move the data to IO thread instead, where both IncrementInflightEvent
and DecrementInflightEvent can access the unacked event data. Note
that both IncrementInflightEvent/DecrementInflightEvent has to pass
through IO thread anyway to access ServiceWorkerContext. The new
inner class IOEventData inside EventAckData contains the map for unacked
events.
This also fixes and enables an existing test's flakiness:
FilteredEventsAfterRestart.
Bug: 844821
Change-Id: Ia9df6c896abbae62c9f395f62ef67cab8e1bfb74
Reviewed-on: https://chromium-review.googlesource.com/1228994
Commit-Queue: Istiaque Ahmed <[email protected]>
Reviewed-by: Devlin <[email protected]>
Cr-Commit-Position: refs/heads/master@{#592674}
diff --git a/chrome/browser/extensions/service_worker_apitest.cc b/chrome/browser/extensions/service_worker_apitest.cc
index 0aeac72..5d8265c9 100644
--- a/chrome/browser/extensions/service_worker_apitest.cc
+++ b/chrome/browser/extensions/service_worker_apitest.cc
@@ -1362,9 +1362,8 @@
lazy_observer.Wait();
}
-// Flaky. See https://crbug.com/844821.
IN_PROC_BROWSER_TEST_P(ServiceWorkerLazyBackgroundTest,
- DISABLED_FilteredEventsAfterRestart) {
+ FilteredEventsAfterRestart) {
// Create a tab to a.html, expect it to navigate to b.html. The service worker
// will see two webNavigation.onCommitted events.
ASSERT_TRUE(StartEmbeddedTestServer());