[iOS][QD] Add tab closure when deleting browsing data [chromium/src : main]

0 views
Skip to first unread message

Filipa Senra (Gerrit)

unread,
Jul 4, 2024, 1:56:52 AM (yesterday) Jul 4
to Sylvain Defresne, findit...@appspot.gserviceaccount.com, Chromium LUCI CQ, Tricium, chromium...@chromium.org, dullweb...@chromium.org, feature-me...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org, msrame...@chromium.org
Attention needed from Sylvain Defresne

Filipa Senra added 1 comment

Patchset-level comments
File-level comment, Patchset 5 (Latest):
Filipa Senra . resolved

Hey Sylvain! Can you take a look? Ty.

Open in Gerrit

Related details

Attention is currently required from:
  • Sylvain Defresne
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I107a0cefb08d3a55ef77a49b5c9ba1c82d78b5eb
Gerrit-Change-Number: 5675435
Gerrit-PatchSet: 5
Gerrit-Owner: Filipa Senra <fse...@google.com>
Gerrit-Reviewer: Filipa Senra <fse...@google.com>
Gerrit-Reviewer: Sylvain Defresne <sdef...@chromium.org>
Gerrit-Attention: Sylvain Defresne <sdef...@chromium.org>
Gerrit-Comment-Date: Thu, 04 Jul 2024 05:56:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Sylvain Defresne (Gerrit)

unread,
Jul 4, 2024, 11:40:28 AM (17 hours ago) Jul 4
to Filipa Senra, findit...@appspot.gserviceaccount.com, Chromium LUCI CQ, Tricium, chromium...@chromium.org, dullweb...@chromium.org, feature-me...@chromium.org, ios-revie...@chromium.org, ios-r...@chromium.org, marq+...@chromium.org, msrame...@chromium.org
Attention needed from Filipa Senra

Sylvain Defresne added 4 comments

File ios/chrome/browser/browsing_data/model/browsing_data_remover_impl.h
Line 8, Patchset 5 (Latest):#import "base/containers/queue.h"
Sylvain Defresne . unresolved

Revert

File ios/chrome/browser/browsing_data/model/browsing_data_remover_impl.mm
Line 699, Patchset 5 (Latest): if (IsRemoveDataMaskSet(mask, BrowsingDataRemoveMask::CLOSE_TABS)) {
SessionRestorationService* service =
SessionRestorationServiceFactory::GetForBrowserState(browser_state_);
BrowserList* browser_list =
BrowserListFactory::GetForBrowserState(browser_state_);
for (Browser* browser : browser_list->AllRegularBrowsers()) {
service->LoadDataFromStorage(
browser,
base::BindRepeating(
&tabs_closure_util::GetLastCommittedTimestampFromStorage),
base::BindOnce(&OnTabsInformationLoaded, browser, delete_begin,
delete_end, CreatePendingTaskCompletionClosure()));
}
}
Sylvain Defresne . unresolved

You already retrieve that info in `TabsCloser`.

Maybe we should avoid duplicating this query. Having a `TabsWithNoRecentNavigationCloser` which does the counting, keeping the list, and closing, and we pass it to `BrowsingDataRemoverImpl`.

And if `BrowsingDataRemoveMask::CLOSE_TABS` is set, it uses its `TabsWithNoRecentNavigationCloser` to close the tabs. This will avoid duplicating the logic to get the tabs, fetch their data, decide/count which should be closed and closing them.

File ios/chrome/browser/browsing_data/model/tabs_closure_util.mm
Line 47, Patchset 5 (Latest):void CloseTabs(Browser* browser, std::set<web::WebStateID> tabs) {
Sylvain Defresne . unresolved

Pass by const reference, and probably renamed to `tabs_to_close`.

    void CloseTabs(
Browser* browser,
const std::set<web::WebStateID>& tabs_to_close) {
Line 61, Patchset 5 (Latest): web_state_list->CloseWebStateAt(index, WebStateList::CLOSE_NO_FLAGS);
Sylvain Defresne . unresolved

Don't close tabs one by one as this will cause the WebStateList to perform many redundant work. Instead use `CloseWebStatesAtIndices()`

    void CloseWebStatesAtIndices(int close_flags,
RemovingIndexes removing_indexes);

You would use it like this:

    std::vector<int> indices_to_close;
for (int index = 0; index < web_state_list->count(); ++index) {
web::WebSate* web_state = web_state_list->GetWebStateAt(index);
web::WebStateID web_state_id = web_state->GetUniqueIdentifier();
if (base::Contains(tabs, web_state_id)) {
indices_to_close.push_back(index);
if (indices_to_close.size() == tabs.size()) {
// All tabs to close have been found, break early.
break;
}
}
}

WebStateList::ScopedBatchOperation lock =
web_state_list->StartBatchOperation();
web_state_list-> CloseWebStatesAtIndices(
WebStateList::CLOSE_NO_FLAGS,
RemovingIndexes(std::move(indices_to_close));

This avoid some catastrophic O(n**2) algorithm when closing many tabs as WebStateList can do all the bookkeeping at once instead of having to perform incremental bookkeeping for each closed tabs.

Open in Gerrit

Related details

Attention is currently required from:
  • Filipa Senra
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I107a0cefb08d3a55ef77a49b5c9ba1c82d78b5eb
    Gerrit-Change-Number: 5675435
    Gerrit-PatchSet: 5
    Gerrit-Owner: Filipa Senra <fse...@google.com>
    Gerrit-Reviewer: Filipa Senra <fse...@google.com>
    Gerrit-Reviewer: Sylvain Defresne <sdef...@chromium.org>
    Gerrit-Attention: Filipa Senra <fse...@google.com>
    Gerrit-Comment-Date: Thu, 04 Jul 2024 15:40:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages