| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/dbus/dbus_thread_manager.h" | 5 #include "chromeos/dbus/dbus_thread_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
| 13 #include "chromeos/chromeos_switches.h" | 13 #include "chromeos/chromeos_switches.h" |
| 14 #include "chromeos/dbus/bluetooth_adapter_client.h" | 14 #include "chromeos/dbus/bluetooth_adapter_client.h" |
| 15 #include "chromeos/dbus/bluetooth_agent_manager_client.h" | 15 #include "chromeos/dbus/bluetooth_agent_manager_client.h" |
| 16 #include "chromeos/dbus/bluetooth_device_client.h" | 16 #include "chromeos/dbus/bluetooth_device_client.h" |
| 17 #include "chromeos/dbus/bluetooth_input_client.h" | 17 #include "chromeos/dbus/bluetooth_input_client.h" |
| 18 #include "chromeos/dbus/bluetooth_profile_manager_client.h" | 18 #include "chromeos/dbus/bluetooth_profile_manager_client.h" |
| 19 #include "chromeos/dbus/cras_audio_client.h" | 19 #include "chromeos/dbus/cras_audio_client.h" |
| 20 #include "chromeos/dbus/cros_disks_client.h" | 20 #include "chromeos/dbus/cros_disks_client.h" |
| 21 #include "chromeos/dbus/cryptohome_client.h" | 21 #include "chromeos/dbus/cryptohome_client.h" |
| 22 #include "chromeos/dbus/dbus_client.h" | 22 #include "chromeos/dbus/dbus_client.h" |
| 23 #include "chromeos/dbus/dbus_client_implementation_type.h" | 23 #include "chromeos/dbus/dbus_client_implementation_type.h" |
| 24 #include "chromeos/dbus/dbus_thread_manager_observer.h" | 24 #include "chromeos/dbus/dbus_thread_manager_observer.h" |
| 25 #include "chromeos/dbus/debug_daemon_client.h" | 25 #include "chromeos/dbus/debug_daemon_client.h" |
| 26 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 26 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
| 27 #include "chromeos/dbus/gsm_sms_client.h" | 27 #include "chromeos/dbus/gsm_sms_client.h" |
| 28 #include "chromeos/dbus/ibus/ibus_client.h" | |
| 29 #include "chromeos/dbus/image_burner_client.h" | 28 #include "chromeos/dbus/image_burner_client.h" |
| 30 #include "chromeos/dbus/introspectable_client.h" | 29 #include "chromeos/dbus/introspectable_client.h" |
| 31 #include "chromeos/dbus/modem_messaging_client.h" | 30 #include "chromeos/dbus/modem_messaging_client.h" |
| 32 #include "chromeos/dbus/nfc_adapter_client.h" | 31 #include "chromeos/dbus/nfc_adapter_client.h" |
| 33 #include "chromeos/dbus/nfc_device_client.h" | 32 #include "chromeos/dbus/nfc_device_client.h" |
| 34 #include "chromeos/dbus/nfc_manager_client.h" | 33 #include "chromeos/dbus/nfc_manager_client.h" |
| 35 #include "chromeos/dbus/nfc_record_client.h" | 34 #include "chromeos/dbus/nfc_record_client.h" |
| 36 #include "chromeos/dbus/nfc_tag_client.h" | 35 #include "chromeos/dbus/nfc_tag_client.h" |
| 37 #include "chromeos/dbus/permission_broker_client.h" | 36 #include "chromeos/dbus/permission_broker_client.h" |
| 38 #include "chromeos/dbus/power_manager_client.h" | 37 #include "chromeos/dbus/power_manager_client.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 virtual void AddObserver(DBusThreadManagerObserver* observer) OVERRIDE { | 90 virtual void AddObserver(DBusThreadManagerObserver* observer) OVERRIDE { |
| 92 DCHECK(observer); | 91 DCHECK(observer); |
| 93 observers_.AddObserver(observer); | 92 observers_.AddObserver(observer); |
| 94 } | 93 } |
| 95 | 94 |
| 96 virtual void RemoveObserver(DBusThreadManagerObserver* observer) OVERRIDE { | 95 virtual void RemoveObserver(DBusThreadManagerObserver* observer) OVERRIDE { |
| 97 DCHECK(observer); | 96 DCHECK(observer); |
| 98 observers_.RemoveObserver(observer); | 97 observers_.RemoveObserver(observer); |
| 99 } | 98 } |
| 100 | 99 |
| 101 virtual void InitIBusBus( | |
| 102 const std::string &ibus_address, | |
| 103 const base::Closure& on_disconnected_callback) OVERRIDE { | |
| 104 ibus_client_.reset(IBusClient::Create()); | |
| 105 } | |
| 106 | |
| 107 virtual dbus::Bus* GetSystemBus() OVERRIDE { | 100 virtual dbus::Bus* GetSystemBus() OVERRIDE { |
| 108 return system_bus_.get(); | 101 return system_bus_.get(); |
| 109 } | 102 } |
| 110 | 103 |
| 111 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { | 104 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { |
| 112 return bluetooth_adapter_client_.get(); | 105 return bluetooth_adapter_client_.get(); |
| 113 } | 106 } |
| 114 | 107 |
| 115 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() | 108 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() |
| 116 OVERRIDE { | 109 OVERRIDE { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 216 } |
| 224 | 217 |
| 225 virtual SystemClockClient* GetSystemClockClient() OVERRIDE { | 218 virtual SystemClockClient* GetSystemClockClient() OVERRIDE { |
| 226 return system_clock_client_.get(); | 219 return system_clock_client_.get(); |
| 227 } | 220 } |
| 228 | 221 |
| 229 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { | 222 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { |
| 230 return update_engine_client_.get(); | 223 return update_engine_client_.get(); |
| 231 } | 224 } |
| 232 | 225 |
| 233 virtual IBusClient* GetIBusClient() OVERRIDE { | |
| 234 return ibus_client_.get(); | |
| 235 } | |
| 236 | |
| 237 private: | 226 private: |
| 238 // Constructs all clients -- stub or real implementation according to | 227 // Constructs all clients -- stub or real implementation according to |
| 239 // |client_type| and |client_type_override| -- and stores them in the | 228 // |client_type| and |client_type_override| -- and stores them in the |
| 240 // respective *_client_ member variable. | 229 // respective *_client_ member variable. |
| 241 void CreateDefaultClients() { | 230 void CreateDefaultClients() { |
| 242 DBusClientImplementationType client_type = REAL_DBUS_CLIENT_IMPLEMENTATION; | 231 DBusClientImplementationType client_type = REAL_DBUS_CLIENT_IMPLEMENTATION; |
| 243 DBusClientImplementationType client_type_override = | 232 DBusClientImplementationType client_type_override = |
| 244 REAL_DBUS_CLIENT_IMPLEMENTATION; | 233 REAL_DBUS_CLIENT_IMPLEMENTATION; |
| 245 // If --dbus-stub was requested, pass STUB to specific components; | 234 // If --dbus-stub was requested, pass STUB to specific components; |
| 246 // Many components like login are not useful with a stub implementation. | 235 // Many components like login are not useful with a stub implementation. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 scoped_ptr<NfcAdapterClient> nfc_adapter_client_; | 317 scoped_ptr<NfcAdapterClient> nfc_adapter_client_; |
| 329 scoped_ptr<NfcDeviceClient> nfc_device_client_; | 318 scoped_ptr<NfcDeviceClient> nfc_device_client_; |
| 330 scoped_ptr<NfcTagClient> nfc_tag_client_; | 319 scoped_ptr<NfcTagClient> nfc_tag_client_; |
| 331 scoped_ptr<NfcRecordClient> nfc_record_client_; | 320 scoped_ptr<NfcRecordClient> nfc_record_client_; |
| 332 scoped_ptr<PermissionBrokerClient> permission_broker_client_; | 321 scoped_ptr<PermissionBrokerClient> permission_broker_client_; |
| 333 scoped_ptr<SystemClockClient> system_clock_client_; | 322 scoped_ptr<SystemClockClient> system_clock_client_; |
| 334 scoped_ptr<PowerManagerClient> power_manager_client_; | 323 scoped_ptr<PowerManagerClient> power_manager_client_; |
| 335 scoped_ptr<SessionManagerClient> session_manager_client_; | 324 scoped_ptr<SessionManagerClient> session_manager_client_; |
| 336 scoped_ptr<SMSClient> sms_client_; | 325 scoped_ptr<SMSClient> sms_client_; |
| 337 scoped_ptr<UpdateEngineClient> update_engine_client_; | 326 scoped_ptr<UpdateEngineClient> update_engine_client_; |
| 338 scoped_ptr<IBusClient> ibus_client_; | |
| 339 | 327 |
| 340 scoped_ptr<PowerPolicyController> power_policy_controller_; | 328 scoped_ptr<PowerPolicyController> power_policy_controller_; |
| 341 }; | 329 }; |
| 342 | 330 |
| 343 // static | 331 // static |
| 344 void DBusThreadManager::Initialize() { | 332 void DBusThreadManager::Initialize() { |
| 345 // Ignore Initialize() if we set a test DBusThreadManager. | 333 // Ignore Initialize() if we set a test DBusThreadManager. |
| 346 if (g_dbus_thread_manager_set_for_testing) | 334 if (g_dbus_thread_manager_set_for_testing) |
| 347 return; | 335 return; |
| 348 // If we initialize DBusThreadManager twice we may also be shutting it down | 336 // If we initialize DBusThreadManager twice we may also be shutting it down |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); | 461 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); |
| 474 } | 462 } |
| 475 | 463 |
| 476 // static | 464 // static |
| 477 void DBusThreadManager::InitClient(DBusClient* client) { | 465 void DBusThreadManager::InitClient(DBusClient* client) { |
| 478 if (client) | 466 if (client) |
| 479 client->Init(g_dbus_thread_manager->GetSystemBus()); | 467 client->Init(g_dbus_thread_manager->GetSystemBus()); |
| 480 } | 468 } |
| 481 | 469 |
| 482 } // namespace chromeos | 470 } // namespace chromeos |
| OLD | NEW |