Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chromeos / dbus / dbus_thread_manager.cc
blob1df4d0e58c7d84245dae88c55d511fbaf915f051
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"
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"
52 namespace chromeos {
54 static DBusThreadManager* g_dbus_thread_manager = NULL;
55 static bool g_using_dbus_thread_manager_for_testing = false;
57 DBusClientBundle::DBusClientTypeMask
58 DBusThreadManager::unstub_client_mask_ = DBusClientBundle::NO_CLIENTS;
60 DBusThreadManager::DBusThreadManager() {
61 dbus::statistics::Initialize();
62 if (!DBusThreadManager::IsUsingStub(DBusClientBundle::ALL_CLIENTS)) {
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);
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);
77 CreateDefaultClients();
80 DBusThreadManager::~DBusThreadManager() {
81 // PowerPolicyController's destructor depends on PowerManagerClient.
82 power_policy_controller_.reset();
84 // Delete all D-Bus clients before shutting down the system bus.
85 client_bundle_.reset();
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();
92 // Stop the D-Bus thread.
93 if (dbus_thread_)
94 dbus_thread_->Stop();
96 dbus::statistics::Shutdown();
98 if (g_dbus_thread_manager == NULL)
99 return; // Called form Shutdown() or local test instance.
101 // There should never be both a global instance and a local instance.
102 CHECK(this == g_dbus_thread_manager);
103 if (g_using_dbus_thread_manager_for_testing) {
104 g_dbus_thread_manager = NULL;
105 g_using_dbus_thread_manager_for_testing = false;
106 VLOG(1) << "DBusThreadManager destroyed";
107 } else {
108 LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()";
112 dbus::Bus* DBusThreadManager::GetSystemBus() {
113 return system_bus_.get();
116 BluetoothAdapterClient* DBusThreadManager::GetBluetoothAdapterClient() {
117 return client_bundle_->bluetooth_adapter_client();
120 BluetoothAgentManagerClient*
121 DBusThreadManager::GetBluetoothAgentManagerClient() {
122 return client_bundle_->bluetooth_agent_manager_client();
125 BluetoothDeviceClient* DBusThreadManager::GetBluetoothDeviceClient() {
126 return client_bundle_->bluetooth_device_client();
129 BluetoothGattCharacteristicClient*
130 DBusThreadManager::GetBluetoothGattCharacteristicClient() {
131 return client_bundle_->bluetooth_gatt_characteristic_client();
134 BluetoothGattDescriptorClient*
135 DBusThreadManager::GetBluetoothGattDescriptorClient() {
136 return client_bundle_->bluetooth_gatt_descriptor_client();
139 BluetoothGattManagerClient*
140 DBusThreadManager::GetBluetoothGattManagerClient() {
141 return client_bundle_->bluetooth_gatt_manager_client();
144 BluetoothGattServiceClient*
145 DBusThreadManager::GetBluetoothGattServiceClient() {
146 return client_bundle_->bluetooth_gatt_service_client();
149 BluetoothInputClient* DBusThreadManager::GetBluetoothInputClient() {
150 return client_bundle_->bluetooth_input_client();
153 BluetoothProfileManagerClient*
154 DBusThreadManager::GetBluetoothProfileManagerClient() {
155 return client_bundle_->bluetooth_profile_manager_client();
158 CrasAudioClient* DBusThreadManager::GetCrasAudioClient() {
159 return client_bundle_->cras_audio_client();
162 CrosDisksClient* DBusThreadManager::GetCrosDisksClient() {
163 return client_bundle_->cros_disks_client();
166 CryptohomeClient* DBusThreadManager::GetCryptohomeClient() {
167 return client_bundle_->cryptohome_client();
170 DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() {
171 return client_bundle_->debug_daemon_client();
174 EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() {
175 return client_bundle_->easy_unlock_client();
177 LorgnetteManagerClient*
178 DBusThreadManager::GetLorgnetteManagerClient() {
179 return client_bundle_->lorgnette_manager_client();
182 ShillDeviceClient*
183 DBusThreadManager::GetShillDeviceClient() {
184 return client_bundle_->shill_device_client();
187 ShillIPConfigClient*
188 DBusThreadManager::GetShillIPConfigClient() {
189 return client_bundle_->shill_ipconfig_client();
192 ShillManagerClient*
193 DBusThreadManager::GetShillManagerClient() {
194 return client_bundle_->shill_manager_client();
197 ShillServiceClient*
198 DBusThreadManager::GetShillServiceClient() {
199 return client_bundle_->shill_service_client();
202 ShillProfileClient*
203 DBusThreadManager::GetShillProfileClient() {
204 return client_bundle_->shill_profile_client();
207 GsmSMSClient* DBusThreadManager::GetGsmSMSClient() {
208 return client_bundle_->gsm_sms_client();
211 ImageBurnerClient* DBusThreadManager::GetImageBurnerClient() {
212 return client_bundle_->image_burner_client();
215 IntrospectableClient* DBusThreadManager::GetIntrospectableClient() {
216 return client_bundle_->introspectable_client();
219 ModemMessagingClient* DBusThreadManager::GetModemMessagingClient() {
220 return client_bundle_->modem_messaging_client();
223 NfcAdapterClient* DBusThreadManager::GetNfcAdapterClient() {
224 return client_bundle_->nfc_adapter_client();
227 NfcDeviceClient* DBusThreadManager::GetNfcDeviceClient() {
228 return client_bundle_->nfc_device_client();
231 NfcManagerClient* DBusThreadManager::GetNfcManagerClient() {
232 return client_bundle_->nfc_manager_client();
235 NfcRecordClient* DBusThreadManager::GetNfcRecordClient() {
236 return client_bundle_->nfc_record_client();
239 NfcTagClient* DBusThreadManager::GetNfcTagClient() {
240 return client_bundle_->nfc_tag_client();
243 PermissionBrokerClient* DBusThreadManager::GetPermissionBrokerClient() {
244 return client_bundle_->permission_broker_client();
247 PowerManagerClient* DBusThreadManager::GetPowerManagerClient() {
248 return client_bundle_->power_manager_client();
251 SessionManagerClient* DBusThreadManager::GetSessionManagerClient() {
252 return client_bundle_->session_manager_client();
255 SMSClient* DBusThreadManager::GetSMSClient() {
256 return client_bundle_->sms_client();
259 SystemClockClient* DBusThreadManager::GetSystemClockClient() {
260 return client_bundle_->system_clock_client();
263 UpdateEngineClient* DBusThreadManager::GetUpdateEngineClient() {
264 return client_bundle_->update_engine_client();
267 PowerPolicyController* DBusThreadManager::GetPowerPolicyController() {
268 return power_policy_controller_.get();
271 void DBusThreadManager::CreateDefaultClients() {
272 client_bundle_.reset(new DBusClientBundle());
273 // TODO(crbug.com/345586): Move PowerPolicyController out of
274 // DBusThreadManager.
275 power_policy_controller_.reset(new PowerPolicyController);
278 void DBusThreadManager::InitializeClients() {
279 GetBluetoothAdapterClient()->Init(GetSystemBus());
280 GetBluetoothAgentManagerClient()->Init(GetSystemBus());
281 GetBluetoothDeviceClient()->Init(GetSystemBus());
282 GetBluetoothGattCharacteristicClient()->Init(GetSystemBus());
283 GetBluetoothGattDescriptorClient()->Init(GetSystemBus());
284 GetBluetoothGattManagerClient()->Init(GetSystemBus());
285 GetBluetoothGattServiceClient()->Init(GetSystemBus());
286 GetBluetoothInputClient()->Init(GetSystemBus());
287 GetBluetoothProfileManagerClient()->Init(GetSystemBus());
288 GetCrasAudioClient()->Init(GetSystemBus());
289 GetCrosDisksClient()->Init(GetSystemBus());
290 GetCryptohomeClient()->Init(GetSystemBus());
291 GetDebugDaemonClient()->Init(GetSystemBus());
292 GetEasyUnlockClient()->Init(GetSystemBus());
293 GetGsmSMSClient()->Init(GetSystemBus());
294 GetImageBurnerClient()->Init(GetSystemBus());
295 GetIntrospectableClient()->Init(GetSystemBus());
296 GetLorgnetteManagerClient()->Init(GetSystemBus());
297 GetModemMessagingClient()->Init(GetSystemBus());
298 GetPermissionBrokerClient()->Init(GetSystemBus());
299 GetPowerManagerClient()->Init(GetSystemBus());
300 GetSessionManagerClient()->Init(GetSystemBus());
301 GetShillDeviceClient()->Init(GetSystemBus());
302 GetShillIPConfigClient()->Init(GetSystemBus());
303 GetShillManagerClient()->Init(GetSystemBus());
304 GetShillServiceClient()->Init(GetSystemBus());
305 GetShillProfileClient()->Init(GetSystemBus());
306 GetSMSClient()->Init(GetSystemBus());
307 GetSystemClockClient()->Init(GetSystemBus());
308 GetUpdateEngineClient()->Init(GetSystemBus());
310 // Initialize the NFC clients in the correct order. The order of
311 // initialization matters due to dependencies that exist between the
312 // client objects.
313 GetNfcManagerClient()->Init(GetSystemBus());
314 GetNfcAdapterClient()->Init(GetSystemBus());
315 GetNfcDeviceClient()->Init(GetSystemBus());
316 GetNfcTagClient()->Init(GetSystemBus());
317 GetNfcRecordClient()->Init(GetSystemBus());
319 // PowerPolicyController is dependent on PowerManagerClient, so
320 // initialize it after the main list of clients.
321 if (GetPowerPolicyController())
322 GetPowerPolicyController()->Init(this);
324 // This must be called after the list of clients so they've each had a
325 // chance to register with their object g_dbus_thread_managers.
326 if (GetSystemBus())
327 GetSystemBus()->GetManagedObjects();
329 client_bundle_->SetupDefaultEnvironment();
332 // static
333 bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) {
334 return !(unstub_client_mask_ & client);
337 // static
338 void DBusThreadManager::Initialize() {
339 // If we initialize DBusThreadManager twice we may also be shutting it down
340 // early; do not allow that.
341 if (g_using_dbus_thread_manager_for_testing)
342 return;
344 CHECK(g_dbus_thread_manager == NULL);
345 bool use_dbus_stub = !base::SysInfo::IsRunningOnChromeOS() ||
346 CommandLine::ForCurrentProcess()->HasSwitch(
347 chromeos::switches::kDbusStub);
348 bool force_unstub_clients = CommandLine::ForCurrentProcess()->HasSwitch(
349 chromeos::switches::kDbusUnstubClients);
350 // Determine whether we use stub or real client implementations.
351 if (force_unstub_clients) {
352 InitializeWithPartialStub(
353 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
354 chromeos::switches::kDbusUnstubClients));
355 } else if (use_dbus_stub) {
356 InitializeWithStubs();
357 } else {
358 InitializeRegular();
362 // static
363 scoped_ptr<DBusThreadManagerSetter> DBusThreadManager::GetSetterForTesting() {
364 if (!g_using_dbus_thread_manager_for_testing) {
365 g_using_dbus_thread_manager_for_testing = true;
366 InitializeWithStubs();
369 return make_scoped_ptr(new DBusThreadManagerSetter());
372 // static
373 void DBusThreadManager::CreateGlobalInstance() {
374 CHECK(!g_dbus_thread_manager);
375 g_dbus_thread_manager = new DBusThreadManager();
376 g_dbus_thread_manager->InitializeClients();
379 // static
380 void DBusThreadManager::InitializeRegular() {
381 unstub_client_mask_ = DBusClientBundle::ALL_CLIENTS;
382 CreateGlobalInstance();
383 VLOG(1) << "DBusThreadManager initialized for Chrome OS";
386 // static
387 void DBusThreadManager::InitializeWithStubs() {
388 unstub_client_mask_ = DBusClientBundle::NO_CLIENTS;
389 CreateGlobalInstance();
390 VLOG(1) << "DBusThreadManager created for testing";
393 // static
394 void DBusThreadManager::InitializeWithPartialStub(
395 const std::string& unstub_clients) {
396 unstub_client_mask_ = DBusClientBundle::ParseUnstubList(unstub_clients);
397 // We should have something parsed correctly here.
398 if (unstub_client_mask_ == 0) {
399 LOG(FATAL) << "Switch values for --"
400 << chromeos::switches::kDbusUnstubClients
401 << " cannot be parsed: "
402 << unstub_clients;
404 VLOG(1) << "DBusThreadManager initialized for mixed runtime environment";
405 CreateGlobalInstance();
408 // static
409 bool DBusThreadManager::IsInitialized() {
410 return g_dbus_thread_manager != NULL;
413 // static
414 void DBusThreadManager::Shutdown() {
415 // Ensure that we only shutdown DBusThreadManager once.
416 CHECK(g_dbus_thread_manager);
417 DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager;
418 g_dbus_thread_manager = NULL;
419 g_using_dbus_thread_manager_for_testing = false;
420 delete dbus_thread_manager;
421 VLOG(1) << "DBusThreadManager Shutdown completed";
424 // static
425 DBusThreadManager* DBusThreadManager::Get() {
426 CHECK(g_dbus_thread_manager)
427 << "DBusThreadManager::Get() called before Initialize()";
428 return g_dbus_thread_manager;
431 DBusThreadManagerSetter::DBusThreadManagerSetter() {
434 DBusThreadManagerSetter::~DBusThreadManagerSetter() {
437 void DBusThreadManagerSetter::SetBluetoothAdapterClient(
438 scoped_ptr<BluetoothAdapterClient> client) {
439 DBusThreadManager::Get()->client_bundle_->bluetooth_adapter_client_ =
440 client.Pass();
443 void DBusThreadManagerSetter::SetBluetoothAgentManagerClient(
444 scoped_ptr<BluetoothAgentManagerClient> client) {
445 DBusThreadManager::Get()->client_bundle_->bluetooth_agent_manager_client_ =
446 client.Pass();
449 void DBusThreadManagerSetter::SetBluetoothDeviceClient(
450 scoped_ptr<BluetoothDeviceClient> client) {
451 DBusThreadManager::Get()->client_bundle_->bluetooth_device_client_ =
452 client.Pass();
455 void DBusThreadManagerSetter::SetBluetoothGattCharacteristicClient(
456 scoped_ptr<BluetoothGattCharacteristicClient> client) {
457 DBusThreadManager::Get()->client_bundle_->
458 bluetooth_gatt_characteristic_client_ = client.Pass();
461 void DBusThreadManagerSetter::SetBluetoothGattDescriptorClient(
462 scoped_ptr<BluetoothGattDescriptorClient> client) {
463 DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_descriptor_client_ =
464 client.Pass();
467 void DBusThreadManagerSetter::SetBluetoothGattManagerClient(
468 scoped_ptr<BluetoothGattManagerClient> client) {
469 DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_manager_client_ =
470 client.Pass();
473 void DBusThreadManagerSetter::SetBluetoothGattServiceClient(
474 scoped_ptr<BluetoothGattServiceClient> client) {
475 DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_service_client_ =
476 client.Pass();
479 void DBusThreadManagerSetter::SetBluetoothInputClient(
480 scoped_ptr<BluetoothInputClient> client) {
481 DBusThreadManager::Get()->client_bundle_->bluetooth_input_client_ =
482 client.Pass();
485 void DBusThreadManagerSetter::SetBluetoothProfileManagerClient(
486 scoped_ptr<BluetoothProfileManagerClient> client) {
487 DBusThreadManager::Get()->client_bundle_->bluetooth_profile_manager_client_ =
488 client.Pass();
491 void DBusThreadManagerSetter::SetCrasAudioClient(
492 scoped_ptr<CrasAudioClient> client) {
493 DBusThreadManager::Get()->client_bundle_->cras_audio_client_ = client.Pass();
496 void DBusThreadManagerSetter::SetCrosDisksClient(
497 scoped_ptr<CrosDisksClient> client) {
498 DBusThreadManager::Get()->client_bundle_->cros_disks_client_ = client.Pass();
501 void DBusThreadManagerSetter::SetCryptohomeClient(
502 scoped_ptr<CryptohomeClient> client) {
503 DBusThreadManager::Get()->client_bundle_->cryptohome_client_ = client.Pass();
506 void DBusThreadManagerSetter::SetDebugDaemonClient(
507 scoped_ptr<DebugDaemonClient> client) {
508 DBusThreadManager::Get()->client_bundle_->debug_daemon_client_ =
509 client.Pass();
512 void DBusThreadManagerSetter::SetEasyUnlockClient(
513 scoped_ptr<EasyUnlockClient> client) {
514 DBusThreadManager::Get()->client_bundle_->easy_unlock_client_ = client.Pass();
517 void DBusThreadManagerSetter::SetLorgnetteManagerClient(
518 scoped_ptr<LorgnetteManagerClient> client) {
519 DBusThreadManager::Get()->client_bundle_->lorgnette_manager_client_ =
520 client.Pass();
523 void DBusThreadManagerSetter::SetShillDeviceClient(
524 scoped_ptr<ShillDeviceClient> client) {
525 DBusThreadManager::Get()->client_bundle_->shill_device_client_ =
526 client.Pass();
529 void DBusThreadManagerSetter::SetShillIPConfigClient(
530 scoped_ptr<ShillIPConfigClient> client) {
531 DBusThreadManager::Get()->client_bundle_->shill_ipconfig_client_ =
532 client.Pass();
535 void DBusThreadManagerSetter::SetShillManagerClient(
536 scoped_ptr<ShillManagerClient> client) {
537 DBusThreadManager::Get()->client_bundle_->shill_manager_client_ =
538 client.Pass();
541 void DBusThreadManagerSetter::SetShillServiceClient(
542 scoped_ptr<ShillServiceClient> client) {
543 DBusThreadManager::Get()->client_bundle_->shill_service_client_ =
544 client.Pass();
547 void DBusThreadManagerSetter::SetShillProfileClient(
548 scoped_ptr<ShillProfileClient> client) {
549 DBusThreadManager::Get()->client_bundle_->shill_profile_client_ =
550 client.Pass();
553 void DBusThreadManagerSetter::SetGsmSMSClient(
554 scoped_ptr<GsmSMSClient> client) {
555 DBusThreadManager::Get()->client_bundle_->gsm_sms_client_ = client.Pass();
558 void DBusThreadManagerSetter::SetImageBurnerClient(
559 scoped_ptr<ImageBurnerClient> client) {
560 DBusThreadManager::Get()->client_bundle_->image_burner_client_ =
561 client.Pass();
564 void DBusThreadManagerSetter::SetIntrospectableClient(
565 scoped_ptr<IntrospectableClient> client) {
566 DBusThreadManager::Get()->client_bundle_->introspectable_client_ =
567 client.Pass();
570 void DBusThreadManagerSetter::SetModemMessagingClient(
571 scoped_ptr<ModemMessagingClient> client) {
572 DBusThreadManager::Get()->client_bundle_->modem_messaging_client_ =
573 client.Pass();
576 void DBusThreadManagerSetter::SetNfcAdapterClient(
577 scoped_ptr<NfcAdapterClient> client) {
578 DBusThreadManager::Get()->client_bundle_->nfc_adapter_client_ = client.Pass();
581 void DBusThreadManagerSetter::SetNfcDeviceClient(
582 scoped_ptr<NfcDeviceClient> client) {
583 DBusThreadManager::Get()->client_bundle_->nfc_device_client_ = client.Pass();
586 void DBusThreadManagerSetter::SetNfcManagerClient(
587 scoped_ptr<NfcManagerClient> client) {
588 DBusThreadManager::Get()->client_bundle_->nfc_manager_client_ = client.Pass();
591 void DBusThreadManagerSetter::SetNfcRecordClient(
592 scoped_ptr<NfcRecordClient> client) {
593 DBusThreadManager::Get()->client_bundle_->nfc_record_client_ = client.Pass();
596 void DBusThreadManagerSetter::SetNfcTagClient(
597 scoped_ptr<NfcTagClient> client) {
598 DBusThreadManager::Get()->client_bundle_->nfc_tag_client_ = client.Pass();
601 void DBusThreadManagerSetter::SetPermissionBrokerClient(
602 scoped_ptr<PermissionBrokerClient> client) {
603 DBusThreadManager::Get()->client_bundle_->permission_broker_client_ =
604 client.Pass();
607 void DBusThreadManagerSetter::SetPowerManagerClient(
608 scoped_ptr<PowerManagerClient> client) {
609 DBusThreadManager::Get()->power_policy_controller_.reset();
610 DBusThreadManager::Get()->client_bundle_->power_manager_client_ =
611 client.Pass();
612 DBusThreadManager::Get()->power_policy_controller_.reset(
613 new PowerPolicyController);
614 DBusThreadManager::Get()->power_policy_controller_->Init(
615 DBusThreadManager::Get());
618 void DBusThreadManagerSetter::SetSessionManagerClient(
619 scoped_ptr<SessionManagerClient> client) {
620 DBusThreadManager::Get()->client_bundle_->session_manager_client_ =
621 client.Pass();
624 void DBusThreadManagerSetter::SetSMSClient(scoped_ptr<SMSClient> client) {
625 DBusThreadManager::Get()->client_bundle_->sms_client_ = client.Pass();
628 void DBusThreadManagerSetter::SetSystemClockClient(
629 scoped_ptr<SystemClockClient> client) {
630 DBusThreadManager::Get()->client_bundle_->system_clock_client_ =
631 client.Pass();
634 void DBusThreadManagerSetter::SetUpdateEngineClient(
635 scoped_ptr<UpdateEngineClient> client) {
636 DBusThreadManager::Get()->client_bundle_->update_engine_client_ =
637 client.Pass();
640 } // namespace chromeos