Skip to content

Commit

Permalink
EnsureBrowserContextKeyedServicesFactoriesBuilt -- Ash
Browse files Browse the repository at this point in the history
Add missing Ash 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.

Arc factories were added in a static `ArcServiceLauncher::EnsureFactoriesBuilt()` method.

Bug: 1412439
Change-Id: I91adc98ec7949cabbc9c75f902a4e9c6a456ab6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4221233
Reviewed-by: David Roger <droger@chromium.org>
Commit-Queue: Ryan Sultanem <rsult@google.com>
Cr-Commit-Position: refs/heads/main@{#1103785}
  • Loading branch information
Ryan Sultanem authored and Chromium LUCI CQ committed Feb 10, 2023
1 parent a246e41 commit 0728086
Show file tree
Hide file tree
Showing 142 changed files with 666 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ash/components/arc/appfuse/arc_appfuse_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,9 @@ void ArcAppfuseBridge::OpenFile(uint32_t uid,
base::BindOnce(&RunWithScopedHandle, std::move(callback)));
}

// static
void ArcAppfuseBridge::EnsureFactoryBuilt() {
ArcAppfuseBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/appfuse/arc_appfuse_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class ArcAppfuseBridge : public KeyedService, public mojom::AppfuseHost {
int32_t flags,
OpenFileCallback callback) override;

static void EnsureFactoryBuilt();

private:
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.
};
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/audio/arc_audio_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,9 @@ void ArcAudioBridge::SendVolumeState() {
audio_instance->NotifyVolumeState(volume_, muted_);
}

// static
void ArcAudioBridge::EnsureFactoryBuilt() {
ArcAudioBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/audio/arc_audio_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class ArcAudioBridge : public KeyedService,
void ShowVolumeControls() override;
void OnSystemVolumeUpdateRequest(int32_t percent) override;

static void EnsureFactoryBuilt();

private:
// ash::CrasAudioHandler::AudioObserver overrides.
void OnAudioNodesChanged() override;
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/camera/arc_camera_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,9 @@ void ArcCameraBridge::RegisterCameraHalClient(
std::move(callback));
}

// static
void ArcCameraBridge::EnsureFactoryBuilt() {
ArcCameraBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/camera/arc_camera_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ArcCameraBridge : public KeyedService, public mojom::CameraHost {
mojo::PendingRemote<cros::mojom::CameraHalClient> client,
RegisterCameraHalClientCallback callback) override;

static void EnsureFactoryBuilt();

private:
class PendingStartCameraServiceResult;

Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/clipboard/arc_clipboard_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,9 @@ void ArcClipboardBridge::GetClipContent(GetClipContentCallback callback) {
std::move(callback).Run(std::move(clip_data));
}

// static
void ArcClipboardBridge::EnsureFactoryBuilt() {
ArcClipboardBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/clipboard/arc_clipboard_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class ArcClipboardBridge : public KeyedService,
void SetClipContent(mojom::ClipDataPtr clip_data) override;
void GetClipContent(GetClipContentCallback callback) override;

static void EnsureFactoryBuilt();

private:
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.

Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/compat_mode/arc_resize_lock_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,9 @@ void ArcResizeLockManager::ShowSplashScreenDialog(aura::Window* window,
is_fully_locked));
}

// static
void ArcResizeLockManager::EnsureFactoryBuilt() {
ArcResizeLockManagerFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/compat_mode/arc_resize_lock_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class ArcResizeLockManager : public KeyedService,
pref_delegate_ = delegate;
}

static void EnsureFactoryBuilt();

private:
friend class ArcResizeLockManagerTest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,9 @@ std::vector<std::string> ArcCrashCollectorBridge::CreateCrashReporterArgs() {
return args;
}

// static
void ArcCrashCollectorBridge::EnsureFactoryBuilt() {
ArcCrashCollectorBridgeFactory::GetInstance();
}

} // namespace arc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class ArcCrashCollectorBridge : public KeyedService,
const std::string& cpu_abi,
const absl::optional<std::string>& fingerprint) override;

static void EnsureFactoryBuilt();

private:
std::vector<std::string> CreateCrashReporterArgs();

Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/disk_quota/arc_disk_quota_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,9 @@ void ArcDiskQuotaBridge::OnGetFreeDiskSpace(GetFreeDiskSpaceCallback callback,
std::move(callback).Run(std::move(disk_space));
}

