Skip to content

Commit

Permalink
set_manager_for_testing removed upstream
Browse files Browse the repository at this point in the history
Chromium change:
https://chromium.googlesource.com/chromium/src/+/3381daf526425ad5b99d5678adab03c073531531

commit 3381daf526425ad5b99d5678adab03c073531531
Author: Lily Chen <[email protected]>
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
  • Loading branch information
cdesouza-chromium committed Apr 28, 2023
1 parent 7b3ad34 commit 47e533f
Showing 1 changed file with 0 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,8 @@ class DownloadDisplayControllerTest : public testing::Test {
browser_ = std::unique_ptr<Browser>(Browser::Create(params));
bubble_controller_ = std::make_unique<DownloadBubbleUIController>(
browser_.get(), mock_update_service_.get());
bubble_controller_->set_manager_for_testing(manager_.get());
controller_ = std::make_unique<DownloadDisplayController>(
display_.get(), browser_.get(), bubble_controller_.get());
controller_->set_manager_for_testing(manager_.get());
display_->SetController(controller_.get());
}

Expand Down

0 comments on commit 47e533f

Please sign in to comment.