Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/dbus/dbus_thread_manager.h" | 5 #include "chromeos/dbus/dbus_thread_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
| 11 #include "chromeos/dbus/bluetooth_adapter_client.h" | 11 #include "chromeos/dbus/bluetooth_adapter_client.h" |
| 12 #include "chromeos/dbus/bluetooth_agent_manager_client.h" | 12 #include "chromeos/dbus/bluetooth_agent_manager_client.h" |
| 13 #include "chromeos/dbus/bluetooth_device_client.h" | 13 #include "chromeos/dbus/bluetooth_device_client.h" |
| 14 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" | 14 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" |
| 15 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" | 15 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" |
| 16 #include "chromeos/dbus/bluetooth_gatt_manager_client.h" | 16 #include "chromeos/dbus/bluetooth_gatt_manager_client.h" |
| 17 #include "chromeos/dbus/bluetooth_gatt_service_client.h" | 17 #include "chromeos/dbus/bluetooth_gatt_service_client.h" |
| 18 #include "chromeos/dbus/bluetooth_input_client.h" | 18 #include "chromeos/dbus/bluetooth_input_client.h" |
| 19 #include "chromeos/dbus/bluetooth_profile_manager_client.h" | 19 #include "chromeos/dbus/bluetooth_profile_manager_client.h" |
| 20 #include "chromeos/dbus/cras_audio_client.h" | 20 #include "chromeos/dbus/cras_audio_client.h" |
| 21 #include "chromeos/dbus/cros_disks_client.h" | 21 #include "chromeos/dbus/cros_disks_client.h" |
| 22 #include "chromeos/dbus/cryptohome_client.h" | 22 #include "chromeos/dbus/cryptohome_client.h" |
| 23 #include "chromeos/dbus/dbus_client.h" | 23 #include "chromeos/dbus/dbus_client.h" |
| 24 #include "chromeos/dbus/dbus_client_bundle.h" | 24 #include "chromeos/dbus/dbus_client_bundle.h" |
| 25 #include "chromeos/dbus/debug_daemon_client.h" | 25 #include "chromeos/dbus/debug_daemon_client.h" |
| 26 #include "chromeos/dbus/easy_unlock_client.h" | 26 #include "chromeos/dbus/easy_unlock_client.h" |
| 27 #include "chromeos/dbus/fake_dbus_thread_manager.h" | |
| 28 #include "chromeos/dbus/gsm_sms_client.h" | 27 #include "chromeos/dbus/gsm_sms_client.h" |
| 29 #include "chromeos/dbus/image_burner_client.h" | 28 #include "chromeos/dbus/image_burner_client.h" |
| 30 #include "chromeos/dbus/introspectable_client.h" | 29 #include "chromeos/dbus/introspectable_client.h" |
| 31 #include "chromeos/dbus/lorgnette_manager_client.h" | 30 #include "chromeos/dbus/lorgnette_manager_client.h" |
| 32 #include "chromeos/dbus/modem_messaging_client.h" | 31 #include "chromeos/dbus/modem_messaging_client.h" |
| 33 #include "chromeos/dbus/nfc_adapter_client.h" | 32 #include "chromeos/dbus/nfc_adapter_client.h" |
| 34 #include "chromeos/dbus/nfc_device_client.h" | 33 #include "chromeos/dbus/nfc_device_client.h" |
| 35 #include "chromeos/dbus/nfc_manager_client.h" | 34 #include "chromeos/dbus/nfc_manager_client.h" |
| 36 #include "chromeos/dbus/nfc_record_client.h" | 35 #include "chromeos/dbus/nfc_record_client.h" |
| 37 #include "chromeos/dbus/nfc_tag_client.h" | 36 #include "chromeos/dbus/nfc_tag_client.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 51 #include "dbus/dbus_statistics.h" | 50 #include "dbus/dbus_statistics.h" |
| 52 | 51 |
| 53 namespace chromeos { | 52 namespace chromeos { |
| 54 | 53 |
| 55 static DBusThreadManager* g_dbus_thread_manager = NULL; | 54 static DBusThreadManager* g_dbus_thread_manager = NULL; |
| 56 static DBusThreadManager* g_dbus_thread_manager_for_testing = NULL; | 55 static DBusThreadManager* g_dbus_thread_manager_for_testing = NULL; |
| 57 | 56 |
| 58 DBusClientBundle::DBusClientTypeMask | 57 DBusClientBundle::DBusClientTypeMask |
| 59 DBusThreadManager::unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; | 58 DBusThreadManager::unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; |
| 60 | 59 |
| 61 // The DBusThreadManager implementation used in production. | 60 DBusThreadManager::DBusThreadManager() { |
| 62 class DBusThreadManagerImpl : public DBusThreadManager { | 61 dbus::statistics::Initialize(); |
| 63 public: | 62 if (!DBusThreadManager::IsUsingStub(DBusClientBundle::ALL_CLIENTS)) { |
| 64 DBusThreadManagerImpl() { | |
| 65 // Create the D-Bus thread. | 63 // Create the D-Bus thread. |
| 66 base::Thread::Options thread_options; | 64 base::Thread::Options thread_options; |
| 67 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 65 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 68 dbus_thread_.reset(new base::Thread("D-Bus thread")); | 66 dbus_thread_.reset(new base::Thread("D-Bus thread")); |
| 69 dbus_thread_->StartWithOptions(thread_options); | 67 dbus_thread_->StartWithOptions(thread_options); |
| 70 | 68 |
| 71 // Create the connection to the system bus. | 69 // Create the connection to the system bus. |
| 72 dbus::Bus::Options system_bus_options; | 70 dbus::Bus::Options system_bus_options; |
| 73 system_bus_options.bus_type = dbus::Bus::SYSTEM; | 71 system_bus_options.bus_type = dbus::Bus::SYSTEM; |
| 74 system_bus_options.connection_type = dbus::Bus::PRIVATE; | 72 system_bus_options.connection_type = dbus::Bus::PRIVATE; |
| 75 system_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); | 73 system_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); |
| 76 system_bus_ = new dbus::Bus(system_bus_options); | 74 system_bus_ = new dbus::Bus(system_bus_options); |
| 77 | |
| 78 CreateDefaultClients(); | |
| 79 } | 75 } |
| 80 | 76 |
| 81 virtual ~DBusThreadManagerImpl() { | 77 CreateDefaultClients(); |
| 82 // PowerPolicyController's destructor depends on PowerManagerClient. | 78 } |
| 83 power_policy_controller_.reset(); | 79 |
| 84 | 80 DBusThreadManager::~DBusThreadManager() { |
| 85 // Delete all D-Bus clients before shutting down the system bus. | 81 // PowerPolicyController's destructor depends on PowerManagerClient. |
| 86 client_bundle_.reset(); | 82 power_policy_controller_.reset(); |
| 87 | 83 |
| 88 // Shut down the bus. During the browser shutdown, it's ok to shut down | 84 // Delete all D-Bus clients before shutting down the system bus. |
| 89 // the bus synchronously. | 85 client_bundle_.reset(); |
| 86 | |
| 87 // Shut down the bus. During the browser shutdown, it's ok to shut down | |
| 88 // the bus synchronously. | |
| 89 if (system_bus_) | |
| 90 system_bus_->ShutdownOnDBusThreadAndBlock(); | 90 system_bus_->ShutdownOnDBusThreadAndBlock(); |
| 91 | 91 |
| 92 // Stop the D-Bus thread. | 92 // Stop the D-Bus thread. |
| 93 if (dbus_thread_) | |
| 93 dbus_thread_->Stop(); | 94 dbus_thread_->Stop(); |
| 95 | |
| 96 dbus::statistics::Shutdown(); | |
| 97 | |
| 98 if (g_dbus_thread_manager == NULL) | |
| 99 return; // Called form Shutdown() or local test instance. | |
| 100 | |
| 101 // There should never be both a global instance and a local instance. | |
| 102 CHECK(this == g_dbus_thread_manager); | |
| 103 if (g_dbus_thread_manager_for_testing) { | |
| 104 g_dbus_thread_manager = NULL; | |
| 105 g_dbus_thread_manager_for_testing = NULL; | |
| 106 VLOG(1) << "DBusThreadManager destroyed"; | |
| 107 } else { | |
| 108 LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()"; | |
| 94 } | 109 } |
| 95 | 110 } |
| 96 void SetupDefaultEnvironment() { | 111 |
| 97 return client_bundle_->SetupDefaultEnvironment(); | 112 // static |
| 98 } | 113 DBusThreadManager* DBusThreadManager::CreateInstance() { |
|
hashimoto
2014/08/25 06:56:20
Is this method needed?
Can't InitializeClients() b
zel
2014/08/25 17:21:42
Done.
zel
2014/08/25 20:19:47
I take this back since it had broken tons of tests
| |
| 99 | 114 DBusThreadManager* dbus_thread_manager = new DBusThreadManager(); |
| 100 virtual dbus::Bus* GetSystemBus() OVERRIDE { | 115 dbus_thread_manager->InitializeClients(); |
| 101 return system_bus_.get(); | 116 return dbus_thread_manager; |
| 102 } | 117 } |
| 103 | 118 |
| 104 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { | 119 dbus::Bus* DBusThreadManager::GetSystemBus() { |
| 105 return client_bundle_->bluetooth_adapter_client(); | 120 return system_bus_.get(); |
| 106 } | 121 } |
| 107 | 122 |
| 108 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() | 123 BluetoothAdapterClient* DBusThreadManager::GetBluetoothAdapterClient() { |
| 109 OVERRIDE { | 124 return client_bundle_->bluetooth_adapter_client(); |
| 110 return client_bundle_->bluetooth_agent_manager_client(); | 125 } |
| 111 } | 126 |
| 112 | 127 BluetoothAgentManagerClient* |
| 113 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { | 128 DBusThreadManager::GetBluetoothAgentManagerClient() { |
| 114 return client_bundle_->bluetooth_device_client(); | 129 return client_bundle_->bluetooth_agent_manager_client(); |
| 115 } | 130 } |
| 116 | 131 |
| 117 virtual BluetoothGattCharacteristicClient* | 132 BluetoothDeviceClient* DBusThreadManager::GetBluetoothDeviceClient() { |
| 118 GetBluetoothGattCharacteristicClient() OVERRIDE { | 133 return client_bundle_->bluetooth_device_client(); |
| 119 return client_bundle_->bluetooth_gatt_characteristic_client(); | 134 } |
| 120 } | 135 |
| 121 | 136 BluetoothGattCharacteristicClient* |
| 122 virtual BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient() | 137 DBusThreadManager::GetBluetoothGattCharacteristicClient() { |
| 123 OVERRIDE { | 138 return client_bundle_->bluetooth_gatt_characteristic_client(); |
| 124 return client_bundle_->bluetooth_gatt_descriptor_client(); | 139 } |
| 125 } | 140 |
| 126 | 141 BluetoothGattDescriptorClient* |
| 127 virtual BluetoothGattManagerClient* GetBluetoothGattManagerClient() OVERRIDE { | 142 DBusThreadManager::GetBluetoothGattDescriptorClient() { |
| 128 return client_bundle_->bluetooth_gatt_manager_client(); | 143 return client_bundle_->bluetooth_gatt_descriptor_client(); |
| 129 } | 144 } |
| 130 | 145 |
| 131 virtual BluetoothGattServiceClient* GetBluetoothGattServiceClient() OVERRIDE { | 146 BluetoothGattManagerClient* |
| 132 return client_bundle_->bluetooth_gatt_service_client(); | 147 DBusThreadManager::GetBluetoothGattManagerClient() { |
| 133 } | 148 return client_bundle_->bluetooth_gatt_manager_client(); |
| 134 | 149 } |
| 135 virtual BluetoothInputClient* GetBluetoothInputClient() OVERRIDE { | 150 |
| 136 return client_bundle_->bluetooth_input_client(); | 151 BluetoothGattServiceClient* |
| 137 } | 152 DBusThreadManager::GetBluetoothGattServiceClient() { |
| 138 | 153 return client_bundle_->bluetooth_gatt_service_client(); |
| 139 virtual BluetoothProfileManagerClient* GetBluetoothProfileManagerClient() | 154 } |
| 140 OVERRIDE { | 155 |
| 141 return client_bundle_->bluetooth_profile_manager_client(); | 156 BluetoothInputClient* DBusThreadManager::GetBluetoothInputClient() { |
| 142 } | 157 return client_bundle_->bluetooth_input_client(); |
| 143 | 158 } |
| 144 virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE { | 159 |
| 145 return client_bundle_->cras_audio_client(); | 160 BluetoothProfileManagerClient* |
| 146 } | 161 DBusThreadManager::GetBluetoothProfileManagerClient() { |
| 147 | 162 return client_bundle_->bluetooth_profile_manager_client(); |
| 148 virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE { | 163 } |
| 149 return client_bundle_->cros_disks_client(); | 164 |
| 150 } | 165 CrasAudioClient* DBusThreadManager::GetCrasAudioClient() { |
| 151 | 166 return client_bundle_->cras_audio_client(); |
| 152 virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE { | 167 } |
| 153 return client_bundle_->cryptohome_client(); | 168 |
| 154 } | 169 CrosDisksClient* DBusThreadManager::GetCrosDisksClient() { |
| 155 | 170 return client_bundle_->cros_disks_client(); |
| 156 virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE { | 171 } |
| 157 return client_bundle_->debug_daemon_client(); | 172 |
| 158 } | 173 CryptohomeClient* DBusThreadManager::GetCryptohomeClient() { |
| 159 | 174 return client_bundle_->cryptohome_client(); |
| 160 virtual EasyUnlockClient* GetEasyUnlockClient() OVERRIDE { | 175 } |
| 161 return client_bundle_->easy_unlock_client(); | 176 |
| 162 } | 177 DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() { |
| 163 virtual LorgnetteManagerClient* GetLorgnetteManagerClient() OVERRIDE { | 178 return client_bundle_->debug_daemon_client(); |
| 164 return client_bundle_->lorgnette_manager_client(); | 179 } |
| 165 } | 180 |
| 166 | 181 EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() { |
| 167 virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE { | 182 return client_bundle_->easy_unlock_client(); |
| 168 return client_bundle_->shill_device_client(); | 183 } |
| 169 } | 184 LorgnetteManagerClient* |
| 170 | 185 DBusThreadManager::GetLorgnetteManagerClient() { |
| 171 virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE { | 186 return client_bundle_->lorgnette_manager_client(); |
| 172 return client_bundle_->shill_ipconfig_client(); | 187 } |
| 173 } | 188 |
| 174 | 189 ShillDeviceClient* |
| 175 virtual ShillManagerClient* GetShillManagerClient() OVERRIDE { | 190 DBusThreadManager::GetShillDeviceClient() { |
| 176 return client_bundle_->shill_manager_client(); | 191 return client_bundle_->shill_device_client(); |
| 177 } | 192 } |
| 178 | 193 |
| 179 virtual ShillServiceClient* GetShillServiceClient() OVERRIDE { | 194 ShillIPConfigClient* |
| 180 return client_bundle_->shill_service_client(); | 195 DBusThreadManager::GetShillIPConfigClient() { |
| 181 } | 196 return client_bundle_->shill_ipconfig_client(); |
| 182 | 197 } |
| 183 virtual ShillProfileClient* GetShillProfileClient() OVERRIDE { | 198 |
| 184 return client_bundle_->shill_profile_client(); | 199 ShillManagerClient* |
| 185 } | 200 DBusThreadManager::GetShillManagerClient() { |
| 186 | 201 return client_bundle_->shill_manager_client(); |
| 187 virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE { | 202 } |
| 188 return client_bundle_->gsm_sms_client(); | 203 |
| 189 } | 204 ShillServiceClient* |
| 190 | 205 DBusThreadManager::GetShillServiceClient() { |
| 191 virtual ImageBurnerClient* GetImageBurnerClient() OVERRIDE { | 206 return client_bundle_->shill_service_client(); |
| 192 return client_bundle_->image_burner_client(); | 207 } |
| 193 } | 208 |
| 194 | 209 ShillProfileClient* |
| 195 virtual IntrospectableClient* GetIntrospectableClient() OVERRIDE { | 210 DBusThreadManager::GetShillProfileClient() { |
| 196 return client_bundle_->introspectable_client(); | 211 return client_bundle_->shill_profile_client(); |
| 197 } | 212 } |
| 198 | 213 |
| 199 virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE { | 214 GsmSMSClient* DBusThreadManager::GetGsmSMSClient() { |
| 200 return client_bundle_->modem_messaging_client(); | 215 return client_bundle_->gsm_sms_client(); |
| 201 } | 216 } |
| 202 | 217 |
| 203 virtual NfcAdapterClient* GetNfcAdapterClient() OVERRIDE { | 218 ImageBurnerClient* DBusThreadManager::GetImageBurnerClient() { |
| 204 return client_bundle_->nfc_adapter_client(); | 219 return client_bundle_->image_burner_client(); |
| 205 } | 220 } |
| 206 | 221 |
| 207 virtual NfcDeviceClient* GetNfcDeviceClient() OVERRIDE { | 222 IntrospectableClient* DBusThreadManager::GetIntrospectableClient() { |
| 208 return client_bundle_->nfc_device_client(); | 223 return client_bundle_->introspectable_client(); |
| 209 } | 224 } |
| 210 | 225 |
| 211 virtual NfcManagerClient* GetNfcManagerClient() OVERRIDE { | 226 ModemMessagingClient* DBusThreadManager::GetModemMessagingClient() { |
| 212 return client_bundle_->nfc_manager_client(); | 227 return client_bundle_->modem_messaging_client(); |
| 213 } | 228 } |
| 214 | 229 |
| 215 virtual NfcRecordClient* GetNfcRecordClient() OVERRIDE { | 230 NfcAdapterClient* DBusThreadManager::GetNfcAdapterClient() { |
| 216 return client_bundle_->nfc_record_client(); | 231 return client_bundle_->nfc_adapter_client(); |
| 217 } | 232 } |
| 218 | 233 |
| 219 virtual NfcTagClient* GetNfcTagClient() OVERRIDE { | 234 NfcDeviceClient* DBusThreadManager::GetNfcDeviceClient() { |
| 220 return client_bundle_->nfc_tag_client(); | 235 return client_bundle_->nfc_device_client(); |
| 221 } | 236 } |
| 222 | 237 |
| 223 virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE { | 238 NfcManagerClient* DBusThreadManager::GetNfcManagerClient() { |
| 224 return client_bundle_->permission_broker_client(); | 239 return client_bundle_->nfc_manager_client(); |
| 225 } | 240 } |
| 226 | 241 |
| 227 virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE { | 242 NfcRecordClient* DBusThreadManager::GetNfcRecordClient() { |
| 228 return client_bundle_->power_manager_client(); | 243 return client_bundle_->nfc_record_client(); |
| 229 } | 244 } |
| 230 | 245 |
| 231 virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE { | 246 NfcTagClient* DBusThreadManager::GetNfcTagClient() { |
| 232 return client_bundle_->session_manager_client(); | 247 return client_bundle_->nfc_tag_client(); |
| 233 } | 248 } |
| 234 | 249 |
| 235 virtual SMSClient* GetSMSClient() OVERRIDE { | 250 PermissionBrokerClient* DBusThreadManager::GetPermissionBrokerClient() { |
| 236 return client_bundle_->sms_client(); | 251 return client_bundle_->permission_broker_client(); |
| 237 } | 252 } |
| 238 | 253 |
| 239 virtual SystemClockClient* GetSystemClockClient() OVERRIDE { | 254 PowerManagerClient* DBusThreadManager::GetPowerManagerClient() { |
| 240 return client_bundle_->system_clock_client(); | 255 return client_bundle_->power_manager_client(); |
| 241 } | 256 } |
| 242 | 257 |
| 243 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { | 258 SessionManagerClient* DBusThreadManager::GetSessionManagerClient() { |
| 244 return client_bundle_->update_engine_client(); | 259 return client_bundle_->session_manager_client(); |
| 245 } | 260 } |
| 246 | 261 |
| 247 virtual PowerPolicyController* GetPowerPolicyController() OVERRIDE { | 262 SMSClient* DBusThreadManager::GetSMSClient() { |
| 248 return power_policy_controller_.get(); | 263 return client_bundle_->sms_client(); |
| 249 } | 264 } |
| 250 | 265 |
| 251 private: | 266 SystemClockClient* DBusThreadManager::GetSystemClockClient() { |
| 252 // Constructs all clients and stores them in the respective *_client_ member | 267 return client_bundle_->system_clock_client(); |
| 253 // variable. | 268 } |
| 254 void CreateDefaultClients() { | 269 |
| 255 client_bundle_.reset(new DBusClientBundle()); | 270 UpdateEngineClient* DBusThreadManager::GetUpdateEngineClient() { |
| 256 // TODO(crbug.com/345586): Move PowerPolicyController out of | 271 return client_bundle_->update_engine_client(); |
| 257 // DBusThreadManagerImpl. | 272 } |
| 258 power_policy_controller_.reset(new PowerPolicyController); | 273 |
| 259 } | 274 PowerPolicyController* DBusThreadManager::GetPowerPolicyController() { |
| 260 | 275 return power_policy_controller_.get(); |
| 261 scoped_ptr<base::Thread> dbus_thread_; | 276 } |
| 262 scoped_refptr<dbus::Bus> system_bus_; | 277 |
| 263 scoped_ptr<DBusClientBundle> client_bundle_; | 278 void DBusThreadManager::CreateDefaultClients() { |
| 264 scoped_ptr<PowerPolicyController> power_policy_controller_; | 279 client_bundle_.reset(new DBusClientBundle()); |
| 265 | 280 // TODO(crbug.com/345586): Move PowerPolicyController out of |
| 266 DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerImpl); | 281 // DBusThreadManager. |
| 267 }; | 282 power_policy_controller_.reset(new PowerPolicyController); |
| 283 } | |
| 284 | |
| 285 void DBusThreadManager::InitializeClients() { | |
| 286 GetBluetoothAdapterClient()->Init(GetSystemBus()); | |
| 287 GetBluetoothAgentManagerClient()->Init(GetSystemBus()); | |
| 288 GetBluetoothDeviceClient()->Init(GetSystemBus()); | |
| 289 GetBluetoothGattCharacteristicClient()->Init(GetSystemBus()); | |
| 290 GetBluetoothGattDescriptorClient()->Init(GetSystemBus()); | |
| 291 GetBluetoothGattManagerClient()->Init(GetSystemBus()); | |
| 292 GetBluetoothGattServiceClient()->Init(GetSystemBus()); | |
| 293 GetBluetoothInputClient()->Init(GetSystemBus()); | |
| 294 GetBluetoothProfileManagerClient()->Init(GetSystemBus()); | |
| 295 GetCrasAudioClient()->Init(GetSystemBus()); | |
| 296 GetCrosDisksClient()->Init(GetSystemBus()); | |
| 297 GetCryptohomeClient()->Init(GetSystemBus()); | |
| 298 GetDebugDaemonClient()->Init(GetSystemBus()); | |
| 299 GetEasyUnlockClient()->Init(GetSystemBus()); | |
| 300 GetGsmSMSClient()->Init(GetSystemBus()); | |
| 301 GetImageBurnerClient()->Init(GetSystemBus()); | |
| 302 GetIntrospectableClient()->Init(GetSystemBus()); | |
| 303 GetLorgnetteManagerClient()->Init(GetSystemBus()); | |
| 304 GetModemMessagingClient()->Init(GetSystemBus()); | |
| 305 GetPermissionBrokerClient()->Init(GetSystemBus()); | |
| 306 GetPowerManagerClient()->Init(GetSystemBus()); | |
| 307 GetSessionManagerClient()->Init(GetSystemBus()); | |
| 308 GetShillDeviceClient()->Init(GetSystemBus()); | |
| 309 GetShillIPConfigClient()->Init(GetSystemBus()); | |
| 310 GetShillManagerClient()->Init(GetSystemBus()); | |
| 311 GetShillServiceClient()->Init(GetSystemBus()); | |
| 312 GetShillProfileClient()->Init(GetSystemBus()); | |
| 313 GetSMSClient()->Init(GetSystemBus()); | |
| 314 GetSystemClockClient()->Init(GetSystemBus()); | |
| 315 GetUpdateEngineClient()->Init(GetSystemBus()); | |
| 316 | |
| 317 // Initialize the NFC clients in the correct order. The order of | |
| 318 // initialization matters due to dependencies that exist between the | |
| 319 // client objects. | |
| 320 GetNfcManagerClient()->Init(GetSystemBus()); | |
| 321 GetNfcAdapterClient()->Init(GetSystemBus()); | |
| 322 GetNfcDeviceClient()->Init(GetSystemBus()); | |
| 323 GetNfcTagClient()->Init(GetSystemBus()); | |
| 324 GetNfcRecordClient()->Init(GetSystemBus()); | |
| 325 | |
| 326 // PowerPolicyController is dependent on PowerManagerClient, so | |
| 327 // initialize it after the main list of clients. | |
| 328 if (GetPowerPolicyController()) | |
| 329 GetPowerPolicyController()->Init(this); | |
| 330 | |
| 331 // This must be called after the list of clients so they've each had a | |
| 332 // chance to register with their object g_dbus_thread_managers. | |
| 333 if (GetSystemBus()) | |
| 334 GetSystemBus()->GetManagedObjects(); | |
| 335 | |
| 336 client_bundle_->SetupDefaultEnvironment(); | |
| 337 } | |
| 268 | 338 |
| 269 // static | 339 // static |
| 270 bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) { | 340 bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) { |
| 271 return !(unstub_client_mask_ & client); | 341 return !(unstub_client_mask_ & client); |
| 272 } | 342 } |
| 273 | 343 |
| 274 // static | 344 // static |
| 275 void DBusThreadManager::Initialize() { | 345 void DBusThreadManager::Initialize() { |
| 276 // If we initialize DBusThreadManager twice we may also be shutting it down | 346 // If we initialize DBusThreadManager twice we may also be shutting it down |
| 277 // early; do not allow that. | 347 // early; do not allow that. |
| 348 if (g_dbus_thread_manager_for_testing) | |
|
hashimoto
2014/08/25 06:56:20
Why is this line needed?
Even tests should not cal
zel
2014/08/25 17:21:42
Nope - it's still needed. All browser_tests would
| |
| 349 return; | |
| 350 | |
| 278 CHECK(g_dbus_thread_manager == NULL); | 351 CHECK(g_dbus_thread_manager == NULL); |
| 279 | |
| 280 if (g_dbus_thread_manager_for_testing) { | |
| 281 g_dbus_thread_manager = g_dbus_thread_manager_for_testing; | |
| 282 InitializeClients(); | |
| 283 VLOG(1) << "DBusThreadManager initialized with test implementation"; | |
| 284 return; | |
| 285 } | |
| 286 | |
| 287 bool use_dbus_stub = !base::SysInfo::IsRunningOnChromeOS() || | 352 bool use_dbus_stub = !base::SysInfo::IsRunningOnChromeOS() || |
| 288 CommandLine::ForCurrentProcess()->HasSwitch( | 353 CommandLine::ForCurrentProcess()->HasSwitch( |
| 289 chromeos::switches::kDbusStub); | 354 chromeos::switches::kDbusStub); |
| 290 bool force_unstub_clients = CommandLine::ForCurrentProcess()->HasSwitch( | 355 bool force_unstub_clients = CommandLine::ForCurrentProcess()->HasSwitch( |
| 291 chromeos::switches::kDbusUnstubClients); | 356 chromeos::switches::kDbusUnstubClients); |
| 292 // Determine whether we use stub or real client implementations. | 357 // Determine whether we use stub or real client implementations. |
| 293 if (force_unstub_clients) { | 358 if (force_unstub_clients) { |
| 294 InitializeWithPartialStub( | 359 InitializeWithPartialStub( |
| 295 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 360 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 296 chromeos::switches::kDbusUnstubClients)); | 361 chromeos::switches::kDbusUnstubClients)); |
| 297 } else if (use_dbus_stub) { | 362 } else if (use_dbus_stub) { |
| 298 InitializeWithStub(); | 363 InitializeForTesting(); |
| 299 } else { | 364 } else { |
| 300 InitializeRegular(); | 365 InitializeRegular(); |
| 301 } | 366 } |
| 302 } | 367 } |
| 303 | 368 |
| 304 // static | 369 // static |
| 305 void DBusThreadManager::SetInstanceForTesting( | 370 scoped_ptr<DBusThreadManagerTestHelper> |
| 306 DBusThreadManager* dbus_thread_manager) { | 371 DBusThreadManager::GetDBusThreadManagerTestHelper() { |
| 307 CHECK(!g_dbus_thread_manager); | 372 if (!g_dbus_thread_manager_for_testing) |
|
hashimoto
2014/08/25 06:56:20
Why is this line needed?
Tests should be responsib
zel
2014/08/25 17:21:42
First, InitializeForTesting() was made private so
| |
| 308 CHECK(!g_dbus_thread_manager_for_testing); | 373 InitializeForTesting(); |
| 309 g_dbus_thread_manager_for_testing = dbus_thread_manager; | |
| 310 } | |
| 311 | 374 |
| 312 // static | 375 return make_scoped_ptr(new DBusThreadManagerTestHelper()); |
| 313 void DBusThreadManager::InitializeForTesting( | |
| 314 DBusThreadManager* dbus_thread_manager) { | |
| 315 unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; | |
| 316 SetInstanceForTesting(dbus_thread_manager); | |
| 317 Initialize(); | |
| 318 } | 376 } |
| 319 | 377 |
| 320 // static | 378 // static |
| 321 void DBusThreadManager::InitializeRegular() { | 379 void DBusThreadManager::InitializeRegular() { |
| 322 unstub_client_mask_ = DBusClientBundle::ALL_CLIENTS; | 380 unstub_client_mask_ = DBusClientBundle::ALL_CLIENTS; |
| 323 g_dbus_thread_manager = new DBusThreadManagerImpl(); | 381 g_dbus_thread_manager = DBusThreadManager::CreateInstance(); |
| 324 InitializeClients(); | |
| 325 VLOG(1) << "DBusThreadManager initialized for Chrome OS"; | 382 VLOG(1) << "DBusThreadManager initialized for Chrome OS"; |
| 326 } | 383 } |
| 327 | 384 |
| 328 // static | 385 // static |
| 386 void DBusThreadManager::InitializeForTesting() { | |
| 387 CHECK(!g_dbus_thread_manager); | |
| 388 CHECK(!g_dbus_thread_manager_for_testing); | |
| 389 unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; | |
| 390 VLOG(1) << "DBusThreadManager created for testing"; | |
| 391 g_dbus_thread_manager = DBusThreadManager::CreateInstance(); | |
| 392 g_dbus_thread_manager_for_testing = g_dbus_thread_manager; | |
| 393 } | |
| 394 | |
| 395 // static | |
| 329 void DBusThreadManager::InitializeWithPartialStub( | 396 void DBusThreadManager::InitializeWithPartialStub( |
| 330 const std::string& unstub_clients) { | 397 const std::string& unstub_clients) { |
| 331 // If we initialize DBusThreadManager twice we may also be shutting it down | 398 // If we initialize DBusThreadManager twice we may also be shutting it down |
| 332 // early; do not allow that. | 399 // early; do not allow that. |
| 333 CHECK(g_dbus_thread_manager == NULL); | 400 CHECK(g_dbus_thread_manager == NULL); |
| 334 | 401 |
| 335 unstub_client_mask_ = DBusClientBundle::ParseUnstubList(unstub_clients); | 402 unstub_client_mask_ = DBusClientBundle::ParseUnstubList(unstub_clients); |
| 336 // We should have something parsed correctly here. | 403 // We should have something parsed correctly here. |
| 337 if (unstub_client_mask_ == 0) { | 404 if (unstub_client_mask_ == 0) { |
| 338 LOG(FATAL) << "Switch values for --" | 405 LOG(FATAL) << "Switch values for --" |
| 339 << chromeos::switches::kDbusUnstubClients | 406 << chromeos::switches::kDbusUnstubClients |
| 340 << " cannot be parsed: " | 407 << " cannot be parsed: " |
| 341 << unstub_clients; | 408 << unstub_clients; |
| 342 } | 409 } |
| 343 DBusThreadManagerImpl* dbus_thread_manager = new DBusThreadManagerImpl(); | |
| 344 VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; | 410 VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; |
| 345 g_dbus_thread_manager = dbus_thread_manager; | 411 g_dbus_thread_manager = DBusThreadManager::CreateInstance(); |
| 346 InitializeClients(); | |
| 347 dbus_thread_manager->SetupDefaultEnvironment(); | |
| 348 } | 412 } |
| 349 | 413 |
| 350 // static | 414 // static |
| 351 void DBusThreadManager::InitializeWithStub() { | |
| 352 unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; | |
| 353 // If we initialize DBusThreadManager twice we may also be shutting it down | |
| 354 // early; do not allow that. | |
| 355 CHECK(g_dbus_thread_manager == NULL); | |
| 356 FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; | |
| 357 fake_dbus_thread_manager->SetFakeClients(); | |
| 358 g_dbus_thread_manager = fake_dbus_thread_manager; | |
| 359 InitializeClients(); | |
| 360 fake_dbus_thread_manager->SetupDefaultEnvironment(); | |
| 361 VLOG(1) << "DBusThreadManager initialized with stub implementation"; | |
| 362 } | |
| 363 | |
| 364 // static | |
| 365 bool DBusThreadManager::IsInitialized() { | 415 bool DBusThreadManager::IsInitialized() { |
| 366 return g_dbus_thread_manager != NULL; | 416 return g_dbus_thread_manager != NULL; |
| 367 } | 417 } |
| 368 | 418 |
| 369 // static | 419 // static |
| 370 void DBusThreadManager::Shutdown() { | 420 void DBusThreadManager::Shutdown() { |
| 371 // If we called InitializeForTesting, this may get called more than once. | 421 // If we called GetDBusThreadManagerTestHelper(), this may get called more |
|
hashimoto
2014/08/25 06:56:20
Does this comment still make sense?
zel
2014/08/25 17:21:42
Done.
| |
| 422 // than once. | |
| 372 // Ensure that we only shutdown DBusThreadManager once. | 423 // Ensure that we only shutdown DBusThreadManager once. |
| 373 CHECK(g_dbus_thread_manager || g_dbus_thread_manager_for_testing); | 424 CHECK(g_dbus_thread_manager); |
| 374 DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager; | 425 DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager; |
| 375 g_dbus_thread_manager = NULL; | 426 g_dbus_thread_manager = NULL; |
| 376 g_dbus_thread_manager_for_testing = NULL; | 427 g_dbus_thread_manager_for_testing = NULL; |
| 377 delete dbus_thread_manager; | 428 delete dbus_thread_manager; |
| 378 VLOG(1) << "DBusThreadManager Shutdown completed"; | 429 VLOG(1) << "DBusThreadManager Shutdown completed"; |
| 379 } | 430 } |
| 380 | 431 |
| 381 DBusThreadManager::DBusThreadManager() { | |
| 382 dbus::statistics::Initialize(); | |
| 383 } | |
| 384 | |
| 385 DBusThreadManager::~DBusThreadManager() { | |
| 386 dbus::statistics::Shutdown(); | |
| 387 if (g_dbus_thread_manager == NULL) | |
| 388 return; // Called form Shutdown() or local test instance. | |
| 389 // There should never be both a global instance and a local instance. | |
| 390 CHECK(this == g_dbus_thread_manager); | |
| 391 if (g_dbus_thread_manager_for_testing) { | |
| 392 g_dbus_thread_manager = NULL; | |
| 393 g_dbus_thread_manager_for_testing = NULL; | |
| 394 VLOG(1) << "DBusThreadManager destroyed"; | |
| 395 } else { | |
| 396 LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()"; | |
| 397 } | |
| 398 } | |
| 399 | |
| 400 // static | 432 // static |
| 401 DBusThreadManager* DBusThreadManager::Get() { | 433 DBusThreadManager* DBusThreadManager::Get() { |
| 402 CHECK(g_dbus_thread_manager) | 434 CHECK(g_dbus_thread_manager) |
| 403 << "DBusThreadManager::Get() called before Initialize()"; | 435 << "DBusThreadManager::Get() called before Initialize()"; |
| 404 return g_dbus_thread_manager; | 436 return g_dbus_thread_manager; |
| 405 } | 437 } |
| 406 | 438 |
| 407 // static | 439 DBusThreadManagerTestHelper::DBusThreadManagerTestHelper() { |
| 408 void DBusThreadManager::InitializeClients() { | 440 } |
| 409 InitClient(g_dbus_thread_manager->GetBluetoothAdapterClient()); | 441 |
| 410 InitClient(g_dbus_thread_manager->GetBluetoothAgentManagerClient()); | 442 DBusThreadManagerTestHelper::~DBusThreadManagerTestHelper() { |
| 411 InitClient(g_dbus_thread_manager->GetBluetoothDeviceClient()); | 443 } |
| 412 InitClient(g_dbus_thread_manager->GetBluetoothGattCharacteristicClient()); | 444 |
| 413 InitClient(g_dbus_thread_manager->GetBluetoothGattDescriptorClient()); | 445 void DBusThreadManagerTestHelper::SetBluetoothAdapterClient( |
| 414 InitClient(g_dbus_thread_manager->GetBluetoothGattManagerClient()); | 446 scoped_ptr<BluetoothAdapterClient> client) { |
| 415 InitClient(g_dbus_thread_manager->GetBluetoothGattServiceClient()); | 447 DBusThreadManager::Get()->client_bundle_->bluetooth_adapter_client_ = |
| 416 InitClient(g_dbus_thread_manager->GetBluetoothInputClient()); | 448 client.Pass(); |
| 417 InitClient(g_dbus_thread_manager->GetBluetoothProfileManagerClient()); | 449 } |
| 418 InitClient(g_dbus_thread_manager->GetCrasAudioClient()); | 450 |
| 419 InitClient(g_dbus_thread_manager->GetCrosDisksClient()); | 451 void DBusThreadManagerTestHelper::SetBluetoothAgentManagerClient( |
| 420 InitClient(g_dbus_thread_manager->GetCryptohomeClient()); | 452 scoped_ptr<BluetoothAgentManagerClient> client) { |
| 421 InitClient(g_dbus_thread_manager->GetDebugDaemonClient()); | 453 DBusThreadManager::Get()->client_bundle_->bluetooth_agent_manager_client_ = |
| 422 InitClient(g_dbus_thread_manager->GetEasyUnlockClient()); | 454 client.Pass(); |
| 423 InitClient(g_dbus_thread_manager->GetGsmSMSClient()); | 455 } |
| 424 InitClient(g_dbus_thread_manager->GetImageBurnerClient()); | 456 |
| 425 InitClient(g_dbus_thread_manager->GetIntrospectableClient()); | 457 void DBusThreadManagerTestHelper::SetBluetoothDeviceClient( |
| 426 InitClient(g_dbus_thread_manager->GetLorgnetteManagerClient()); | 458 scoped_ptr<BluetoothDeviceClient> client) { |
| 427 InitClient(g_dbus_thread_manager->GetModemMessagingClient()); | 459 DBusThreadManager::Get()->client_bundle_->bluetooth_device_client_ = |
| 428 InitClient(g_dbus_thread_manager->GetPermissionBrokerClient()); | 460 client.Pass(); |
| 429 InitClient(g_dbus_thread_manager->GetPowerManagerClient()); | 461 } |
| 430 InitClient(g_dbus_thread_manager->GetSessionManagerClient()); | 462 |
| 431 InitClient(g_dbus_thread_manager->GetShillDeviceClient()); | 463 void DBusThreadManagerTestHelper::SetBluetoothGattCharacteristicClient( |
| 432 InitClient(g_dbus_thread_manager->GetShillIPConfigClient()); | 464 scoped_ptr<BluetoothGattCharacteristicClient> client) { |
| 433 InitClient(g_dbus_thread_manager->GetShillManagerClient()); | 465 DBusThreadManager::Get()->client_bundle_-> |
| 434 InitClient(g_dbus_thread_manager->GetShillServiceClient()); | 466 bluetooth_gatt_characteristic_client_ = client.Pass(); |
| 435 InitClient(g_dbus_thread_manager->GetShillProfileClient()); | 467 } |
| 436 InitClient(g_dbus_thread_manager->GetSMSClient()); | 468 |
| 437 InitClient(g_dbus_thread_manager->GetSystemClockClient()); | 469 void DBusThreadManagerTestHelper::SetBluetoothGattDescriptorClient( |
| 438 InitClient(g_dbus_thread_manager->GetUpdateEngineClient()); | 470 scoped_ptr<BluetoothGattDescriptorClient> client) { |
| 439 | 471 DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_descriptor_client_ = |
| 440 // Initialize the NFC clients in the correct order. The order of | 472 client.Pass(); |
| 441 // initialization matters due to dependencies that exist between the | 473 } |
| 442 // client objects. | 474 |
| 443 InitClient(g_dbus_thread_manager->GetNfcManagerClient()); | 475 void DBusThreadManagerTestHelper::SetBluetoothGattManagerClient( |
| 444 InitClient(g_dbus_thread_manager->GetNfcAdapterClient()); | 476 scoped_ptr<BluetoothGattManagerClient> client) { |
| 445 InitClient(g_dbus_thread_manager->GetNfcDeviceClient()); | 477 DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_manager_client_ = |
| 446 InitClient(g_dbus_thread_manager->GetNfcTagClient()); | 478 client.Pass(); |
| 447 InitClient(g_dbus_thread_manager->GetNfcRecordClient()); | 479 } |
| 448 | 480 |
| 449 // PowerPolicyController is dependent on PowerManagerClient, so | 481 void DBusThreadManagerTestHelper::SetBluetoothGattServiceClient( |
| 450 // initialize it after the main list of clients. | 482 scoped_ptr<BluetoothGattServiceClient> client) { |
| 451 if (g_dbus_thread_manager->GetPowerPolicyController()) { | 483 DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_service_client_ = |
| 452 g_dbus_thread_manager->GetPowerPolicyController()->Init( | 484 client.Pass(); |
| 453 g_dbus_thread_manager); | 485 } |
| 454 } | 486 |
| 455 | 487 void DBusThreadManagerTestHelper::SetBluetoothInputClient( |
| 456 // This must be called after the list of clients so they've each had a | 488 scoped_ptr<BluetoothInputClient> client) { |
| 457 // chance to register with their object g_dbus_thread_managers. | 489 DBusThreadManager::Get()->client_bundle_->bluetooth_input_client_ = |
| 458 if (g_dbus_thread_manager->GetSystemBus()) | 490 client.Pass(); |
| 459 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); | 491 } |
| 460 } | 492 |
| 461 | 493 void DBusThreadManagerTestHelper::SetBluetoothProfileManagerClient( |
| 462 // static | 494 scoped_ptr<BluetoothProfileManagerClient> client) { |
| 463 void DBusThreadManager::InitClient(DBusClient* client) { | 495 DBusThreadManager::Get()->client_bundle_->bluetooth_profile_manager_client_ = |
| 464 if (client) | 496 client.Pass(); |
| 465 client->Init(g_dbus_thread_manager->GetSystemBus()); | 497 } |
| 498 | |
| 499 void DBusThreadManagerTestHelper::SetCrasAudioClient( | |
| 500 scoped_ptr<CrasAudioClient> client) { | |
| 501 DBusThreadManager::Get()->client_bundle_->cras_audio_client_ = client.Pass(); | |
| 502 } | |
| 503 | |
| 504 void DBusThreadManagerTestHelper::SetCrosDisksClient( | |
| 505 scoped_ptr<CrosDisksClient> client) { | |
| 506 DBusThreadManager::Get()->client_bundle_->cros_disks_client_ = client.Pass(); | |
| 507 } | |
| 508 | |
| 509 void DBusThreadManagerTestHelper::SetCryptohomeClient( | |
| 510 scoped_ptr<CryptohomeClient> client) { | |
| 511 DBusThreadManager::Get()->client_bundle_->cryptohome_client_ = client.Pass(); | |
| 512 } | |
| 513 | |
| 514 void DBusThreadManagerTestHelper::SetDebugDaemonClient( | |
| 515 scoped_ptr<DebugDaemonClient> client) { | |
| 516 DBusThreadManager::Get()->client_bundle_->debug_daemon_client_ = | |
| 517 client.Pass(); | |
| 518 } | |
| 519 | |
| 520 void DBusThreadManagerTestHelper::SetEasyUnlockClient( | |
| 521 scoped_ptr<EasyUnlockClient> client) { | |
| 522 DBusThreadManager::Get()->client_bundle_->easy_unlock_client_ = client.Pass(); | |
| 523 } | |
| 524 | |
| 525 void DBusThreadManagerTestHelper::SetLorgnetteManagerClient( | |
| 526 scoped_ptr<LorgnetteManagerClient> client) { | |
| 527 DBusThreadManager::Get()->client_bundle_->lorgnette_manager_client_ = | |
| 528 client.Pass(); | |
| 529 } | |
| 530 | |
| 531 void DBusThreadManagerTestHelper::SetShillDeviceClient( | |
| 532 scoped_ptr<ShillDeviceClient> client) { | |
| 533 DBusThreadManager::Get()->client_bundle_->shill_device_client_ = | |
| 534 client.Pass(); | |
| 535 } | |
| 536 | |
| 537 void DBusThreadManagerTestHelper::SetShillIPConfigClient( | |
| 538 scoped_ptr<ShillIPConfigClient> client) { | |
| 539 DBusThreadManager::Get()->client_bundle_->shill_ipconfig_client_ = | |
| 540 client.Pass(); | |
| 541 } | |
| 542 | |
| 543 void DBusThreadManagerTestHelper::SetShillManagerClient( | |
| 544 scoped_ptr<ShillManagerClient> client) { | |
| 545 DBusThreadManager::Get()->client_bundle_->shill_manager_client_ = | |
| 546 client.Pass(); | |
| 547 } | |
| 548 | |
| 549 void DBusThreadManagerTestHelper::SetShillServiceClient( | |
| 550 scoped_ptr<ShillServiceClient> client) { | |
| 551 DBusThreadManager::Get()->client_bundle_->shill_service_client_ = | |
| 552 client.Pass(); | |
| 553 } | |
| 554 | |
| 555 void DBusThreadManagerTestHelper::SetShillProfileClient( | |
| 556 scoped_ptr<ShillProfileClient> client) { | |
| 557 DBusThreadManager::Get()->client_bundle_->shill_profile_client_ = | |
| 558 client.Pass(); | |
| 559 } | |
| 560 | |
| 561 void DBusThreadManagerTestHelper::SetGsmSMSClient( | |
| 562 scoped_ptr<GsmSMSClient> client) { | |
| 563 DBusThreadManager::Get()->client_bundle_->gsm_sms_client_ = client.Pass(); | |
| 564 } | |
| 565 | |
| 566 void DBusThreadManagerTestHelper::SetImageBurnerClient( | |
| 567 scoped_ptr<ImageBurnerClient> client) { | |
| 568 DBusThreadManager::Get()->client_bundle_->image_burner_client_ = | |
| 569 client.Pass(); | |
| 570 } | |
| 571 | |
| 572 void DBusThreadManagerTestHelper::SetIntrospectableClient( | |
| 573 scoped_ptr<IntrospectableClient> client) { | |
| 574 DBusThreadManager::Get()->client_bundle_->introspectable_client_ = | |
| 575 client.Pass(); | |
| 576 } | |
| 577 | |
| 578 void DBusThreadManagerTestHelper::SetModemMessagingClient( | |
| 579 scoped_ptr<ModemMessagingClient> client) { | |
| 580 DBusThreadManager::Get()->client_bundle_->modem_messaging_client_ = | |
| 581 client.Pass(); | |
| 582 } | |
| 583 | |
| 584 void DBusThreadManagerTestHelper::SetNfcAdapterClient( | |
| 585 scoped_ptr<NfcAdapterClient> client) { | |
| 586 DBusThreadManager::Get()->client_bundle_->nfc_adapter_client_ = client.Pass(); | |
| 587 } | |
| 588 | |
| 589 void DBusThreadManagerTestHelper::SetNfcDeviceClient( | |
| 590 scoped_ptr<NfcDeviceClient> client) { | |
| 591 DBusThreadManager::Get()->client_bundle_->nfc_device_client_ = client.Pass(); | |
| 592 } | |
| 593 | |
| 594 void DBusThreadManagerTestHelper::SetNfcManagerClient( | |
| 595 scoped_ptr<NfcManagerClient> client) { | |
| 596 DBusThreadManager::Get()->client_bundle_->nfc_manager_client_ = client.Pass(); | |
| 597 } | |
| 598 | |
| 599 void DBusThreadManagerTestHelper::SetNfcRecordClient( | |
| 600 scoped_ptr<NfcRecordClient> client) { | |
| 601 DBusThreadManager::Get()->client_bundle_->nfc_record_client_ = client.Pass(); | |
| 602 } | |
| 603 | |
| 604 void DBusThreadManagerTestHelper::SetNfcTagClient( | |
| 605 scoped_ptr<NfcTagClient> client) { | |
| 606 DBusThreadManager::Get()->client_bundle_->nfc_tag_client_ = client.Pass(); | |
| 607 } | |
| 608 | |
| 609 void DBusThreadManagerTestHelper::SetPermissionBrokerClient( | |
| 610 scoped_ptr<PermissionBrokerClient> client) { | |
| 611 DBusThreadManager::Get()->client_bundle_->permission_broker_client_ = | |
| 612 client.Pass(); | |
| 613 } | |
| 614 | |
| 615 void DBusThreadManagerTestHelper::SetPowerManagerClient( | |
| 616 scoped_ptr<PowerManagerClient> client) { | |
|
hashimoto
2014/08/25 06:56:20
A method named SetPowerManagerClient overwriting t
zel
2014/08/25 17:21:42
No, this can't be handled on the caller side due t
Daniel Erat
2014/08/25 17:28:25
PowerPolicyController registers itself as an obser
hashimoto
2014/08/26 01:54:59
Then can't we remove SetPowerPolicyController?
Pow
Daniel Erat
2014/08/26 16:08:03
yes, i suspect that this would work.
zel
2014/08/26 17:50:45
Removed SetPowerPolicyController()
| |
| 617 DBusThreadManager::Get()->power_policy_controller_.reset(); | |
| 618 DBusThreadManager::Get()->client_bundle_->power_manager_client_ = | |
| 619 client.Pass(); | |
| 620 DBusThreadManager::Get()->power_policy_controller_.reset( | |
| 621 new PowerPolicyController); | |
| 622 DBusThreadManager::Get()->power_policy_controller_->Init( | |
| 623 DBusThreadManager::Get()); | |
| 624 } | |
| 625 | |
| 626 void DBusThreadManagerTestHelper::SetPowerPolicyController( | |
| 627 scoped_ptr<PowerPolicyController> client) { | |
| 628 DBusThreadManager::Get()->power_policy_controller_ = client.Pass(); | |
| 629 } | |
| 630 | |
| 631 void DBusThreadManagerTestHelper::SetSessionManagerClient( | |
| 632 scoped_ptr<SessionManagerClient> client) { | |
| 633 DBusThreadManager::Get()->client_bundle_->session_manager_client_ = | |
| 634 client.Pass(); | |
| 635 } | |
| 636 | |
| 637 void DBusThreadManagerTestHelper::SetSMSClient(scoped_ptr<SMSClient> client) { | |
| 638 DBusThreadManager::Get()->client_bundle_->sms_client_ = client.Pass(); | |
| 639 } | |
| 640 | |
| 641 void DBusThreadManagerTestHelper::SetSystemClockClient( | |
| 642 scoped_ptr<SystemClockClient> client) { | |
| 643 DBusThreadManager::Get()->client_bundle_->system_clock_client_ = | |
| 644 client.Pass(); | |
| 645 } | |
| 646 | |
| 647 void DBusThreadManagerTestHelper::SetUpdateEngineClient( | |
| 648 scoped_ptr<UpdateEngineClient> client) { | |
| 649 DBusThreadManager::Get()->client_bundle_->update_engine_client_ = | |
| 650 client.Pass(); | |
| 466 } | 651 } |
| 467 | 652 |
| 468 } // namespace chromeos | 653 } // namespace chromeos |
| OLD | NEW |