Commit 2d614435 authored by Danyao Wang's avatar Danyao Wang Committed by Commit Bot

[Nav Experiment] Early exit if CommitPendingItem is already called.

CommitPendingItem may be called more than once. For example, when a
navigation fails after it is committed, |webView:didFailNavigation|
calls |loadNativeViewWithSuccess|, which calls CommitPendingItem a
second time even though it was already called once in
|webView:didCommitNavigation|.

NavigationAndLoadCallbacksTest.FailedLoad is failing because of this
reason. This CL fixes the test and the occasional crash observed in
WKBasedNavigationManagerImpl::CommitPendingItem.

Bug: 795475
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I62bbd7b87e26c4e82f197d533a8d5951cf2531e0
Reviewed-on: https://chromium-review.googlesource.com/1002893Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Danyao Wang <danyao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549290}
parent 7463677b
......@@ -159,6 +159,11 @@ void WKBasedNavigationManagerImpl::AddPendingItem(
}
void WKBasedNavigationManagerImpl::CommitPendingItem() {
// CommitPendingItem may be called multiple times. Do nothing if there is no
// pending item.
if (pending_item_index_ == -1 && !pending_item_)
return;
bool last_committed_item_was_empty_window_open_item =
empty_window_open_item_ != nullptr;
......@@ -190,6 +195,7 @@ void WKBasedNavigationManagerImpl::CommitPendingItem() {
}
pending_item_index_ = -1;
pending_item_.reset();
// If the last committed item is the empty window open item, then don't update
// previous item because the new commit replaces the last committed item.
if (!last_committed_item_was_empty_window_open_item) {
......
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