Skip to content

Commit

Permalink
UpdateToolbarButtonState simplified to receive a summary
Browse files Browse the repository at this point in the history
Chromium change:
https://chromium.googlesource.com/chromium/src/+/e1a48ccd6d3ea6fb6bd8a9d82cecd4cad1b3a202

commit e1a48ccd6d3ea6fb6bd8a9d82cecd4cad1b3a202
Author: Lily Chen <[email protected]>
Date:   Fri Apr 21 20:11:47 2023 +0000

    [DownloadBubble] Compute info relevant to button state in update service

    This moves the computation of the AllDownloadUIModelsInfo from the
    per-window DownloadDisplayController to the per-profile
    DownloadBubbleUpdateService. This avoids redundant fetching of models
    from the update service, which is expensive and potentially causes jank
    while downloading files, since the models are not needed (just the info
    about them) in order to update the button state.

    Bug: 1434670
  • Loading branch information
cdesouza-chromium committed Apr 28, 2023
1 parent 47e533f commit 6c5ec04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
#undef DownloadDisplayController

void DownloadDisplayController::UpdateToolbarButtonState(
std::vector<std::unique_ptr<DownloadUIModel>>& all_models) {
DownloadDisplayControllerChromium::UpdateToolbarButtonState(all_models);
const AllDownloadUIModelsInfo& info) {
DownloadDisplayControllerChromium::UpdateToolbarButtonState(info);

if (all_models.empty()) {
if (info.all_models_size == 0) {
return;
}

Expand All @@ -26,10 +26,7 @@ void DownloadDisplayController::UpdateToolbarButtonState(
// Show toolbar if there's at least one in-progress download item.
// Upstream doesn't show toolbar button when only dangerous files are
// in-progress.
for (const auto& model : all_models) {
if (model->GetState() == download::DownloadItem::IN_PROGRESS) {
ShowToolbarButton();
return;
}
if (info.in_progress_count || info.has_deep_scanning) {
ShowToolbarButton();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class DownloadDisplayController : public DownloadDisplayControllerChromium {
using DownloadDisplayControllerChromium::DownloadDisplayControllerChromium;

private:
void UpdateToolbarButtonState(
std::vector<std::unique_ptr<DownloadUIModel>>& all_models) override;
void UpdateToolbarButtonState(const AllDownloadUIModelsInfo& info) override;
};

#endif // BRAVE_CHROMIUM_SRC_CHROME_BROWSER_DOWNLOAD_BUBBLE_DOWNLOAD_DISPLAY_CONTROLLER_H_

0 comments on commit 6c5ec04

Please sign in to comment.