Re: [w3c/ServiceWorker] Avoid array manipulation in parallel (#1243)

bzbarsky commented on this pull request.



> +                        1. Add |windowData| to |matchedWindowData|.
+                1. Else if |options|["{{ClientQueryOptions/type}}"] is {{ClientType/"worker"}} or {{ClientType/"all"}} and |client| is a [=dedicated worker client=], or |options|["{{ClientQueryOptions/type}}"] is {{ClientType/"sharedworker"}} or {{ClientType/"all"}} and |client| is a [=shared worker client=], then:
+                    1. Add |client| to |matchedClients|.
+            1. [=Queue a task=] on |promise|'s [=relevant settings object=]'s [=responsible event loop=], using the [=DOM manipulation task source=], to run the following steps:
+                1. Let |clientObjects| be a new [=list=].
+                1. [=list/For each=] |windowData| in |matchedWindowData|:
+                    1. Let |windowClient| be the result of running [=Create Window Client=] algorithm with |windowData|["`client`"], |windowData|["`visibilityState`"], |windowData|["`focusState`"], and |windowData|["`ancestorOriginsList`"] as the arguments.
+                    1. [=Append=] |windowClient| to |clientObjects|.
+                1. [=list/For each=] |client| in |matchedClients|:
+                    1. Let |clientObject| be the result of running [=Create Client=] algorithm with |client| as the argument.
+                    1. [=Append=] |clientObject| to |clientObjects|.
+                1. Sort |matchedClients| such that:
+                    * {{WindowClient}} objects are always placed before {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=].
+                    * {{WindowClient}} objects that have been [=focusing steps|focused=] are placed first sorted in the most recently [=focusing steps|focused=] order, and {{WindowClient}} objects that have never been [=focusing steps|focused=] are placed next sorted in their [=Client/service worker clients=]' creation order.
+                    * {{Client}} objects whose associated [=Client/service worker clients=] are [=worker clients=] are placed next sorted in their [=Client/service worker clients=]' creation order.
+                1. [=Resolve=] |promise| with [=create a frozen array|a new frozen array of=] |clientObjects|.

Which global?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1243#pullrequestreview-81907479

Received on Thursday, 7 December 2017 16:14:40 UTC