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.
5 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "base/command_line.h"
10 #include "base/observer_list.h"
11 #include "base/sys_info.h"
12 #include "base/threading/thread.h"
13 #include "chromeos/chromeos_switches.h"
14 #include "chromeos/dbus/bluetooth_adapter_client.h"
15 #include "chromeos/dbus/bluetooth_agent_manager_client.h"
16 #include "chromeos/dbus/bluetooth_device_client.h"
17 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h"
18 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h"
19 #include "chromeos/dbus/bluetooth_gatt_manager_client.h"
20 #include "chromeos/dbus/bluetooth_gatt_service_client.h"
21 #include "chromeos/dbus/bluetooth_input_client.h"
22 #include "chromeos/dbus/bluetooth_profile_manager_client.h"
23 #include "chromeos/dbus/cras_audio_client.h"
24 #include "chromeos/dbus/cros_disks_client.h"
25 #include "chromeos/dbus/cryptohome_client.h"
26 #include "chromeos/dbus/dbus_client.h"
27 #include "chromeos/dbus/dbus_thread_manager_observer.h"
28 #include "chromeos/dbus/debug_daemon_client.h"
29 #include "chromeos/dbus/fake_dbus_thread_manager.h"
30 #include "chromeos/dbus/gsm_sms_client.h"
31 #include "chromeos/dbus/image_burner_client.h"
32 #include "chromeos/dbus/introspectable_client.h"
33 #include "chromeos/dbus/lorgnette_manager_client.h"
34 #include "chromeos/dbus/modem_messaging_client.h"
35 #include "chromeos/dbus/nfc_adapter_client.h"
36 #include "chromeos/dbus/nfc_device_client.h"
37 #include "chromeos/dbus/nfc_manager_client.h"
38 #include "chromeos/dbus/nfc_record_client.h"
39 #include "chromeos/dbus/nfc_tag_client.h"
40 #include "chromeos/dbus/permission_broker_client.h"
41 #include "chromeos/dbus/power_manager_client.h"
42 #include "chromeos/dbus/power_policy_controller.h"
43 #include "chromeos/dbus/session_manager_client.h"
44 #include "chromeos/dbus/shill_device_client.h"
45 #include "chromeos/dbus/shill_ipconfig_client.h"
46 #include "chromeos/dbus/shill_manager_client.h"
47 #include "chromeos/dbus/shill_profile_client.h"
48 #include "chromeos/dbus/shill_service_client.h"
49 #include "chromeos/dbus/sms_client.h"
50 #include "chromeos/dbus/system_clock_client.h"
51 #include "chromeos/dbus/update_engine_client.h"
53 #include "dbus/dbus_statistics.h"
57 static DBusThreadManager
* g_dbus_thread_manager
= NULL
;
58 static DBusThreadManager
* g_dbus_thread_manager_for_testing
= NULL
;
60 // The bundle of all D-Bus clients used in DBusThreadManagerImpl. The bundle
61 // is used to delete them at once in the right order before shutting down the
62 // system bus. See also the comment in the destructor of DBusThreadManagerImpl.
63 class DBusClientBundle
{
66 DBusClientImplementationType client_type
= REAL_DBUS_CLIENT_IMPLEMENTATION
;
67 DBusClientImplementationType client_type_override
= client_type
;
68 // If --dbus-stub was requested, pass STUB to specific components;
69 // Many components like login are not useful with a stub implementation.
70 if (CommandLine::ForCurrentProcess()->HasSwitch(
71 chromeos::switches::kDbusStub
)) {
72 client_type_override
= STUB_DBUS_CLIENT_IMPLEMENTATION
;
75 bluetooth_adapter_client_
.reset(BluetoothAdapterClient::Create());
76 bluetooth_agent_manager_client_
.reset(
77 BluetoothAgentManagerClient::Create());
78 bluetooth_device_client_
.reset(BluetoothDeviceClient::Create());
79 bluetooth_gatt_characteristic_client_
.reset(
80 BluetoothGattCharacteristicClient::Create());
81 bluetooth_gatt_descriptor_client_
.reset(
82 BluetoothGattDescriptorClient::Create());
83 bluetooth_gatt_manager_client_
.reset(BluetoothGattManagerClient::Create());
84 bluetooth_gatt_service_client_
.reset(BluetoothGattServiceClient::Create());
85 bluetooth_input_client_
.reset(BluetoothInputClient::Create());
86 bluetooth_profile_manager_client_
.reset(
87 BluetoothProfileManagerClient::Create());
88 cras_audio_client_
.reset(CrasAudioClient::Create());
89 cros_disks_client_
.reset(CrosDisksClient::Create(client_type
));
90 cryptohome_client_
.reset(CryptohomeClient::Create());
91 debug_daemon_client_
.reset(DebugDaemonClient::Create());
92 lorgnette_manager_client_
.reset(LorgnetteManagerClient::Create());
93 shill_manager_client_
.reset(ShillManagerClient::Create());
94 shill_device_client_
.reset(ShillDeviceClient::Create());
95 shill_ipconfig_client_
.reset(ShillIPConfigClient::Create());
96 shill_service_client_
.reset(ShillServiceClient::Create());
97 shill_profile_client_
.reset(ShillProfileClient::Create());
98 gsm_sms_client_
.reset(GsmSMSClient::Create());
99 image_burner_client_
.reset(ImageBurnerClient::Create());
100 introspectable_client_
.reset(IntrospectableClient::Create());
101 modem_messaging_client_
.reset(ModemMessagingClient::Create());
102 // Create the NFC clients in the correct order based on their dependencies.
103 nfc_manager_client_
.reset(NfcManagerClient::Create());
104 nfc_adapter_client_
.reset(
105 NfcAdapterClient::Create(nfc_manager_client_
.get()));
106 nfc_device_client_
.reset(
107 NfcDeviceClient::Create(nfc_adapter_client_
.get()));
108 nfc_tag_client_
.reset(NfcTagClient::Create(nfc_adapter_client_
.get()));
109 nfc_record_client_
.reset(NfcRecordClient::Create(nfc_device_client_
.get(),
110 nfc_tag_client_
.get()));
111 permission_broker_client_
.reset(PermissionBrokerClient::Create());
112 power_manager_client_
.reset(
113 PowerManagerClient::Create(client_type_override
));
114 session_manager_client_
.reset(SessionManagerClient::Create(client_type
));
115 sms_client_
.reset(SMSClient::Create());
116 system_clock_client_
.reset(SystemClockClient::Create());
117 update_engine_client_
.reset(UpdateEngineClient::Create(client_type
));
120 BluetoothAdapterClient
* bluetooth_adapter_client() {
121 return bluetooth_adapter_client_
.get();
123 BluetoothAgentManagerClient
* bluetooth_agent_manager_client() {
124 return bluetooth_agent_manager_client_
.get();
126 BluetoothDeviceClient
* bluetooth_device_client() {
127 return bluetooth_device_client_
.get();
129 BluetoothGattCharacteristicClient
* bluetooth_gatt_characteristic_client() {
130 return bluetooth_gatt_characteristic_client_
.get();
132 BluetoothGattDescriptorClient
* bluetooth_gatt_descriptor_client() {
133 return bluetooth_gatt_descriptor_client_
.get();
135 BluetoothGattManagerClient
* bluetooth_gatt_manager_client() {
136 return bluetooth_gatt_manager_client_
.get();
138 BluetoothGattServiceClient
* bluetooth_gatt_service_client() {
139 return bluetooth_gatt_service_client_
.get();
141 BluetoothInputClient
* bluetooth_input_client() {
142 return bluetooth_input_client_
.get();
144 BluetoothProfileManagerClient
* bluetooth_profile_manager_client() {
145 return bluetooth_profile_manager_client_
.get();
147 CrasAudioClient
* cras_audio_client() {
148 return cras_audio_client_
.get();
150 CrosDisksClient
* cros_disks_client() {
151 return cros_disks_client_
.get();
153 CryptohomeClient
* cryptohome_client() {
154 return cryptohome_client_
.get();
156 DebugDaemonClient
* debug_daemon_client() {
157 return debug_daemon_client_
.get();
159 LorgnetteManagerClient
* lorgnette_manager_client() {
160 return lorgnette_manager_client_
.get();
162 ShillDeviceClient
* shill_device_client() {
163 return shill_device_client_
.get();
165 ShillIPConfigClient
* shill_ipconfig_client() {
166 return shill_ipconfig_client_
.get();
168 ShillManagerClient
* shill_manager_client() {
169 return shill_manager_client_
.get();
171 ShillServiceClient
* shill_service_client() {
172 return shill_service_client_
.get();
174 ShillProfileClient
* shill_profile_client() {
175 return shill_profile_client_
.get();
177 GsmSMSClient
* gsm_sms_client() {
178 return gsm_sms_client_
.get();
180 ImageBurnerClient
* image_burner_client() {
181 return image_burner_client_
.get();
183 IntrospectableClient
* introspectable_client() {
184 return introspectable_client_
.get();
186 ModemMessagingClient
* modem_messaging_client() {
187 return modem_messaging_client_
.get();
189 NfcManagerClient
* nfc_manager_client() {
190 return nfc_manager_client_
.get();
192 NfcAdapterClient
* nfc_adapter_client() {
193 return nfc_adapter_client_
.get();
195 NfcDeviceClient
* nfc_device_client() {
196 return nfc_device_client_
.get();
198 NfcTagClient
* nfc_tag_client() {
199 return nfc_tag_client_
.get();
201 NfcRecordClient
* nfc_record_client() {
202 return nfc_record_client_
.get();
204 PermissionBrokerClient
* permission_broker_client() {
205 return permission_broker_client_
.get();
207 SystemClockClient
* system_clock_client() {
208 return system_clock_client_
.get();
210 PowerManagerClient
* power_manager_client() {
211 return power_manager_client_
.get();
213 SessionManagerClient
* session_manager_client() {
214 return session_manager_client_
.get();
216 SMSClient
* sms_client() {
217 return sms_client_
.get();
219 UpdateEngineClient
* update_engine_client() {
220 return update_engine_client_
.get();
224 scoped_ptr
<BluetoothAdapterClient
> bluetooth_adapter_client_
;
225 scoped_ptr
<BluetoothAgentManagerClient
> bluetooth_agent_manager_client_
;
226 scoped_ptr
<BluetoothDeviceClient
> bluetooth_device_client_
;
227 scoped_ptr
<BluetoothGattCharacteristicClient
>
228 bluetooth_gatt_characteristic_client_
;
229 scoped_ptr
<BluetoothGattDescriptorClient
> bluetooth_gatt_descriptor_client_
;
230 scoped_ptr
<BluetoothGattManagerClient
> bluetooth_gatt_manager_client_
;
231 scoped_ptr
<BluetoothGattServiceClient
> bluetooth_gatt_service_client_
;
232 scoped_ptr
<BluetoothInputClient
> bluetooth_input_client_
;
233 scoped_ptr
<BluetoothProfileManagerClient
> bluetooth_profile_manager_client_
;
234 scoped_ptr
<CrasAudioClient
> cras_audio_client_
;
235 scoped_ptr
<CrosDisksClient
> cros_disks_client_
;
236 scoped_ptr
<CryptohomeClient
> cryptohome_client_
;
237 scoped_ptr
<DebugDaemonClient
> debug_daemon_client_
;
238 scoped_ptr
<LorgnetteManagerClient
> lorgnette_manager_client_
;
239 scoped_ptr
<ShillDeviceClient
> shill_device_client_
;
240 scoped_ptr
<ShillIPConfigClient
> shill_ipconfig_client_
;
241 scoped_ptr
<ShillManagerClient
> shill_manager_client_
;
242 scoped_ptr
<ShillServiceClient
> shill_service_client_
;
243 scoped_ptr
<ShillProfileClient
> shill_profile_client_
;
244 scoped_ptr
<GsmSMSClient
> gsm_sms_client_
;
245 scoped_ptr
<ImageBurnerClient
> image_burner_client_
;
246 scoped_ptr
<IntrospectableClient
> introspectable_client_
;
247 scoped_ptr
<ModemMessagingClient
> modem_messaging_client_
;
248 // The declaration order for NFC client objects is important. See
249 // DBusThreadManager::CreateDefaultClients for the dependencies.
250 scoped_ptr
<NfcManagerClient
> nfc_manager_client_
;
251 scoped_ptr
<NfcAdapterClient
> nfc_adapter_client_
;
252 scoped_ptr
<NfcDeviceClient
> nfc_device_client_
;
253 scoped_ptr
<NfcTagClient
> nfc_tag_client_
;
254 scoped_ptr
<NfcRecordClient
> nfc_record_client_
;
255 scoped_ptr
<PermissionBrokerClient
> permission_broker_client_
;
256 scoped_ptr
<SystemClockClient
> system_clock_client_
;
257 scoped_ptr
<PowerManagerClient
> power_manager_client_
;
258 scoped_ptr
<SessionManagerClient
> session_manager_client_
;
259 scoped_ptr
<SMSClient
> sms_client_
;
260 scoped_ptr
<UpdateEngineClient
> update_engine_client_
;
262 DISALLOW_COPY_AND_ASSIGN(DBusClientBundle
);
265 // The DBusThreadManager implementation used in production.
266 class DBusThreadManagerImpl
: public DBusThreadManager
{
268 explicit DBusThreadManagerImpl() {
269 // Create the D-Bus thread.
270 base::Thread::Options thread_options
;
271 thread_options
.message_loop_type
= base::MessageLoop::TYPE_IO
;
272 dbus_thread_
.reset(new base::Thread("D-Bus thread"));
273 dbus_thread_
->StartWithOptions(thread_options
);
275 // Create the connection to the system bus.
276 dbus::Bus::Options system_bus_options
;
277 system_bus_options
.bus_type
= dbus::Bus::SYSTEM
;
278 system_bus_options
.connection_type
= dbus::Bus::PRIVATE
;
279 system_bus_options
.dbus_task_runner
= dbus_thread_
->message_loop_proxy();
280 system_bus_
= new dbus::Bus(system_bus_options
);
282 CreateDefaultClients();
285 virtual ~DBusThreadManagerImpl() {
286 FOR_EACH_OBSERVER(DBusThreadManagerObserver
, observers_
,
287 OnDBusThreadManagerDestroying(this));
289 // PowerPolicyController's destructor depends on PowerManagerClient.
290 power_policy_controller_
.reset();
292 // Delete all D-Bus clients before shutting down the system bus.
293 client_bundle_
.reset();
295 // Shut down the bus. During the browser shutdown, it's ok to shut down
296 // the bus synchronously.
297 system_bus_
->ShutdownOnDBusThreadAndBlock();
299 // Stop the D-Bus thread.
300 dbus_thread_
->Stop();
303 // DBusThreadManager overrides:
304 virtual void AddObserver(DBusThreadManagerObserver
* observer
) OVERRIDE
{
306 observers_
.AddObserver(observer
);
309 virtual void RemoveObserver(DBusThreadManagerObserver
* observer
) OVERRIDE
{
311 observers_
.RemoveObserver(observer
);
314 virtual dbus::Bus
* GetSystemBus() OVERRIDE
{
315 return system_bus_
.get();
318 virtual BluetoothAdapterClient
* GetBluetoothAdapterClient() OVERRIDE
{
319 return client_bundle_
->bluetooth_adapter_client();
322 virtual BluetoothAgentManagerClient
* GetBluetoothAgentManagerClient()
324 return client_bundle_
->bluetooth_agent_manager_client();
327 virtual BluetoothDeviceClient
* GetBluetoothDeviceClient() OVERRIDE
{
328 return client_bundle_
->bluetooth_device_client();
331 virtual BluetoothGattCharacteristicClient
*
332 GetBluetoothGattCharacteristicClient() OVERRIDE
{
333 return client_bundle_
->bluetooth_gatt_characteristic_client();
336 virtual BluetoothGattDescriptorClient
* GetBluetoothGattDescriptorClient()
338 return client_bundle_
->bluetooth_gatt_descriptor_client();
341 virtual BluetoothGattManagerClient
* GetBluetoothGattManagerClient() OVERRIDE
{
342 return client_bundle_
->bluetooth_gatt_manager_client();
345 virtual BluetoothGattServiceClient
* GetBluetoothGattServiceClient() OVERRIDE
{
346 return client_bundle_
->bluetooth_gatt_service_client();
349 virtual BluetoothInputClient
* GetBluetoothInputClient() OVERRIDE
{
350 return client_bundle_
->bluetooth_input_client();
353 virtual BluetoothProfileManagerClient
* GetBluetoothProfileManagerClient()
355 return client_bundle_
->bluetooth_profile_manager_client();
358 virtual CrasAudioClient
* GetCrasAudioClient() OVERRIDE
{
359 return client_bundle_
->cras_audio_client();
362 virtual CrosDisksClient
* GetCrosDisksClient() OVERRIDE
{
363 return client_bundle_
->cros_disks_client();
366 virtual CryptohomeClient
* GetCryptohomeClient() OVERRIDE
{
367 return client_bundle_
->cryptohome_client();
370 virtual DebugDaemonClient
* GetDebugDaemonClient() OVERRIDE
{
371 return client_bundle_
->debug_daemon_client();
374 virtual LorgnetteManagerClient
* GetLorgnetteManagerClient() OVERRIDE
{
375 return client_bundle_
->lorgnette_manager_client();
378 virtual ShillDeviceClient
* GetShillDeviceClient() OVERRIDE
{
379 return client_bundle_
->shill_device_client();
382 virtual ShillIPConfigClient
* GetShillIPConfigClient() OVERRIDE
{
383 return client_bundle_
->shill_ipconfig_client();
386 virtual ShillManagerClient
* GetShillManagerClient() OVERRIDE
{
387 return client_bundle_
->shill_manager_client();
390 virtual ShillServiceClient
* GetShillServiceClient() OVERRIDE
{
391 return client_bundle_
->shill_service_client();
394 virtual ShillProfileClient
* GetShillProfileClient() OVERRIDE
{
395 return client_bundle_
->shill_profile_client();
398 virtual GsmSMSClient
* GetGsmSMSClient() OVERRIDE
{
399 return client_bundle_
->gsm_sms_client();
402 virtual ImageBurnerClient
* GetImageBurnerClient() OVERRIDE
{
403 return client_bundle_
->image_burner_client();
406 virtual IntrospectableClient
* GetIntrospectableClient() OVERRIDE
{
407 return client_bundle_
->introspectable_client();
410 virtual ModemMessagingClient
* GetModemMessagingClient() OVERRIDE
{
411 return client_bundle_
->modem_messaging_client();
414 virtual NfcAdapterClient
* GetNfcAdapterClient() OVERRIDE
{
415 return client_bundle_
->nfc_adapter_client();
418 virtual NfcDeviceClient
* GetNfcDeviceClient() OVERRIDE
{
419 return client_bundle_
->nfc_device_client();
422 virtual NfcManagerClient
* GetNfcManagerClient() OVERRIDE
{
423 return client_bundle_
->nfc_manager_client();
426 virtual NfcRecordClient
* GetNfcRecordClient() OVERRIDE
{
427 return client_bundle_
->nfc_record_client();
430 virtual NfcTagClient
* GetNfcTagClient() OVERRIDE
{
431 return client_bundle_
->nfc_tag_client();
434 virtual PermissionBrokerClient
* GetPermissionBrokerClient() OVERRIDE
{
435 return client_bundle_
->permission_broker_client();
438 virtual PowerManagerClient
* GetPowerManagerClient() OVERRIDE
{
439 return client_bundle_
->power_manager_client();
442 virtual SessionManagerClient
* GetSessionManagerClient() OVERRIDE
{
443 return client_bundle_
->session_manager_client();
446 virtual SMSClient
* GetSMSClient() OVERRIDE
{
447 return client_bundle_
->sms_client();
450 virtual SystemClockClient
* GetSystemClockClient() OVERRIDE
{
451 return client_bundle_
->system_clock_client();
454 virtual UpdateEngineClient
* GetUpdateEngineClient() OVERRIDE
{
455 return client_bundle_
->update_engine_client();
458 virtual PowerPolicyController
* GetPowerPolicyController() OVERRIDE
{
459 return power_policy_controller_
.get();
463 // Constructs all clients and stores them in the respective *_client_ member
465 void CreateDefaultClients() {
466 client_bundle_
.reset(new DBusClientBundle
);
467 power_policy_controller_
.reset(new PowerPolicyController
);
470 // Note: Keep this before other members so they can call AddObserver() in
472 ObserverList
<DBusThreadManagerObserver
> observers_
;
474 scoped_ptr
<base::Thread
> dbus_thread_
;
475 scoped_refptr
<dbus::Bus
> system_bus_
;
476 scoped_ptr
<DBusClientBundle
> client_bundle_
;
477 scoped_ptr
<PowerPolicyController
> power_policy_controller_
;
481 void DBusThreadManager::Initialize() {
482 // If we initialize DBusThreadManager twice we may also be shutting it down
483 // early; do not allow that.
484 CHECK(g_dbus_thread_manager
== NULL
);
486 if (g_dbus_thread_manager_for_testing
) {
487 g_dbus_thread_manager
= g_dbus_thread_manager_for_testing
;
489 VLOG(1) << "DBusThreadManager initialized with test implementation";
492 // Determine whether we use stub or real client implementations.
493 if (base::SysInfo::IsRunningOnChromeOS()) {
494 g_dbus_thread_manager
= new DBusThreadManagerImpl
;
496 VLOG(1) << "DBusThreadManager initialized for ChromeOS";
498 InitializeWithStub();
503 void DBusThreadManager::SetInstanceForTesting(
504 DBusThreadManager
* dbus_thread_manager
) {
505 CHECK(!g_dbus_thread_manager
);
506 CHECK(!g_dbus_thread_manager_for_testing
);
507 g_dbus_thread_manager_for_testing
= dbus_thread_manager
;
511 void DBusThreadManager::InitializeForTesting(
512 DBusThreadManager
* dbus_thread_manager
) {
513 SetInstanceForTesting(dbus_thread_manager
);
518 void DBusThreadManager::InitializeWithStub() {
519 // If we initialize DBusThreadManager twice we may also be shutting it down
520 // early; do not allow that.
521 CHECK(g_dbus_thread_manager
== NULL
);
522 FakeDBusThreadManager
* fake_dbus_thread_manager
= new FakeDBusThreadManager
;
523 fake_dbus_thread_manager
->SetFakeClients();
524 g_dbus_thread_manager
= fake_dbus_thread_manager
;
526 fake_dbus_thread_manager
->SetupDefaultEnvironment();
527 VLOG(1) << "DBusThreadManager initialized with stub implementation";
531 bool DBusThreadManager::IsInitialized() {
532 return g_dbus_thread_manager
!= NULL
;
536 void DBusThreadManager::Shutdown() {
537 // If we called InitializeForTesting, this may get called more than once.
538 // Ensure that we only shutdown DBusThreadManager once.
539 CHECK(g_dbus_thread_manager
|| g_dbus_thread_manager_for_testing
);
540 DBusThreadManager
* dbus_thread_manager
= g_dbus_thread_manager
;
541 g_dbus_thread_manager
= NULL
;
542 g_dbus_thread_manager_for_testing
= NULL
;
543 delete dbus_thread_manager
;
544 VLOG(1) << "DBusThreadManager Shutdown completed";
547 DBusThreadManager::DBusThreadManager() {
548 dbus::statistics::Initialize();
551 DBusThreadManager::~DBusThreadManager() {
552 dbus::statistics::Shutdown();
553 if (g_dbus_thread_manager
== NULL
)
554 return; // Called form Shutdown() or local test instance.
555 // There should never be both a global instance and a local instance.
556 CHECK(this == g_dbus_thread_manager
);
557 if (g_dbus_thread_manager_for_testing
) {
558 g_dbus_thread_manager
= NULL
;
559 g_dbus_thread_manager_for_testing
= NULL
;
560 VLOG(1) << "DBusThreadManager destroyed";
562 LOG(FATAL
) << "~DBusThreadManager() called outside of Shutdown()";
567 DBusThreadManager
* DBusThreadManager::Get() {
568 CHECK(g_dbus_thread_manager
)
569 << "DBusThreadManager::Get() called before Initialize()";
570 return g_dbus_thread_manager
;
574 void DBusThreadManager::InitializeClients() {
575 InitClient(g_dbus_thread_manager
->GetBluetoothAdapterClient());
576 InitClient(g_dbus_thread_manager
->GetBluetoothAgentManagerClient());
577 InitClient(g_dbus_thread_manager
->GetBluetoothDeviceClient());
578 InitClient(g_dbus_thread_manager
->GetBluetoothGattCharacteristicClient());
579 InitClient(g_dbus_thread_manager
->GetBluetoothGattDescriptorClient());
580 InitClient(g_dbus_thread_manager
->GetBluetoothGattManagerClient());
581 InitClient(g_dbus_thread_manager
->GetBluetoothGattServiceClient());
582 InitClient(g_dbus_thread_manager
->GetBluetoothInputClient());
583 InitClient(g_dbus_thread_manager
->GetBluetoothProfileManagerClient());
584 InitClient(g_dbus_thread_manager
->GetCrasAudioClient());
585 InitClient(g_dbus_thread_manager
->GetCrosDisksClient());
586 InitClient(g_dbus_thread_manager
->GetCryptohomeClient());
587 InitClient(g_dbus_thread_manager
->GetDebugDaemonClient());
588 InitClient(g_dbus_thread_manager
->GetGsmSMSClient());
589 InitClient(g_dbus_thread_manager
->GetImageBurnerClient());
590 InitClient(g_dbus_thread_manager
->GetIntrospectableClient());
591 InitClient(g_dbus_thread_manager
->GetLorgnetteManagerClient());
592 InitClient(g_dbus_thread_manager
->GetModemMessagingClient());
593 InitClient(g_dbus_thread_manager
->GetPermissionBrokerClient());
594 InitClient(g_dbus_thread_manager
->GetPowerManagerClient());
595 InitClient(g_dbus_thread_manager
->GetSessionManagerClient());
596 InitClient(g_dbus_thread_manager
->GetShillDeviceClient());
597 InitClient(g_dbus_thread_manager
->GetShillIPConfigClient());
598 InitClient(g_dbus_thread_manager
->GetShillManagerClient());
599 InitClient(g_dbus_thread_manager
->GetShillServiceClient());
600 InitClient(g_dbus_thread_manager
->GetShillProfileClient());
601 InitClient(g_dbus_thread_manager
->GetSMSClient());
602 InitClient(g_dbus_thread_manager
->GetSystemClockClient());
603 InitClient(g_dbus_thread_manager
->GetUpdateEngineClient());
605 // Initialize the NFC clients in the correct order. The order of
606 // initialization matters due to dependencies that exist between the
608 InitClient(g_dbus_thread_manager
->GetNfcManagerClient());
609 InitClient(g_dbus_thread_manager
->GetNfcAdapterClient());
610 InitClient(g_dbus_thread_manager
->GetNfcDeviceClient());
611 InitClient(g_dbus_thread_manager
->GetNfcTagClient());
612 InitClient(g_dbus_thread_manager
->GetNfcRecordClient());
614 // PowerPolicyController is dependent on PowerManagerClient, so
615 // initialize it after the main list of clients.
616 if (g_dbus_thread_manager
->GetPowerPolicyController()) {
617 g_dbus_thread_manager
->GetPowerPolicyController()->Init(
618 g_dbus_thread_manager
);
621 // This must be called after the list of clients so they've each had a
622 // chance to register with their object g_dbus_thread_managers.
623 if (g_dbus_thread_manager
->GetSystemBus())
624 g_dbus_thread_manager
->GetSystemBus()->GetManagedObjects();
628 void DBusThreadManager::InitClient(DBusClient
* client
) {
630 client
->Init(g_dbus_thread_manager
->GetSystemBus());
633 } // namespace chromeos