Index: chromeos/dbus/dbus_thread_manager.cc |
diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc |
index e372005dc52663ba1a7723190b1fe63da211a494..fff6567dc807619bd866d17c5e2bc6fc8bbfa56c 100644 |
--- a/chromeos/dbus/dbus_thread_manager.cc |
+++ b/chromeos/dbus/dbus_thread_manager.cc |
@@ -6,6 +6,8 @@ |
#include "base/command_line.h" |
#include "base/observer_list.h" |
+#include "base/strings/string_split.h" |
+#include "base/strings/string_util.h" |
#include "base/sys_info.h" |
#include "base/threading/thread.h" |
#include "chromeos/chromeos_switches.h" |
@@ -55,58 +57,128 @@ namespace chromeos { |
static DBusThreadManager* g_dbus_thread_manager = NULL; |
static DBusThreadManager* g_dbus_thread_manager_for_testing = NULL; |
- |
// The bundle of all D-Bus clients used in DBusThreadManagerImpl. The bundle |
// is used to delete them at once in the right order before shutting down the |
// system bus. See also the comment in the destructor of DBusThreadManagerImpl. |
class DBusClientBundle { |
public: |
- DBusClientBundle() { |
+ enum DBusClientType { |
+ Unknown = 0, |
+ Bluetooth = 1 << 1, |
+ BluetoothLowEnergy = 1 << 2, |
satorux1
2014/08/07 20:00:05
Per http://www.chromium.org/developers/coding-styl
zel
2014/08/07 21:40:44
Done.
|
+ Cras = 1 << 3, |
+ CrosDisks = 1 << 4, |
+ Cryptohome = 1 << 5, |
+ DebugDaemon = 1 << 6, |
+ EasyUnlock = 1 << 7, |
+ LorgnetteManager = 1 << 8, |
+ Shill = 1 << 9, |
+ GsmSMS = 1 << 10, |
+ ImageBurner = 1 << 11, |
+ Introspectable = 1 << 12, |
+ ModemMessaging = 1 << 13, |
+ Nfc = 1 << 14, |
+ PermissionBroker = 1 << 15, |
+ PowerManager = 1 << 16, |
+ PowerPolicy = 1 << 17, |
+ SessionManager = 1 << 18, |
+ SMS = 1 << 19, |
+ SystemClock = 1 << 20, |
+ UpdateEngine = 1 << 21, |
+ All = 0xFFFFFFFF, |
+ }; |
+ |
+ explicit DBusClientBundle(int client_mask) { |
const DBusClientImplementationType type = REAL_DBUS_CLIENT_IMPLEMENTATION; |
- bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create()); |
- bluetooth_agent_manager_client_.reset( |
- BluetoothAgentManagerClient::Create()); |
- bluetooth_device_client_.reset(BluetoothDeviceClient::Create()); |
- bluetooth_gatt_characteristic_client_.reset( |
- BluetoothGattCharacteristicClient::Create()); |
- bluetooth_gatt_descriptor_client_.reset( |
- BluetoothGattDescriptorClient::Create()); |
- bluetooth_gatt_manager_client_.reset(BluetoothGattManagerClient::Create()); |
- bluetooth_gatt_service_client_.reset(BluetoothGattServiceClient::Create()); |
- bluetooth_input_client_.reset(BluetoothInputClient::Create()); |
- bluetooth_profile_manager_client_.reset( |
- BluetoothProfileManagerClient::Create()); |
- cras_audio_client_.reset(CrasAudioClient::Create()); |
- cros_disks_client_.reset(CrosDisksClient::Create(type)); |
+ if (client_mask & Bluetooth) { |
+ bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create()); |
+ bluetooth_agent_manager_client_.reset( |
+ BluetoothAgentManagerClient::Create()); |
+ bluetooth_device_client_.reset(BluetoothDeviceClient::Create()); |
+ bluetooth_input_client_.reset(BluetoothInputClient::Create()); |
+ bluetooth_profile_manager_client_.reset( |
+ BluetoothProfileManagerClient::Create()); |
+ } |
+ |
+ if (client_mask & BluetoothLowEnergy) { |
+ bluetooth_gatt_characteristic_client_.reset( |
+ BluetoothGattCharacteristicClient::Create()); |
+ bluetooth_gatt_descriptor_client_.reset( |
+ BluetoothGattDescriptorClient::Create()); |
+ bluetooth_gatt_manager_client_.reset( |
+ BluetoothGattManagerClient::Create()); |
+ bluetooth_gatt_service_client_.reset( |
+ BluetoothGattServiceClient::Create()); |
+ } |
+ |
+ if (client_mask & Cras) |
+ cras_audio_client_.reset(CrasAudioClient::Create()); |
+ |
+ if (client_mask & CrosDisks) |
+ cros_disks_client_.reset(CrosDisksClient::Create(type)); |
+ |
+ if (client_mask & Cryptohome) |
cryptohome_client_.reset(CryptohomeClient::Create()); |
+ |
+ if (client_mask & DebugDaemon) |
debug_daemon_client_.reset(DebugDaemonClient::Create()); |
- easy_unlock_client_.reset(EasyUnlockClient::Create()); |
- lorgnette_manager_client_.reset(LorgnetteManagerClient::Create()); |
- shill_manager_client_.reset(ShillManagerClient::Create()); |
- shill_device_client_.reset(ShillDeviceClient::Create()); |
- shill_ipconfig_client_.reset(ShillIPConfigClient::Create()); |
- shill_service_client_.reset(ShillServiceClient::Create()); |
- shill_profile_client_.reset(ShillProfileClient::Create()); |
- gsm_sms_client_.reset(GsmSMSClient::Create()); |
- image_burner_client_.reset(ImageBurnerClient::Create()); |
- introspectable_client_.reset(IntrospectableClient::Create()); |
- modem_messaging_client_.reset(ModemMessagingClient::Create()); |
+ |
+ if (client_mask & EasyUnlock) |
+ easy_unlock_client_.reset(EasyUnlockClient::Create()); |
+ |
+ if (client_mask & LorgnetteManager) |
+ lorgnette_manager_client_.reset(LorgnetteManagerClient::Create()); |
+ |
+ if (client_mask & Shill) { |
+ shill_manager_client_.reset(ShillManagerClient::Create()); |
+ shill_device_client_.reset(ShillDeviceClient::Create()); |
+ shill_ipconfig_client_.reset(ShillIPConfigClient::Create()); |
+ shill_service_client_.reset(ShillServiceClient::Create()); |
+ shill_profile_client_.reset(ShillProfileClient::Create()); |
+ } |
+ |
+ if (client_mask & GsmSMS) |
+ gsm_sms_client_.reset(GsmSMSClient::Create()); |
+ |
+ if (client_mask & ImageBurner) |
+ image_burner_client_.reset(ImageBurnerClient::Create()); |
+ |
+ if (client_mask & Introspectable) |
+ introspectable_client_.reset(IntrospectableClient::Create()); |
+ |
+ if (client_mask & ModemMessaging) |
+ modem_messaging_client_.reset(ModemMessagingClient::Create()); |
+ |
// Create the NFC clients in the correct order based on their dependencies. |
- nfc_manager_client_.reset(NfcManagerClient::Create()); |
- nfc_adapter_client_.reset( |
- NfcAdapterClient::Create(nfc_manager_client_.get())); |
- nfc_device_client_.reset( |
- NfcDeviceClient::Create(nfc_adapter_client_.get())); |
- nfc_tag_client_.reset(NfcTagClient::Create(nfc_adapter_client_.get())); |
- nfc_record_client_.reset(NfcRecordClient::Create(nfc_device_client_.get(), |
- nfc_tag_client_.get())); |
- permission_broker_client_.reset(PermissionBrokerClient::Create()); |
- power_manager_client_.reset(PowerManagerClient::Create(type)); |
- session_manager_client_.reset(SessionManagerClient::Create(type)); |
- sms_client_.reset(SMSClient::Create()); |
- system_clock_client_.reset(SystemClockClient::Create()); |
- update_engine_client_.reset(UpdateEngineClient::Create(type)); |
+ if (client_mask & Nfc) { |
+ nfc_manager_client_.reset(NfcManagerClient::Create()); |
+ nfc_adapter_client_.reset( |
+ NfcAdapterClient::Create(nfc_manager_client_.get())); |
+ nfc_device_client_.reset( |
+ NfcDeviceClient::Create(nfc_adapter_client_.get())); |
+ nfc_tag_client_.reset(NfcTagClient::Create(nfc_adapter_client_.get())); |
+ nfc_record_client_.reset(NfcRecordClient::Create(nfc_device_client_.get(), |
+ nfc_tag_client_.get())); |
+ } |
+ |
+ if (client_mask & PermissionBroker) |
+ permission_broker_client_.reset(PermissionBrokerClient::Create()); |
+ |
+ if (client_mask & PowerManager) |
+ power_manager_client_.reset(PowerManagerClient::Create(type)); |
+ |
+ if (client_mask & SessionManager) |
+ session_manager_client_.reset(SessionManagerClient::Create(type)); |
+ |
+ if (client_mask & SMS) |
+ sms_client_.reset(SMSClient::Create()); |
+ |
+ if (client_mask & SystemClock) |
+ system_clock_client_.reset(SystemClockClient::Create()); |
+ |
+ if (client_mask & UpdateEngine) |
+ update_engine_client_.reset(UpdateEngineClient::Create(type)); |
} |
BluetoothAdapterClient* bluetooth_adapter_client() { |
@@ -261,7 +333,7 @@ class DBusClientBundle { |
// The DBusThreadManager implementation used in production. |
class DBusThreadManagerImpl : public DBusThreadManager { |
public: |
- DBusThreadManagerImpl() { |
+ explicit DBusThreadManagerImpl(int client_mask) : client_mask_(client_mask) { |
satorux1
2014/08/07 20:00:05
please document |client_mask|
|
// Create the D-Bus thread. |
base::Thread::Options thread_options; |
thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
@@ -462,7 +534,7 @@ class DBusThreadManagerImpl : public DBusThreadManager { |
// Constructs all clients and stores them in the respective *_client_ member |
// variable. |
void CreateDefaultClients() { |
- client_bundle_.reset(new DBusClientBundle); |
+ client_bundle_.reset(new DBusClientBundle(client_mask_)); |
power_policy_controller_.reset(new PowerPolicyController); |
} |
@@ -474,10 +546,290 @@ class DBusThreadManagerImpl : public DBusThreadManager { |
scoped_refptr<dbus::Bus> system_bus_; |
scoped_ptr<DBusClientBundle> client_bundle_; |
scoped_ptr<PowerPolicyController> power_policy_controller_; |
+ int client_mask_; |
DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerImpl); |
}; |
+class MixedDBusThreadManager : public DBusThreadManager { |
satorux1
2014/08/07 20:00:05
Class comment is missing.
zel
2014/08/07 21:40:44
Done.
|
+ public: |
+ explicit MixedDBusThreadManager(const std::string& unstub_list) { |
+ ParseUnstubList(unstub_list); |
+ real_thread_manager_.reset( |
+ new DBusThreadManagerImpl(unstub_mask_)); |
+ FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; |
+ fake_dbus_thread_manager->SetFakeClients(); |
+ fake_thread_manager_.reset(fake_dbus_thread_manager); |
+ } |
+ |
+ virtual ~MixedDBusThreadManager() { |
+ } |
+ |
+ private: |
+ static DBusClientBundle::DBusClientType GetDBusClientType( |
satorux1
2014/08/07 20:00:05
function comment is missing.
zel
2014/08/07 21:40:44
Done.
|
+ const std::string& client_type); |
+ |
+ void ParseUnstubList(const std::string& unstub_list) { |
satorux1
2014/08/07 20:00:05
function comment is missing.
zel
2014/08/07 21:40:45
Done.
|
+ unstub_mask_ = 0; |
+ std::vector<std::string> unstub_components; |
+ base::SplitString(unstub_list, ',', &unstub_components); |
+ for (std::vector<std::string>::const_iterator iter = |
+ unstub_components.begin(); |
+ iter != unstub_components.end(); ++iter) { |
+ DBusClientBundle::DBusClientType client = GetDBusClientType(*iter); |
+ if (client != DBusClientBundle::Unknown) { |
+ LOG(WARNING) << "Unstubbing dbus client for " << *iter; |
+ unstub_mask_ |= client; |
satorux1
2014/08/07 20:00:05
instead of modifying unstub_mask_ directly, return
zel
2014/08/07 23:16:17
Done.
|
+ } |
+ } |
+ |
+ // We should have something parsed correctly here. |
+ if (unstub_mask_ == 0) { |
+ LOG(FATAL) << "Switch values for --" |
+ << chromeos::switches::kDbusUnstubClients |
+ << " cannot be parsed: " |
+ << unstub_list; |
+ } |
+ } |
+ |
+ // DBusThreadManager overrides. |
+ virtual void AddObserver(DBusThreadManagerObserver* observer) OVERRIDE { |
+ real_thread_manager_->AddObserver(observer); |
+ } |
+ |
+ virtual void RemoveObserver(DBusThreadManagerObserver* observer) OVERRIDE { |
+ real_thread_manager_->RemoveObserver(observer); |
+ } |
+ |
+ virtual dbus::Bus* GetSystemBus() OVERRIDE { |
+ return real_thread_manager_->GetSystemBus(); |
+ } |
+ |
+ virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::Bluetooth)->GetBluetoothAdapterClient(); |
+ } |
+ |
+ virtual BluetoothAgentManagerClient* |
+ GetBluetoothAgentManagerClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::Bluetooth)->GetBluetoothAgentManagerClient(); |
+ } |
+ |
+ virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::Bluetooth)->GetBluetoothDeviceClient(); |
+ } |
+ |
+ virtual BluetoothGattCharacteristicClient* |
+ GetBluetoothGattCharacteristicClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::Bluetooth)->GetBluetoothGattCharacteristicClient(); |
+ } |
+ |
+ virtual BluetoothGattDescriptorClient* |
+ GetBluetoothGattDescriptorClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::BluetoothLowEnergy)-> |
+ GetBluetoothGattDescriptorClient(); |
+ } |
+ |
+ virtual BluetoothGattManagerClient* GetBluetoothGattManagerClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::BluetoothLowEnergy)->GetBluetoothGattManagerClient(); |
+ } |
+ |
+ virtual BluetoothGattServiceClient* GetBluetoothGattServiceClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::BluetoothLowEnergy)->GetBluetoothGattServiceClient(); |
+ } |
+ |
+ virtual BluetoothInputClient* GetBluetoothInputClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::Bluetooth)->GetBluetoothInputClient(); |
+ } |
+ |
+ virtual BluetoothProfileManagerClient* |
+ GetBluetoothProfileManagerClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::Bluetooth)->GetBluetoothProfileManagerClient(); |
+ } |
+ |
+ virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::Cras)->GetCrasAudioClient(); |
+ } |
+ |
+ virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::CrosDisks)->GetCrosDisksClient(); |
+ } |
+ |
+ virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::Cryptohome)->GetCryptohomeClient(); |
+ } |
+ |
+ virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::DebugDaemon)->GetDebugDaemonClient(); |
+ } |
+ |
+ virtual EasyUnlockClient* GetEasyUnlockClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::EasyUnlock)->GetEasyUnlockClient(); |
+ } |
+ |
+ virtual LorgnetteManagerClient* GetLorgnetteManagerClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::LorgnetteManager)->GetLorgnetteManagerClient(); |
+ } |
+ |
+ virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Shill)->GetShillDeviceClient(); |
+ } |
+ |
+ virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Shill)->GetShillIPConfigClient(); |
+ } |
+ |
+ virtual ShillManagerClient* GetShillManagerClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Shill)->GetShillManagerClient(); |
+ } |
+ |
+ virtual ShillProfileClient* GetShillProfileClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Shill)->GetShillProfileClient(); |
+ } |
+ |
+ virtual ShillServiceClient* GetShillServiceClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Shill)->GetShillServiceClient(); |
+ } |
+ |
+ virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::GsmSMS)->GetGsmSMSClient(); |
+ } |
+ |
+ virtual ImageBurnerClient* GetImageBurnerClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::ImageBurner)->GetImageBurnerClient(); |
+ } |
+ |
+ virtual IntrospectableClient* GetIntrospectableClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::ImageBurner)->GetIntrospectableClient(); |
+ } |
+ |
+ virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::ModemMessaging)->GetModemMessagingClient(); |
+ } |
+ |
+ virtual NfcAdapterClient* GetNfcAdapterClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Nfc)->GetNfcAdapterClient(); |
+ } |
+ |
+ virtual NfcDeviceClient* GetNfcDeviceClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Nfc)->GetNfcDeviceClient(); |
+ } |
+ |
+ virtual NfcManagerClient* GetNfcManagerClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Nfc)->GetNfcManagerClient(); |
+ } |
+ |
+ virtual NfcRecordClient* GetNfcRecordClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Nfc)->GetNfcRecordClient(); |
+ } |
+ |
+ virtual NfcTagClient* GetNfcTagClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::Nfc)->GetNfcTagClient(); |
+ } |
+ |
+ virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::PermissionBroker)->GetPermissionBrokerClient(); |
+ } |
+ |
+ virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::PowerManager)->GetPowerManagerClient(); |
+ } |
+ |
+ virtual PowerPolicyController* GetPowerPolicyController() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::PowerPolicy)->GetPowerPolicyController(); |
+ } |
+ |
+ virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::SessionManager)->GetSessionManagerClient(); |
+ } |
+ |
+ virtual SMSClient* GetSMSClient() OVERRIDE { |
+ return GetThreadManager(DBusClientBundle::SMS)->GetSMSClient(); |
+ } |
+ |
+ virtual SystemClockClient* GetSystemClockClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::SystemClock)->GetSystemClockClient(); |
+ } |
+ |
+ virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { |
+ return GetThreadManager( |
+ DBusClientBundle::UpdateEngine)->GetUpdateEngineClient(); |
+ } |
+ |
+ private: |
+ DBusThreadManager* GetThreadManager(DBusClientBundle::DBusClientType client) { |
+ if (unstub_mask_ & client) |
+ return real_thread_manager_.get(); |
+ |
+ return fake_thread_manager_.get(); |
+ } |
+ |
+ scoped_ptr<DBusThreadManager> fake_thread_manager_; |
+ scoped_ptr<DBusThreadManager> real_thread_manager_; |
+ int unstub_mask_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MixedDBusThreadManager); |
+}; |
+ |
+// Command line switch mapping for --dbus-unstub-clients. |
+struct { |
+ const char* param_name; |
+ DBusClientBundle::DBusClientType client_type; |
+} client_type_map[] = { |
+ { "bluetooth", DBusClientBundle::Bluetooth }, |
+ { "bluetoothlowenergy", DBusClientBundle::BluetoothLowEnergy }, |
+ { "cras", DBusClientBundle::Cras }, |
+ { "crosdisks", DBusClientBundle::CrosDisks }, |
+ { "cryptohome", DBusClientBundle::Cryptohome }, |
+ { "debugdaemon", DBusClientBundle::DebugDaemon }, |
+ { "easyunlock", DBusClientBundle::EasyUnlock }, |
+ { "lorgnettemanager", DBusClientBundle::LorgnetteManager }, |
+ { "shill", DBusClientBundle::Shill }, |
+ { "gsmsms", DBusClientBundle::GsmSMS }, |
+ { "imageburner", DBusClientBundle::ImageBurner }, |
+ { "introspectable", DBusClientBundle::Introspectable }, |
+ { "modemmessaging", DBusClientBundle::ModemMessaging }, |
+ { "nfc", DBusClientBundle::Nfc }, |
+ { "permissionbroker", DBusClientBundle::PermissionBroker }, |
+ { "powermanager", DBusClientBundle::PowerManager }, |
+ { "powerpolicy", DBusClientBundle::PowerPolicy }, |
+ { "sessionmanager", DBusClientBundle::SessionManager }, |
+ { "sms", DBusClientBundle::SMS }, |
+ { "systemclock", DBusClientBundle::SystemClock }, |
+ { "updateengine", DBusClientBundle::UpdateEngine }, |
+}; |
+ |
stevenjb
2014/08/07 20:20:31
This class is large enough that we should really p
zel
2014/08/07 21:40:44
so does DBusClientBundle... done.
|
+// static |
+DBusClientBundle::DBusClientType |
+MixedDBusThreadManager::GetDBusClientType(const std::string& client_type) { |
stevenjb
2014/08/07 20:20:31
This looks like it could just be a local helper fu
|
+ for (size_t i = 0; i < arraysize(client_type_map); i++) { |
+ if (LowerCaseEqualsASCII(client_type, client_type_map[i].param_name)) |
+ return client_type_map[i].client_type; |
+ } |
+ return DBusClientBundle::Unknown; |
+} |
+ |
+ |
// static |
void DBusThreadManager::Initialize() { |
// If we initialize DBusThreadManager twice we may also be shutting it down |
@@ -491,15 +843,24 @@ void DBusThreadManager::Initialize() { |
return; |
} |
- // Determine whether we use stub or real client implementations. |
- if (!base::SysInfo::IsRunningOnChromeOS() || |
+ bool use_dbus_stub = !base::SysInfo::IsRunningOnChromeOS() || |
CommandLine::ForCurrentProcess()->HasSwitch( |
- chromeos::switches::kDbusStub)) { |
- InitializeWithStub(); |
+ chromeos::switches::kDbusStub); |
+ bool force_bluetooth_client = CommandLine::ForCurrentProcess()->HasSwitch( |
satorux1
2014/08/07 20:00:05
force_bluetooth_client -> unstub_clients ?
zel
2014/08/07 21:40:44
Done.
|
+ chromeos::switches::kDbusUnstubClients); |
+ // Determine whether we use stub or real client implementations. |
+ if (!use_dbus_stub || force_bluetooth_client) { |
+ if (!use_dbus_stub) { |
satorux1
2014/08/07 20:00:05
slightly easier to read with:
if (unstub_clients)
zel
2014/08/07 21:40:44
Done.
|
+ g_dbus_thread_manager = new DBusThreadManagerImpl(DBusClientBundle::All); |
+ InitializeClients(); |
+ VLOG(1) << "DBusThreadManager initialized for Chrome OS"; |
+ } else { |
+ InitializeWithPartialStub( |
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
+ chromeos::switches::kDbusUnstubClients)); |
+ } |
} else { |
- g_dbus_thread_manager = new DBusThreadManagerImpl; |
- InitializeClients(); |
- VLOG(1) << "DBusThreadManager initialized for Chrome OS"; |
+ InitializeWithStub(); |
} |
} |
@@ -519,6 +880,18 @@ void DBusThreadManager::InitializeForTesting( |
} |
// static |
+void DBusThreadManager::InitializeWithPartialStub( |
+ const std::string& unstub_clients) { |
+ // If we initialize DBusThreadManager twice we may also be shutting it down |
+ // early; do not allow that. |
+ CHECK(g_dbus_thread_manager == NULL); |
+ |
+ VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; |
+ g_dbus_thread_manager = new MixedDBusThreadManager(unstub_clients); |
+ InitializeClients(); |
+} |
+ |
+// static |
void DBusThreadManager::InitializeWithStub() { |
// If we initialize DBusThreadManager twice we may also be shutting it down |
// early; do not allow that. |