From 47e533fa5f6c4b1af6953d3840091fe39dfc58b0 Mon Sep 17 00:00:00 2001 From: Claudio DeSouza Date: Thu, 27 Apr 2023 17:56:32 +0100 Subject: [PATCH] set_manager_for_testing removed upstream Chromium change: https://chromium.googlesource.com/chromium/src/+/3381daf526425ad5b99d5678adab03c073531531 commit 3381daf526425ad5b99d5678adab03c073531531 Author: Lily Chen Date: Fri Apr 21 12:57:07 2023 +0000 [DownloadBubble] Defer GetDownloadManager() calls This defers calls to GetDownloadManager() to avoid calling it at startup, which may be expensive as it may cause the DownloadManager to be created immediately. These calls were potentially causing large performance regressions in startup time when the download bubble is enabled. This fixes 3 places: 1. DownloadBubbleUpdateService: This CL now splits the initialization of the service, adding a separate function to start listening to the DownloadManager (by creating an AllDownloadItemNotifier) after the DownloadManager is ready. This function is called from DownloadUIController's ctor, which runs immediately after the DownloadManager has been created by DownloadCoreService in GetDownloadManagerDelegate. 2. DownloadBubbleUIController: This CL removes the ctor call to GetDownloadManager() in favor of getting the manager only when needed, i.e. when retrying a download, by which time the manager should be initialized. 3. DownloadDisplayController: This was calling GetDownloadManager() on construction (i.e. startup) completely unnecessarily, to get the DownloadPrefs, which also has a getter based on BrowserContext. Bug: 1421426 --- browser/download/bubble/download_display_controller_unittest.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/browser/download/bubble/download_display_controller_unittest.cc b/browser/download/bubble/download_display_controller_unittest.cc index 3a761cd9272f..931d3d5a4724 100644 --- a/browser/download/bubble/download_display_controller_unittest.cc +++ b/browser/download/bubble/download_display_controller_unittest.cc @@ -265,10 +265,8 @@ class DownloadDisplayControllerTest : public testing::Test { browser_ = std::unique_ptr(Browser::Create(params)); bubble_controller_ = std::make_unique( browser_.get(), mock_update_service_.get()); - bubble_controller_->set_manager_for_testing(manager_.get()); controller_ = std::make_unique( display_.get(), browser_.get(), bubble_controller_.get()); - controller_->set_manager_for_testing(manager_.get()); display_->SetController(controller_.get()); }