// static
void ArcDiskQuotaBridge::EnsureFactoryBuilt() {
ArcDiskQuotaBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/disk_quota/arc_disk_quota_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class ArcDiskQuotaBridge : public KeyedService, public mojom::DiskQuotaHost {

void GetFreeDiskSpace(GetFreeDiskSpaceCallback) override;

static void EnsureFactoryBuilt();

private:
void OnGetFreeDiskSpace(GetFreeDiskSpaceCallback callback,
absl::optional<int64_t> reply);
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/ime/arc_ime_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -822,4 +822,9 @@ gfx::Point ArcImeService::GetDisplayOriginForFocusedWindow() const {
.origin();
}

// static
void ArcImeService::EnsureFactoryBuilt() {
ArcImeServiceFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/ime/arc_ime_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ class ArcImeService : public KeyedService,
static void SetOverrideDisplayOriginForTesting(
absl::optional<gfx::Point> origin);

static void EnsureFactoryBuilt();

private:
friend class ArcImeServiceTest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,9 @@ void ArcKeyboardShortcutBridge::HideKeyboardShortcutViewer() {
NOTIMPLEMENTED();
}

// static
void ArcKeyboardShortcutBridge::EnsureFactoryBuilt() {
ArcKeyboardShortcutBridgeFactory::GetInstance();
}

} // namespace arc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class ArcKeyboardShortcutBridge : public KeyedService,
void ShowKeyboardShortcutViewer() override;
void HideKeyboardShortcutViewer() override;

static void EnsureFactoryBuilt();

private:
ArcBridgeService* const arc_bridge_service_;
};
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/lock_screen/arc_lock_screen_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ void ArcLockScreenBridge::SendDeviceLockedState() {
session_manager::SessionManager::Get()->IsUserSessionBlocked());
}

