Reorganize isolated origins into a map indexed by site URLs.
Previously isolated origins were stored in a set. This resulted in
large overheads when URLs needed to be checked against isolated
origins, since the set had to be walked through linearly, running a
fairly slow comparison function
(IsolatedOriginUtil::DoesOriginMatchIsolatedOrigin()) on each isolated
origin, and this lookup turned out to be fairly common.
This CL reorganizes the underlying data structure into a map keyed by
site URLs. For example, if we add {https://foo.com,
https://bar.foo.com, https://www.bar.com} as isolated origins, the map
will look like this:
https://foo.com -> { https://foo.com, https://bar.foo.com }
https://bar.com -> { https://www.bar.com }
When checking a URL against isolated origins, we now can just look up
the map using the URL's site and then look for the most specific
isolated origins as before. The site can be found in O(log n) time,
and the corresponding list of origins to search using
DoesOriginMatchIsolatedOrigin() changes from O(n) to O(originsPerSite),
which is expected to be ~1.
Bug: 877653
Change-Id: I41667f94cea7f1f8e5b53fa23443d83cfbb3c0ed
Reviewed-on: https://chromium-review.googlesource.com/1208942
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by:
Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by:
Charlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590063}
Showing
Please register or sign in to comment