Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: chromeos/dbus/dbus_thread_manager.cc

Issue 2319783002: mash: Allow a subset of D-Bus clients to be created in DBusThreadManager (Closed)
Patch Set: cleanup Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/dbus_thread_manager.cc
diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc
index ecb6af2e86b0b612dd487bd7641e62b53997bd20..7f26f067d2f80126b9f26e1e74a7165260e2e189 100644
--- a/chromeos/dbus/dbus_thread_manager.cc
+++ b/chromeos/dbus/dbus_thread_manager.cc
@@ -193,28 +193,50 @@ UpdateEngineClient* DBusThreadManager::GetUpdateEngineClient() {
}
void DBusThreadManager::InitializeClients() {
- GetArcObbMounterClient()->Init(GetSystemBus());
- GetCrasAudioClient()->Init(GetSystemBus());
- GetCrosDisksClient()->Init(GetSystemBus());
- GetCryptohomeClient()->Init(GetSystemBus());
- GetDebugDaemonClient()->Init(GetSystemBus());
- GetEasyUnlockClient()->Init(GetSystemBus());
- GetGsmSMSClient()->Init(GetSystemBus());
- GetImageBurnerClient()->Init(GetSystemBus());
- GetLorgnetteManagerClient()->Init(GetSystemBus());
- GetModemMessagingClient()->Init(GetSystemBus());
- GetPermissionBrokerClient()->Init(GetSystemBus());
- GetPowerManagerClient()->Init(GetSystemBus());
- GetSessionManagerClient()->Init(GetSystemBus());
- GetShillDeviceClient()->Init(GetSystemBus());
- GetShillIPConfigClient()->Init(GetSystemBus());
- GetShillManagerClient()->Init(GetSystemBus());
- GetShillServiceClient()->Init(GetSystemBus());
- GetShillProfileClient()->Init(GetSystemBus());
- GetShillThirdPartyVpnDriverClient()->Init(GetSystemBus());
- GetSMSClient()->Init(GetSystemBus());
- GetSystemClockClient()->Init(GetSystemBus());
- GetUpdateEngineClient()->Init(GetSystemBus());
+ if (GetArcObbMounterClient())
+ GetArcObbMounterClient()->Init(GetSystemBus());
+ if (GetCrasAudioClient())
+ GetCrasAudioClient()->Init(GetSystemBus());
+ if (GetCrosDisksClient())
+ GetCrosDisksClient()->Init(GetSystemBus());
+ if (GetCryptohomeClient())
+ GetCryptohomeClient()->Init(GetSystemBus());
+ if (GetDebugDaemonClient())
+ GetDebugDaemonClient()->Init(GetSystemBus());
+ if (GetEasyUnlockClient())
+ GetEasyUnlockClient()->Init(GetSystemBus());
+ if (GetGsmSMSClient())
+ GetGsmSMSClient()->Init(GetSystemBus());
+ if (GetImageBurnerClient())
+ GetImageBurnerClient()->Init(GetSystemBus());
+ if (GetLorgnetteManagerClient())
+ GetLorgnetteManagerClient()->Init(GetSystemBus());
+ if (GetModemMessagingClient())
+ GetModemMessagingClient()->Init(GetSystemBus());
+ if (GetPermissionBrokerClient())
+ GetPermissionBrokerClient()->Init(GetSystemBus());
+ if (GetPowerManagerClient())
+ GetPowerManagerClient()->Init(GetSystemBus());
+ if (GetSessionManagerClient())
+ GetSessionManagerClient()->Init(GetSystemBus());
+ if (GetShillDeviceClient())
+ GetShillDeviceClient()->Init(GetSystemBus());
+ if (GetShillIPConfigClient())
+ GetShillIPConfigClient()->Init(GetSystemBus());
+ if (GetShillManagerClient())
+ GetShillManagerClient()->Init(GetSystemBus());
+ if (GetShillServiceClient())
+ GetShillServiceClient()->Init(GetSystemBus());
+ if (GetShillProfileClient())
+ GetShillProfileClient()->Init(GetSystemBus());
+ if (GetShillThirdPartyVpnDriverClient())
+ GetShillThirdPartyVpnDriverClient()->Init(GetSystemBus());
+ if (GetSMSClient())
+ GetSMSClient()->Init(GetSystemBus());
+ if (GetSystemClockClient())
+ GetSystemClockClient()->Init(GetSystemBus());
+ if (GetUpdateEngineClient())
+ GetUpdateEngineClient()->Init(GetSystemBus());
// This must be called after the list of clients so they've each had a
// chance to register with their object g_dbus_thread_managers.
@@ -224,12 +246,17 @@ void DBusThreadManager::InitializeClients() {
client_bundle_->SetupDefaultEnvironment();
}
-bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) {
- return client_bundle_->IsUsingStub(client);
+bool DBusThreadManager::IsUsingFake(DBusClientBundle::DBusClientType client) {
+ return client_bundle_->IsUsingFake(client);
}
// static
void DBusThreadManager::Initialize() {
+ Initialize(DBusClientBundle::ALL_CLIENTS);
+}
+
+// static
+void DBusThreadManager::Initialize(DBusClientTypeMask clients) {
// If we initialize DBusThreadManager twice we may also be shutting it down
// early; do not allow that.
if (g_using_dbus_thread_manager_for_testing)
@@ -243,13 +270,13 @@ void DBusThreadManager::Initialize() {
chromeos::switches::kDbusUnstubClients);
// Determine whether we use stub or real client implementations.
if (force_unstub_clients) {
- InitializeWithPartialStub(
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- chromeos::switches::kDbusUnstubClients));
+ InitializeWithPartialFakes(
+ clients, base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ chromeos::switches::kDbusUnstubClients));
} else if (use_dbus_stub) {
- InitializeWithStubs();
+ InitializeWithFakeClients(clients);
} else {
- InitializeWithRealClients();
+ InitializeWithRealClients(clients);
}
}
@@ -258,44 +285,50 @@ std::unique_ptr<DBusThreadManagerSetter>
DBusThreadManager::GetSetterForTesting() {
if (!g_using_dbus_thread_manager_for_testing) {
g_using_dbus_thread_manager_for_testing = true;
- InitializeWithStubs();
+ InitializeWithFakeClients(DBusClientBundle::ALL_CLIENTS);
}
return base::WrapUnique(new DBusThreadManagerSetter());
}
// static
-void DBusThreadManager::CreateGlobalInstance(
- DBusClientBundle::DBusClientTypeMask unstub_client_mask) {
+void DBusThreadManager::CreateGlobalInstance(DBusClientTypeMask real_clients,
+ DBusClientTypeMask fake_clients) {
CHECK(!g_dbus_thread_manager);
g_dbus_thread_manager = new DBusThreadManager(
- base::MakeUnique<DBusClientBundle>(unstub_client_mask));
+ base::MakeUnique<DBusClientBundle>(real_clients, fake_clients));
g_dbus_thread_manager->InitializeClients();
}
// static
-void DBusThreadManager::InitializeWithRealClients() {
- CreateGlobalInstance(~static_cast<DBusClientBundle::DBusClientTypeMask>(0));
+void DBusThreadManager::InitializeWithRealClients(
+ DBusClientTypeMask real_clients) {
+ const DBusClientTypeMask fake_clients = DBusClientBundle::NO_CLIENT;
+ CreateGlobalInstance(real_clients, fake_clients);
VLOG(1) << "DBusThreadManager initialized for Chrome OS";
}
// static
-void DBusThreadManager::InitializeWithStubs() {
- CreateGlobalInstance(0 /* unstub_client_mask */);
+void DBusThreadManager::InitializeWithFakeClients(
+ DBusClientTypeMask fake_clients) {
+ const DBusClientTypeMask real_clients = DBusClientBundle::NO_CLIENT;
+ CreateGlobalInstance(real_clients, fake_clients);
VLOG(1) << "DBusThreadManager created for testing";
}
// static
-void DBusThreadManager::InitializeWithPartialStub(
- const std::string& unstub_clients) {
- DBusClientBundle::DBusClientTypeMask unstub_client_mask =
- DBusClientBundle::ParseUnstubList(unstub_clients);
+void DBusThreadManager::InitializeWithPartialFakes(
+ DBusClientTypeMask clients,
+ const std::string& force_real_clients_list) {
+ DBusClientTypeMask real_clients =
+ DBusClientBundle::ParseUnstubList(force_real_clients_list);
// We should have something parsed correctly here.
- LOG_IF(FATAL, unstub_client_mask == 0)
- << "Switch values for --" << chromeos::switches::kDbusUnstubClients
- << " cannot be parsed: " << unstub_clients;
+ LOG_IF(FATAL, real_clients == 0) << "Switch values for --"
+ << chromeos::switches::kDbusUnstubClients
+ << " cannot be parsed: " << real_clients;
VLOG(1) << "DBusThreadManager initialized for mixed runtime environment";
- CreateGlobalInstance(unstub_client_mask);
+ DBusClientTypeMask fake_clients = clients & ~real_clients;
+ CreateGlobalInstance(fake_clients, real_clients);
Daniel Erat 2016/09/07 20:31:59 the parameters here are swapped
James Cook 2016/09/07 20:58:12 Argh. Good catch. Done. I tried to add a test for
}
// static

Powered by Google App Engine
This is Rietveld 408576698