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