Home | History | Annotate | Download | only in dbus
      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 
     57 DBusThreadManager::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 
     82 DBusThreadManager::~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 
    114 dbus::Bus* DBusThreadManager::GetSystemBus() {
    115   return system_bus_.get();
    116 }
    117 
    118 BluetoothAdapterClient* DBusThreadManager::GetBluetoothAdapterClient() {
    119   return client_bundle_->bluetooth_adapter_client();
    120 }
    121 
    122 BluetoothAgentManagerClient*
    123 DBusThreadManager::GetBluetoothAgentManagerClient() {
    124   return client_bundle_->bluetooth_agent_manager_client();
    125 }
    126 
    127 BluetoothDeviceClient* DBusThreadManager::GetBluetoothDeviceClient() {
    128   return client_bundle_->bluetooth_device_client();
    129 }
    130 
    131 BluetoothGattCharacteristicClient*
    132 DBusThreadManager::GetBluetoothGattCharacteristicClient() {
    133   return client_bundle_->bluetooth_gatt_characteristic_client();
    134 }
    135 
    136 BluetoothGattDescriptorClient*
    137 DBusThreadManager::GetBluetoothGattDescriptorClient() {
    138   return client_bundle_->bluetooth_gatt_descriptor_client();
    139 }
    140 
    141 BluetoothGattManagerClient*
    142 DBusThreadManager::GetBluetoothGattManagerClient() {
    143   return client_bundle_->bluetooth_gatt_manager_client();
    144 }
    145 
    146 BluetoothGattServiceClient*
    147 DBusThreadManager::GetBluetoothGattServiceClient() {
    148   return client_bundle_->bluetooth_gatt_service_client();
    149 }
    150 
    151 BluetoothInputClient* DBusThreadManager::GetBluetoothInputClient() {
    152   return client_bundle_->bluetooth_input_client();
    153 }
    154 
    155 BluetoothProfileManagerClient*
    156 DBusThreadManager::GetBluetoothProfileManagerClient() {
    157   return client_bundle_->bluetooth_profile_manager_client();
    158 }
    159 
    160 CrasAudioClient* DBusThreadManager::GetCrasAudioClient() {
    161   return client_bundle_->cras_audio_client();
    162 }
    163 
    164 CrosDisksClient* DBusThreadManager::GetCrosDisksClient() {
    165   return client_bundle_->cros_disks_client();
    166 }
    167 
    168 CryptohomeClient* DBusThreadManager::GetCryptohomeClient() {
    169   return client_bundle_->cryptohome_client();
    170 }
    171 
    172 DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() {
    173   return client_bundle_->debug_daemon_client();
    174 }
    175 
    176 EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() {
    177   return client_bundle_->easy_unlock_client();
    178 }
    179 LorgnetteManagerClient*
    180 DBusThreadManager::GetLorgnetteManagerClient() {
    181   return client_bundle_->lorgnette_manager_client();
    182 }
    183 
    184 ShillDeviceClient*
    185 DBusThreadManager::GetShillDeviceClient() {
    186   return client_bundle_->shill_device_client();
    187 }
    188 
    189 ShillIPConfigClient*
    190 DBusThreadManager::GetShillIPConfigClient() {
    191   return client_bundle_->shill_ipconfig_client();
    192 }
    193 
    194 ShillManagerClient*
    195 DBusThreadManager::GetShillManagerClient() {
    196   return client_bundle_->shill_manager_client();
    197 }
    198 
    199 ShillServiceClient*
    200 DBusThreadManager::GetShillServiceClient() {
    201   return client_bundle_->shill_service_client();
    202 }
    203 
    204 ShillProfileClient*
    205 DBusThreadManager::GetShillProfileClient() {
    206   return client_bundle_->shill_profile_client();
    207 }
    208 
    209 GsmSMSClient* DBusThreadManager::GetGsmSMSClient() {
    210   return client_bundle_->gsm_sms_client();
    211 }
    212 
    213 ImageBurnerClient* DBusThreadManager::GetImageBurnerClient() {
    214   return client_bundle_->image_burner_client();
    215 }
    216 
    217 IntrospectableClient* DBusThreadManager::GetIntrospectableClient() {
    218   return client_bundle_->introspectable_client();
    219 }
    220 
    221 ModemMessagingClient* DBusThreadManager::GetModemMessagingClient() {
    222   return client_bundle_->modem_messaging_client();
    223 }
    224 
    225 NfcAdapterClient* DBusThreadManager::GetNfcAdapterClient() {
    226   return client_bundle_->nfc_adapter_client();
    227 }
    228 
    229 NfcDeviceClient* DBusThreadManager::GetNfcDeviceClient() {
    230   return client_bundle_->nfc_device_client();
    231 }
    232 
    233 NfcManagerClient* DBusThreadManager::GetNfcManagerClient() {
    234   return client_bundle_->nfc_manager_client();
    235 }
    236 
    237 NfcRecordClient* DBusThreadManager::GetNfcRecordClient() {
    238   return client_bundle_->nfc_record_client();
    239 }
    240 
    241 NfcTagClient* DBusThreadManager::GetNfcTagClient() {
    242   return client_bundle_->nfc_tag_client();
    243 }
    244 
    245 PermissionBrokerClient* DBusThreadManager::GetPermissionBrokerClient() {
    246   return client_bundle_->permission_broker_client();
    247 }
    248 
    249 PowerManagerClient* DBusThreadManager::GetPowerManagerClient() {
    250   return client_bundle_->power_manager_client();
    251 }
    252 
    253 SessionManagerClient* DBusThreadManager::GetSessionManagerClient() {
    254   return client_bundle_->session_manager_client();
    255 }
    256 
    257 SMSClient* DBusThreadManager::GetSMSClient() {
    258   return client_bundle_->sms_client();
    259 }
    260 
    261 SystemClockClient* DBusThreadManager::GetSystemClockClient() {
    262   return client_bundle_->system_clock_client();
    263 }
    264 
    265 UpdateEngineClient* DBusThreadManager::GetUpdateEngineClient() {
    266   return client_bundle_->update_engine_client();
    267 }
    268 
    269 PowerPolicyController* DBusThreadManager::GetPowerPolicyController() {
    270   return power_policy_controller_.get();
    271 }
    272 
    273 void 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 
    327 bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) {
    328   return client_bundle_->IsUsingStub(client);
    329 }
    330 
    331 // static
    332 void 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
    357 scoped_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
    367 void 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
    376 void DBusThreadManager::InitializeWithRealClients() {
    377   CreateGlobalInstance(~static_cast<DBusClientBundle::DBusClientTypeMask>(0));
    378   VLOG(1) << "DBusThreadManager initialized for Chrome OS";
    379 }
    380 
    381 // static
    382 void DBusThreadManager::InitializeWithStubs() {
    383   CreateGlobalInstance(0 /* unstub_client_mask */);
    384   VLOG(1) << "DBusThreadManager created for testing";
    385 }
    386 
    387 // static
    388 void 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
    401 bool DBusThreadManager::IsInitialized() {
    402   return g_dbus_thread_manager != NULL;
    403 }
    404 
    405 // static
    406 void 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
    417 DBusThreadManager* DBusThreadManager::Get() {
    418   CHECK(g_dbus_thread_manager)
    419       << "DBusThreadManager::Get() called before Initialize()";
    420   return g_dbus_thread_manager;
    421 }
    422 
    423 DBusThreadManagerSetter::DBusThreadManagerSetter() {
    424 }
    425 
    426 DBusThreadManagerSetter::~DBusThreadManagerSetter() {
    427 }
    428 
    429 void DBusThreadManagerSetter::SetBluetoothAdapterClient(
    430     scoped_ptr<BluetoothAdapterClient> client) {
    431   DBusThreadManager::Get()->client_bundle_->bluetooth_adapter_client_ =
    432       client.Pass();
    433 }
    434 
    435 void DBusThreadManagerSetter::SetBluetoothAgentManagerClient(
    436     scoped_ptr<BluetoothAgentManagerClient> client) {
    437   DBusThreadManager::Get()->client_bundle_->bluetooth_agent_manager_client_ =
    438       client.Pass();
    439 }
    440 
    441 void DBusThreadManagerSetter::SetBluetoothDeviceClient(
    442     scoped_ptr<BluetoothDeviceClient> client) {
    443   DBusThreadManager::Get()->client_bundle_->bluetooth_device_client_ =
    444       client.Pass();
    445 }
    446 
    447 void DBusThreadManagerSetter::SetBluetoothGattCharacteristicClient(
    448     scoped_ptr<BluetoothGattCharacteristicClient> client) {
    449   DBusThreadManager::Get()->client_bundle_->
    450       bluetooth_gatt_characteristic_client_ = client.Pass();
    451 }
    452 
    453 void DBusThreadManagerSetter::SetBluetoothGattDescriptorClient(
    454     scoped_ptr<BluetoothGattDescriptorClient> client) {
    455   DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_descriptor_client_ =
    456       client.Pass();
    457 }
    458 
    459 void DBusThreadManagerSetter::SetBluetoothGattManagerClient(
    460     scoped_ptr<BluetoothGattManagerClient> client) {
    461   DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_manager_client_ =
    462       client.Pass();
    463 }
    464 
    465 void DBusThreadManagerSetter::SetBluetoothGattServiceClient(
    466     scoped_ptr<BluetoothGattServiceClient> client) {
    467   DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_service_client_ =
    468       client.Pass();
    469 }
    470 
    471 void DBusThreadManagerSetter::SetBluetoothInputClient(
    472     scoped_ptr<BluetoothInputClient> client) {
    473   DBusThreadManager::Get()->client_bundle_->bluetooth_input_client_ =
    474       client.Pass();
    475 }
    476 
    477 void DBusThreadManagerSetter::SetBluetoothProfileManagerClient(
    478     scoped_ptr<BluetoothProfileManagerClient> client) {
    479   DBusThreadManager::Get()->client_bundle_->bluetooth_profile_manager_client_ =
    480       client.Pass();
    481 }
    482 
    483 void DBusThreadManagerSetter::SetCrasAudioClient(
    484     scoped_ptr<CrasAudioClient> client) {
    485   DBusThreadManager::Get()->client_bundle_->cras_audio_client_ = client.Pass();
    486 }
    487 
    488 void DBusThreadManagerSetter::SetCrosDisksClient(
    489     scoped_ptr<CrosDisksClient> client) {
    490   DBusThreadManager::Get()->client_bundle_->cros_disks_client_ = client.Pass();
    491 }
    492 
    493 void DBusThreadManagerSetter::SetCryptohomeClient(
    494     scoped_ptr<CryptohomeClient> client) {
    495   DBusThreadManager::Get()->client_bundle_->cryptohome_client_ = client.Pass();
    496 }
    497 
    498 void DBusThreadManagerSetter::SetDebugDaemonClient(
    499     scoped_ptr<DebugDaemonClient> client) {
    500   DBusThreadManager::Get()->client_bundle_->debug_daemon_client_ =
    501       client.Pass();
    502 }
    503 
    504 void DBusThreadManagerSetter::SetEasyUnlockClient(
    505     scoped_ptr<EasyUnlockClient> client) {
    506   DBusThreadManager::Get()->client_bundle_->easy_unlock_client_ = client.Pass();
    507 }
    508 
    509 void DBusThreadManagerSetter::SetLorgnetteManagerClient(
    510     scoped_ptr<LorgnetteManagerClient> client) {
    511   DBusThreadManager::Get()->client_bundle_->lorgnette_manager_client_ =
    512       client.Pass();
    513 }
    514 
    515 void DBusThreadManagerSetter::SetShillDeviceClient(
    516     scoped_ptr<ShillDeviceClient> client) {
    517   DBusThreadManager::Get()->client_bundle_->shill_device_client_ =
    518       client.Pass();
    519 }
    520 
    521 void DBusThreadManagerSetter::SetShillIPConfigClient(
    522     scoped_ptr<ShillIPConfigClient> client) {
    523   DBusThreadManager::Get()->client_bundle_->shill_ipconfig_client_ =
    524       client.Pass();
    525 }
    526 
    527 void DBusThreadManagerSetter::SetShillManagerClient(
    528     scoped_ptr<ShillManagerClient> client) {
    529   DBusThreadManager::Get()->client_bundle_->shill_manager_client_ =
    530       client.Pass();
    531 }
    532 
    533 void DBusThreadManagerSetter::SetShillServiceClient(
    534     scoped_ptr<ShillServiceClient> client) {
    535   DBusThreadManager::Get()->client_bundle_->shill_service_client_ =
    536       client.Pass();
    537 }
    538 
    539 void DBusThreadManagerSetter::SetShillProfileClient(
    540     scoped_ptr<ShillProfileClient> client) {
    541   DBusThreadManager::Get()->client_bundle_->shill_profile_client_ =
    542       client.Pass();
    543 }
    544 
    545 void DBusThreadManagerSetter::SetGsmSMSClient(
    546     scoped_ptr<GsmSMSClient> client) {
    547   DBusThreadManager::Get()->client_bundle_->gsm_sms_client_ = client.Pass();
    548 }
    549 
    550 void DBusThreadManagerSetter::SetImageBurnerClient(
    551     scoped_ptr<ImageBurnerClient> client) {
    552   DBusThreadManager::Get()->client_bundle_->image_burner_client_ =
    553       client.Pass();
    554 }
    555 
    556 void DBusThreadManagerSetter::SetIntrospectableClient(
    557     scoped_ptr<IntrospectableClient> client) {
    558   DBusThreadManager::Get()->client_bundle_->introspectable_client_ =
    559       client.Pass();
    560 }
    561 
    562 void DBusThreadManagerSetter::SetModemMessagingClient(
    563     scoped_ptr<ModemMessagingClient> client) {
    564   DBusThreadManager::Get()->client_bundle_->modem_messaging_client_ =
    565       client.Pass();
    566 }
    567 
    568 void DBusThreadManagerSetter::SetNfcAdapterClient(
    569     scoped_ptr<NfcAdapterClient> client) {
    570   DBusThreadManager::Get()->client_bundle_->nfc_adapter_client_ = client.Pass();
    571 }
    572 
    573 void DBusThreadManagerSetter::SetNfcDeviceClient(
    574     scoped_ptr<NfcDeviceClient> client) {
    575   DBusThreadManager::Get()->client_bundle_->nfc_device_client_ = client.Pass();
    576 }
    577 
    578 void DBusThreadManagerSetter::SetNfcManagerClient(
    579     scoped_ptr<NfcManagerClient> client) {
    580   DBusThreadManager::Get()->client_bundle_->nfc_manager_client_ = client.Pass();
    581 }
    582 
    583 void DBusThreadManagerSetter::SetNfcRecordClient(
    584     scoped_ptr<NfcRecordClient> client) {
    585   DBusThreadManager::Get()->client_bundle_->nfc_record_client_ = client.Pass();
    586 }
    587 
    588 void DBusThreadManagerSetter::SetNfcTagClient(
    589     scoped_ptr<NfcTagClient> client) {
    590   DBusThreadManager::Get()->client_bundle_->nfc_tag_client_ = client.Pass();
    591 }
    592 
    593 void DBusThreadManagerSetter::SetPermissionBrokerClient(
    594     scoped_ptr<PermissionBrokerClient> client) {
    595   DBusThreadManager::Get()->client_bundle_->permission_broker_client_ =
    596       client.Pass();
    597 }
    598 
    599 void 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 
    610 void DBusThreadManagerSetter::SetSessionManagerClient(
    611     scoped_ptr<SessionManagerClient> client) {
    612   DBusThreadManager::Get()->client_bundle_->session_manager_client_ =
    613       client.Pass();
    614 }
    615 
    616 void DBusThreadManagerSetter::SetSMSClient(scoped_ptr<SMSClient> client) {
    617   DBusThreadManager::Get()->client_bundle_->sms_client_ = client.Pass();
    618 }
    619 
    620 void DBusThreadManagerSetter::SetSystemClockClient(
    621     scoped_ptr<SystemClockClient> client) {
    622   DBusThreadManager::Get()->client_bundle_->system_clock_client_ =
    623       client.Pass();
    624 }
    625 
    626 void DBusThreadManagerSetter::SetUpdateEngineClient(
    627     scoped_ptr<UpdateEngineClient> client) {
    628   DBusThreadManager::Get()->client_bundle_->update_engine_client_ =
    629       client.Pass();
    630 }
    631 
    632 }  // namespace chromeos
    633