Skip to content

Commit

Permalink
Rewrite IsDescendant of to a ForEachRenderFrameHost
Browse files Browse the repository at this point in the history
The code previously collected the descendants determining if they
were a child of the current frame tree. It is far easier to iterate
the frame tree and clear any that are remaining.

BUG=1249202

Change-Id: I625b42ab286a56097b127278a9dcc43655c232f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3157414
Reviewed-by: Kevin McNee <[email protected]>
Reviewed-by: Colin Blundell <[email protected]>
Commit-Queue: Dave Tapuska <[email protected]>
Cr-Commit-Position: refs/heads/main@{#921649}
  • Loading branch information
dtapuska authored and Chromium LUCI CQ committed Sep 15, 2021
1 parent 115290d commit d95bd66
Showing 1 changed file with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,18 +412,15 @@ void WebContentsTaskProvider::WebContentsEntry::ClearTaskForFrame(

void WebContentsTaskProvider::WebContentsEntry::ClearTasksForDescendantsOf(
RenderFrameHost* ancestor) {
// 1) Collect descendants.
base::flat_set<RenderFrameHost*> descendants;
for (const auto& site_instance_pair : site_instance_infos_) {
for (auto* frame : site_instance_pair.second.frames) {
if (frame->IsDescendantOf(ancestor))
descendants.insert(frame);
}
}

// 2) Delete them.
for (RenderFrameHost* rfh : descendants)
ClearTaskForFrame(rfh);
ancestor->ForEachRenderFrameHost(base::BindRepeating(
[](WebContentsTaskProvider::WebContentsEntry* provider,
content::RenderFrameHost* ancestor,
content::RenderFrameHost* render_frame_host) {
if (render_frame_host == ancestor)
return;
provider->ClearTaskForFrame(render_frame_host);
},
this, ancestor));
}

////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit d95bd66

Please sign in to comment.