Skip to content

Commit 6fe9cae

Browse files
Ryan SultanemChromium LUCI CQ
Ryan Sultanem
authored and
Chromium LUCI CQ
committed
EnsureBrowserContextKeyedServicesFactoriesBuilt -- Chrome common Factories
Add missing common Chrome KeyedServiceFactories to the initialisation list in `EnsureBrowserContextKeyedServicesFactoriesBuilt()` to properly populate the dependency graph at start. If the factory `GetInstance()` method does not exist, is private, or the whole factory is private (or implemented in a .cc file), only expose an `EnsureFactoryBuilt()` method in the relative service or code that matters. Bug: 1412439 Change-Id: I643473899914b9c28886e9511138881265b243b0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4190213 Reviewed-by: David Roger <[email protected]> Reviewed-by: Dominick Ng <[email protected]> Reviewed-by: Colin Blundell <[email protected]> Code-Coverage: Findit <[email protected]> Commit-Queue: Ryan Sultanem <[email protected]> Cr-Commit-Position: refs/heads/main@{#1102058}
1 parent f0c02e8 commit 6fe9cae

30 files changed

+370
-19
lines changed

apps/browser_context_keyed_service_factories.cc

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace apps {
1616
void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
1717
AppLifetimeMonitorFactory::GetInstance();
1818
AppRestoreServiceFactory::GetInstance();
19+
SavedFilesServiceFactory::GetInstance();
1920
}
2021

2122
void NotifyApplicationTerminating(content::BrowserContext* browser_context) {

chrome/browser/apps/platform_apps/api/browser_context_keyed_service_factories.cc

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@
66

77
#include "build/chromeos_buildflags.h"
88

9+
#include "chrome/browser/apps/platform_apps/api/media_galleries/media_galleries_api.h"
10+
#include "chrome/browser/apps/platform_apps/api/sync_file_system/extension_sync_event_observer.h"
11+
912
#if BUILDFLAG(IS_CHROMEOS_ASH)
1013
#include "chrome/browser/apps/platform_apps/api/arc_apps_private/arc_apps_private_api.h"
1114
#endif
1215

13-
namespace chrome_apps {
14-
namespace api {
16+
namespace chrome_apps::api {
1517

1618
void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
1719
#if BUILDFLAG(IS_CHROMEOS_ASH)
1820
ArcAppsPrivateAPI::GetFactoryInstance();
1921
#endif
22+
ExtensionSyncEventObserver::GetFactoryInstance();
23+
MediaGalleriesEventRouter::GetFactoryInstance();
2024
}
2125

22-
} // namespace api
23-
} // namespace chrome_apps
26+
} // namespace chrome_apps::api

chrome/browser/history_clusters/history_clusters_service_factory.cc

+5
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,8 @@ KeyedService* HistoryClustersServiceFactory::BuildServiceInstanceFor(
6969
OptimizationGuideKeyedServiceFactory::GetForProfile(profile),
7070
profile->GetPrefs());
7171
}
72+
73+
// static
74+
void HistoryClustersServiceFactory::EnsureFactoryBuilt() {
75+
GetInstance();
76+
}

chrome/browser/history_clusters/history_clusters_service_factory.h

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class HistoryClustersServiceFactory : public ProfileKeyedServiceFactory {
2121
static history_clusters::HistoryClustersService* GetForBrowserContext(
2222
content::BrowserContext* browser_context);
2323

24+
static void EnsureFactoryBuilt();
25+
2426
private:
2527
friend base::NoDestructor<HistoryClustersServiceFactory>;
2628
static HistoryClustersServiceFactory& GetInstance();

chrome/browser/image_service/image_service_factory.cc

+5
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,9 @@ KeyedService* ImageServiceFactory::BuildServiceInstanceFor(
4040
SyncServiceFactory::GetForProfile(profile));
4141
}
4242

43+
// static
44+
void ImageServiceFactory::EnsureFactoryBuilt() {
45+
GetInstance();
46+
}
47+
4348
} // namespace image_service

chrome/browser/image_service/image_service_factory.h

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class ImageServiceFactory : public ProfileKeyedServiceFactory {
2424
static ImageService* GetForBrowserContext(
2525
content::BrowserContext* browser_context);
2626

27+
static void EnsureFactoryBuilt();
28+
2729
private:
2830
friend base::NoDestructor<ImageServiceFactory>;
2931
static ImageServiceFactory& GetInstance();

chrome/browser/lookalikes/lookalike_url_service.cc

+5
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,8 @@ void LookalikeUrlService::OnUIDisabledFirstVisit(const GURL& url) {
371371
void LookalikeUrlService::ResetWarningDismissedETLDPlusOnesForTesting() {
372372
warning_dismissed_etld1s_.clear();
373373
}
374+
375+
// static
376+
void LookalikeUrlService::EnsureFactoryBuilt() {
377+
LookalikeUrlServiceFactory::GetInstance();
378+
}

chrome/browser/lookalikes/lookalike_url_service.h

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ class LookalikeUrlService : public KeyedService {
150150
// for testing.
151151
void ResetWarningDismissedETLDPlusOnesForTesting();
152152

153+
static void EnsureFactoryBuilt();
154+
153155
private:
154156
// Called when an async engaged site computation is finished.
155157
void OnUpdateEngagedSitesCompleted(

chrome/browser/media_galleries/media_file_system_registry.cc

+6
Original file line numberDiff line numberDiff line change
@@ -697,3 +697,9 @@ void MediaFileSystemRegistry::OnProfileShutdown(Profile* profile) {
697697
DCHECK(profile_subscription_it != profile_subscription_map_.end());
698698
profile_subscription_map_.erase(profile_subscription_it);
699699
}
700+
701+
// static
702+
BrowserContextKeyedServiceShutdownNotifierFactory*
703+
MediaFileSystemRegistry::GetFactoryInstance() {
704+
return MediaFileSystemRegistryShutdownNotifierFactory::GetInstance();
705+
}

chrome/browser/media_galleries/media_file_system_registry.h

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
2121
#include "components/storage_monitor/removable_storage_observer.h"
2222

23+
class BrowserContextKeyedServiceShutdownNotifierFactory;
2324
class ExtensionGalleriesHost;
2425
class GalleryWatchManager;
2526
class MediaFileSystemContext;
@@ -99,6 +100,9 @@ class MediaFileSystemRegistry
99100
void OnRemovableStorageDetached(
100101
const storage_monitor::StorageInfo& info) override;
101102

103+
static BrowserContextKeyedServiceShutdownNotifierFactory*
104+
GetFactoryInstance();
105+
102106
private:
103107
class MediaFileSystemContextImpl;
104108

chrome/browser/plugins/plugin_info_host_impl.cc

+5
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ void PluginInfoHostImpl::GetPluginInfoFinish(
383383
std::move(callback).Run(std::move(output));
384384
}
385385

386+
// static
387+
void PluginInfoHostImpl::EnsureFactoryBuilt() {
388+
PluginInfoHostImplShutdownNotifierFactory::GetInstance();
389+
}
390+
386391
void PluginInfoHostImpl::Context::MaybeGrantAccess(
387392
chrome::mojom::PluginStatus status,
388393
const base::FilePath& path) const {

chrome/browser/plugins/plugin_info_host_impl.h

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class PluginInfoHostImpl : public chrome::mojom::PluginInfoHost {
105105
const std::string& mime_type,
106106
GetPluginInfoCallback callback) override;
107107

108+
static void EnsureFactoryBuilt();
109+
108110
private:
109111
void ShutdownOnUIThread();
110112

0 commit comments

Comments
 (0)