// static
void ArcLockScreenBridge::EnsureFactoryBuilt() {
ArcLockScreenBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/lock_screen/arc_lock_screen_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class ArcLockScreenBridge
// session_manager::SessionManagerObserver overrides.
void OnSessionStateChanged() override;

static void EnsureFactoryBuilt();

private:
// Sends the device locked state to container.
void SendDeviceLockedState();
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/media_session/arc_media_session_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,9 @@ void ArcMediaSessionBridge::SetupAudioFocus() {
ms_instance->EnableAudioFocus(audio_focus.Unbind());
}

// static
void ArcMediaSessionBridge::EnsureFactoryBuilt() {
ArcMediaSessionBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/media_session/arc_media_session_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class ArcMediaSessionBridge
void OnConnectionReady() override;
void OnConnectionClosed() override;

static void EnsureFactoryBuilt();

private:
void SetupAudioFocus();

Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/midis/arc_midis_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,9 @@ void ArcMidisBridge::OnMojoConnectionError() {
midis_host_remote_.reset();
}

// static
void ArcMidisBridge::EnsureFactoryBuilt() {
ArcMidisBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/midis/arc_midis_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class ArcMidisBridge : public KeyedService, public mojom::MidisHost {
void Connect(mojo::PendingReceiver<mojom::MidisServer> receiver,
mojo::PendingRemote<mojom::MidisClient> client_remote) override;

static void EnsureFactoryBuilt();

private:
void OnBootstrapMojoConnection(
mojo::PendingReceiver<mojom::MidisServer> receiver,
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/net/arc_net_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1554,4 +1554,9 @@ void ArcNetHostImpl::OnShuttingDown() {
observing_network_state_ = false;
}

// static
void ArcNetHostImpl::EnsureFactoryBuilt() {
ArcNetHostImplFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/net/arc_net_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class ArcNetHostImpl : public KeyedService,
void OnConnectionReady() override;
void OnConnectionClosed() override;

static void EnsureFactoryBuilt();

private:
const ash::NetworkState* GetDefaultNetworkFromChrome();
void UpdateActiveNetworks(
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/obb_mounter/arc_obb_mounter_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ void ArcObbMounterBridge::UnmountObb(const std::string& target_path,
ash::ArcObbMounterClient::Get()->UnmountObb(target_path, std::move(callback));
}

// static
void ArcObbMounterBridge::EnsureFactoryBuilt() {
ArcObbMounterBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/obb_mounter/arc_obb_mounter_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class ArcObbMounterBridge : public KeyedService, public mojom::ObbMounterHost {
void UnmountObb(const std::string& target_path,
UnmountObbCallback callback) override;

static void EnsureFactoryBuilt();

private:
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.
};
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/pay/arc_digital_goods_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,9 @@ void ArcDigitalGoodsBridge::Consume(const std::string& package_name,
std::move(callback));
}

// static
void ArcDigitalGoodsBridge::EnsureFactoryBuilt() {
ArcDigitalGoodsBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/pay/arc_digital_goods_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class ArcDigitalGoodsBridge : public KeyedService {
const std::string& purchase_token,
ConsumeCallback callback);

static void EnsureFactoryBuilt();

private:
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.
};
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/pay/arc_payment_app_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,9 @@ void ArcPaymentAppBridge::AbortPaymentApp(const std::string& request_token,
payment_app->AbortPaymentApp(request_token, std::move(callback));
}

// static
void ArcPaymentAppBridge::EnsureFactoryBuilt() {
ArcPaymentAppBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/pay/arc_payment_app_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class ArcPaymentAppBridge : public KeyedService {
void AbortPaymentApp(const std::string& request_token,
AbortPaymentAppCallback callback);

static void EnsureFactoryBuilt();

private:
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.
};
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/power/arc_power_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,9 @@ void ArcPowerBridge::UpdateAndroidScreenBrightness(double percent) {
power_instance->UpdateScreenBrightnessSettings(percent);
}

// static
void ArcPowerBridge::EnsureFactoryBuilt() {
ArcPowerBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/power/arc_power_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class ArcPowerBridge : public KeyedService,
wake_lock_provider_ = std::move(provider);
}

static void EnsureFactoryBuilt();

private:
class WakeLockRequestor;

Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/property/arc_property_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,9 @@ void ArcPropertyBridge::SyncMinimizeOnBackButton() {
property_instance->SetMinimizeOnBackButton(false);
}

// static
void ArcPropertyBridge::EnsureFactoryBuilt() {
ArcPropertyBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/property/arc_property_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class ArcPropertyBridge : public KeyedService,
void GetGcaMigrationProperty(
mojom::PropertyInstance::GetGcaMigrationPropertyCallback callback);

static void EnsureFactoryBuilt();

private:
ArcBridgeService* const arc_bridge_service_; // Owned by ArcServiceManager.

Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/rotation_lock/arc_rotation_lock_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,9 @@ void ArcRotationLockBridge::SendRotationLockState() {
static_cast<arc::mojom::Rotation>(current_display.rotation()));
}

// static
void ArcRotationLockBridge::EnsureFactoryBuilt() {
ArcRotationLockBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/rotation_lock/arc_rotation_lock_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class ArcRotationLockBridge
// ash::TabletModeObserver:
void OnTabletPhysicalStateChanged() override;

static void EnsureFactoryBuilt();

private:
void SendRotationLockState();

Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/sensor/arc_iio_sensor_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,9 @@ void ArcIioSensorBridge::OnGetSwitchStates(
}
}

// static
void ArcIioSensorBridge::EnsureFactoryBuilt() {
ArcIioSensorBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/sensor/arc_iio_sensor_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class ArcIioSensorBridge : public KeyedService,
void TabletModeEventReceived(chromeos::PowerManagerClient::TabletMode mode,
base::TimeTicks timestamp) override;

static void EnsureFactoryBuilt();

private:
// Send tablet mode changed event to ARC.
void SendTabletMode();
Expand Down
5 changes: 5 additions & 0 deletions ash/components/arc/system_ui/arc_system_ui_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,9 @@ bool ArcSystemUIBridge::SendOverlayColor(uint32_t source_color,
return true;
}

// static
void ArcSystemUIBridge::EnsureFactoryBuilt() {
ArcSystemUIBridgeFactory::GetInstance();
}

} // namespace arc
2 changes: 2 additions & 0 deletions ash/components/arc/system_ui/arc_system_ui_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class ArcSystemUIBridge : public KeyedService,
bool SendOverlayColor(uint32_t source_color,
mojom::ThemeStyleType theme_style);

static void EnsureFactoryBuilt();

private:
FRIEND_TEST_ALL_PREFIXES(ArcSystemUIBridgeTest, SendOverlayColor);
// Sends the device dark theme state to Android.
Expand Down

0 comments on commit 0728086

Please sign in to comment.