Use RemoveEntryById to erase the entry when restore recent closed tabs
This CL will use the method RemoveEntryById to remove the entry from entries list of tab restore. Because the iterator may be invaild after the time-consuming operation. Change-Id: I70fc581f41fea1a9f88d496b92d367458b77f865 Bug: 390075226 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6176858 Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org> Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org> Reviewed-by: Stefan Kuhne <skuhne@chromium.org> Reviewed-by: Sky Malice <skym@chromium.org> Cr-Commit-Position: refs/heads/main@{#1408035}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
86d506005d
commit
525df6f097
chrome/android/javatests/src/org/chromium/chrome/browser/ntp
components/sessions/core
@ -692,7 +692,10 @@ std::vector<LiveTab*> TabRestoreServiceHelper::RestoreEntryById(
|
||||
|
||||
if (window.tabs.empty()) {
|
||||
// Remove the entry if there is nothing left to restore.
|
||||
entries_.erase(entry_iterator);
|
||||
// The entries_ may by changed after the tabs restored and the
|
||||
// entry_iterator may be no longer valid. So call RemoveEntryById here
|
||||
// instead of entries_.erase(entry_iterator).
|
||||
RemoveEntryById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -745,7 +748,10 @@ std::vector<LiveTab*> TabRestoreServiceHelper::RestoreEntryById(
|
||||
CHECK(ValidateGroup(group));
|
||||
group.tabs.erase(group.tabs.begin() + i);
|
||||
if (group.tabs.empty()) {
|
||||
entries_.erase(entry_iterator);
|
||||
// The entries_ may by changed after the tabs restored and the
|
||||
// entry_iterator may be no longer valid. So call RemoveEntryById
|
||||
// here instead of entries_.erase(entry_iterator).
|
||||
RemoveEntryById(id);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -759,7 +765,10 @@ std::vector<LiveTab*> TabRestoreServiceHelper::RestoreEntryById(
|
||||
}
|
||||
|
||||
if (entry_id_matches_restore_id) {
|
||||
entries_.erase(entry_iterator);
|
||||
// The entries_ may by changed after the tabs restored and the
|
||||
// entry_iterator may be no longer valid. So call RemoveEntryById here
|
||||
// instead of entries_.erase(entry_iterator).
|
||||
RemoveEntryById(id);
|
||||
}
|
||||
|
||||
restoring_ = false;
|
||||
|
Reference in New Issue
Block a user