Commit a2343dd0 authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[Devtools] Simplify GetFtnForNetworkRequest.

Please make sure I didn't simplify it too much. :-)
Also, please let me know what comment to put (if any)
for the second return. Thanks.

Change-Id: Iffa201442e99c1df4896fe4c168845df2bcb9bc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1718781
Commit-Queue: Johannes Henkel <johannes@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681141}
parent add9b228
......@@ -55,22 +55,19 @@ FrameTreeNode* GetFtnForNetworkRequest(int process_id, int routing_id) {
// Navigation requests start in the browser, before process_id is assigned, so
// the id is set to 0. In these situations, the routing_id is the frame tree
// node id, and can be used directly.
int frame_tree_node_id =
process_id == 0 ? routing_id
: RenderFrameHost::GetFrameTreeNodeIdForRoutingId(
process_id, routing_id);
FrameTreeNode* ftn = FrameTreeNode::GloballyFindByID(frame_tree_node_id);
if (process_id == 0) {
FrameTreeNode* ftn = FrameTreeNode::GloballyFindByID(routing_id);
if (ftn == nullptr)
return nullptr;
// If this is a navigation request (process_id == 0) of a child frame
// (ftn->parent()), then requestWillBeSent and responseReceived are delivered
// to the parent frame instead of the child because we don't know if the child
// will become an OOPIF with a separate target yet or not. Do the same for
// requestWillBeSentExtraInfo and responseReceivedExtraInfo.
if (ftn && process_id == 0 && ftn->parent()) {
ftn = ftn->parent();
// (ftn->parent()), then requestWillBeSent and responseReceived are
// delivered to the parent frame instead of the child because we don't know
// if the child will become an OOPIF with a separate target yet or not. Do
// the same for requestWillBeSentExtraInfo and responseReceivedExtraInfo.
return ftn->parent() ? ftn->parent() : ftn;
}
return ftn;
return FrameTreeNode::GloballyFindByID(
RenderFrameHost::GetFrameTreeNodeIdForRoutingId(process_id, routing_id));
}
} // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment