Skip to content

Commit

Permalink
Remove SiteDataCacheFacade service for System Profile
Browse files Browse the repository at this point in the history
This is the last service that is created with the creation of the System Profile. System Profile is not expected to need any keyed service to be active yet.

Fix: stop tracking web contents performance on profiles that have keyed service disabled, in this case System Profile.

Bug: 1284664
Change-Id: Ie534f49bf7f3d1ef966a82bebe1757b5629cea26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4518422
Reviewed-by: David Roger <droger@chromium.org>
Commit-Queue: Ryan Sultanem <rsult@google.com>
Cr-Commit-Position: refs/heads/main@{#1147131}
  • Loading branch information
Ryan Sultanem authored and Chromium LUCI CQ committed May 22, 2023
1 parent 17ff63b commit fbef34b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
12 changes: 9 additions & 3 deletions chrome/browser/chrome_content_browser_client.cc
Expand Up @@ -1862,9 +1862,15 @@ ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
std::unique_ptr<content::WebContentsViewDelegate>
ChromeContentBrowserClient::GetWebContentsViewDelegate(
content::WebContents* web_contents) {
if (auto* registry =
performance_manager::PerformanceManagerRegistry::GetInstance()) {
registry->MaybeCreatePageNodeForWebContents(web_contents);
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
// Do not track web contents performance for profiles that have Keyed Services
// disabled.
if (!AreKeyedServicesDisabledForProfileByDefault(profile)) {
if (auto* registry =
performance_manager::PerformanceManagerRegistry::GetInstance()) {
registry->MaybeCreatePageNodeForWebContents(web_contents);
}
}
return CreateWebContentsViewDelegate(web_contents);
}
Expand Down
Expand Up @@ -48,7 +48,6 @@ SiteDataCacheFacadeFactory::SiteDataCacheFacadeFactory()
ProfileSelections::Builder()
.WithRegular(ProfileSelection::kOwnInstance)
.WithGuest(ProfileSelection::kOwnInstance)
.WithSystem(ProfileSelection::kOwnInstance)
.Build()) {
DependsOn(HistoryServiceFactory::GetInstance());
}
Expand Down
19 changes: 3 additions & 16 deletions chrome/browser/profiles/profile_keyed_service_browsertest.cc
Expand Up @@ -172,37 +172,24 @@ class ProfileKeyedServiceBrowserTest : public InProcessBrowserTest {

IN_PROC_BROWSER_TEST_F(ProfileKeyedServiceBrowserTest,
SystemProfileOTR_NeededServices) {
// clang-format off
// List of services expected to be created for the System OTR Profile.
std::set<std::string> system_otr_active_services {
"SiteDataCacheFacadeFactory"
};
// clang-format on

Profile* system_profile =
CreateProfileAndWaitForAllTasks(ProfileManager::GetSystemProfilePath());
ASSERT_TRUE(system_profile->HasAnyOffTheRecordProfile());
Profile* system_profile_otr = system_profile->GetPrimaryOTRProfile(false);
ASSERT_TRUE(system_profile_otr->IsOffTheRecord());
ASSERT_TRUE(system_profile_otr->IsSystemProfile());
TestKeyedProfileServicesActives(system_profile_otr,
system_otr_active_services);
/*expected_active_services_names=*/{});
}

IN_PROC_BROWSER_TEST_F(ProfileKeyedServiceBrowserTest,
SystemProfileParent_NeededServices) {
// clang-format off
// List of services expected to be created for the Parent System Profile.
std::set<std::string> system_active_services {
"SiteDataCacheFacadeFactory"
};
// clang-format on

Profile* system_profile =
CreateProfileAndWaitForAllTasks(ProfileManager::GetSystemProfilePath());
ASSERT_FALSE(system_profile->IsOffTheRecord());
ASSERT_TRUE(system_profile->IsSystemProfile());
TestKeyedProfileServicesActives(system_profile, system_active_services);
TestKeyedProfileServicesActives(system_profile,
/*expected_active_services_names=*/{});
}

IN_PROC_BROWSER_TEST_F(ProfileKeyedServiceBrowserTest,
Expand Down

0 comments on commit fbef34b

Please sign in to comment.