Make OriginAgentCluster global walk more efficient for OAC-by-default.
With the advent of OriginAgentCluster(OAC)-by-default, the number of
navigations getting OAC isolation is expected to increase dramatically. Prior to this CL, each time a navigation got OAC (either via header or
OAC-by-default) we had to check if the navigation's origin had ever
been isolated before, and if not do a potentially expensive search of
the frame tree and session history to verify that we hadn't previously
encountered the origin in the current BrowsingInstance.
To avoid OAC-by-default causing a performance regression due to many
additional global walks, this CL refactors the global walk logic so
that it is only invoked when the OAC header is explicitly present,
either for opt-in or opt-out, and not invoked when an origin gets
OAC-by-default. Since the number of sites explicitly opting-out is expected to be small, this should help keep the total number of global walks small.
When OAC-by-default is enabled, we will explicitly track all origins
that have sent the OAC header, along with the requested opt-in or
opt-out state. All untracked origins will be assumed to have the
default OAC-enabled state.
When OAC-by-default is not enabled, we continue to track only origins
that have explicitly requested opt-in via the header.
This CL also renames a number of functions used in the global walk
to make their behavior more easily understood.
More details about the global walk and this refactor/redesign can
be found at
https://docs.google.com/document/d/1zrMXDOXDhp4-qFZvkZkDVSuqsT718Y-kRVRPqestiMY/edit?usp=sharing
Bug: 1259920
Change-Id: I0a31641eebe187f3961ddfcb2a2d1977a7a3f1f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3763843
Reviewed-by: Alex Moshchuk <[email protected]>
Reviewed-by: Charlie Reis <[email protected]>
Commit-Queue: James Maclean <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1027872}
diff --git a/content/browser/renderer_host/frame_tree.cc b/content/browser/renderer_host/frame_tree.cc
index d3a91fd5..d83b0c2 100644
--- a/content/browser/renderer_host/frame_tree.cc
+++ b/content/browser/renderer_host/frame_tree.cc
@@ -712,10 +712,10 @@
}
}
-void FrameTree::RegisterExistingOriginToPreventOptInIsolation(
+void FrameTree::RegisterExistingOriginAsHavingDefaultIsolation(
const url::Origin& previously_visited_origin,
NavigationRequest* navigation_request_to_exclude) {
- controller().RegisterExistingOriginToPreventOptInIsolation(
+ controller().RegisterExistingOriginAsHavingDefaultIsolation(
previously_visited_origin);
std::unordered_set<SiteInstance*> matching_site_instances;
@@ -753,7 +753,7 @@
// Update any SiteInstances found to contain |origin|.
for (auto* site_instance : matching_site_instances) {
static_cast<SiteInstanceImpl*>(site_instance)
- ->PreventOptInOriginIsolation(previously_visited_origin);
+ ->RegisterAsDefaultOriginIsolation(previously_visited_origin);
}
}