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

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: WIP, add DBusThreadManagerAsh and DBusThreadManagerChrome 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
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.h ('k') | chromeos/dbus/dbus_thread_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/dbus_thread_manager.cc
diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc
index e0df6117f28afa5346044361df66a8e07539468b..1083b13782c78ffbb33255fd7239e6e242322c19 100644
--- a/chromeos/dbus/dbus_thread_manager.cc
+++ b/chromeos/dbus/dbus_thread_manager.cc
@@ -193,38 +193,65 @@ 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());
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)
@@ -238,13 +265,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);
}
}
@@ -253,44 +280,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(real_clients, fake_clients);
}
// static
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.h ('k') | chromeos/dbus/dbus_thread_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698