| 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 "base/chromeos/chromeos_version.h" | 7 #include "base/chromeos/chromeos_version.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "chromeos/dbus/bluetooth_adapter_client.h" | 9 #include "chromeos/dbus/bluetooth_adapter_client.h" |
| 10 #include "chromeos/dbus/bluetooth_device_client.h" | 10 #include "chromeos/dbus/bluetooth_device_client.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 virtual ~DBusThreadManagerImpl() { | 124 virtual ~DBusThreadManagerImpl() { |
| 125 // Shut down the bus. During the browser shutdown, it's ok to shut down | 125 // Shut down the bus. During the browser shutdown, it's ok to shut down |
| 126 // the bus synchronously. | 126 // the bus synchronously. |
| 127 system_bus_->ShutdownOnDBusThreadAndBlock(); | 127 system_bus_->ShutdownOnDBusThreadAndBlock(); |
| 128 | 128 |
| 129 // Stop the D-Bus thread. | 129 // Stop the D-Bus thread. |
| 130 dbus_thread_->Stop(); | 130 dbus_thread_->Stop(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 // DBusThreadManager override. | 133 // DBusThreadManager override. |
| 134 virtual void MaybeResetIBusBus(const std::string &ibus_address) OVERRIDE { |
| 135 if (ibus_address_ == ibus_address) { |
| 136 // If current address is same as specified, do nothing. |
| 137 return; |
| 138 } |
| 139 |
| 140 if (ibus_bus_) { |
| 141 // If old connection is alive, shutdown it at first. |
| 142 ibus_bus_->ShutdownOnDBusThreadAndBlock(); |
| 143 } |
| 144 dbus::Bus::Options ibus_bus_options; |
| 145 ibus_bus_options.bus_type = dbus::Bus::CUSTOM_ADDRESS; |
| 146 ibus_bus_options.address = ibus_address; |
| 147 ibus_bus_options.connection_type = dbus::Bus::PRIVATE; |
| 148 ibus_bus_options.dbus_thread_message_loop_proxy = |
| 149 dbus_thread_->message_loop_proxy(); |
| 150 ibus_bus_ = new dbus::Bus(ibus_bus_options); |
| 151 ibus_address_ = ibus_address; |
| 152 VLOG(1) << "Connected to ibus-daemon.(address:" << ibus_address << ")"; |
| 153 } |
| 154 |
| 155 // DBusThreadManager override. |
| 134 virtual dbus::Bus* GetSystemBus() OVERRIDE { | 156 virtual dbus::Bus* GetSystemBus() OVERRIDE { |
| 135 return system_bus_.get(); | 157 return system_bus_.get(); |
| 136 } | 158 } |
| 137 | 159 |
| 138 // DBusThreadManager override. | 160 // DBusThreadManager override. |
| 161 virtual dbus::Bus* GetIBusBus() OVERRIDE { |
| 162 return ibus_bus_.get(); |
| 163 } |
| 164 |
| 165 // DBusThreadManager override. |
| 139 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { | 166 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { |
| 140 return bluetooth_adapter_client_.get(); | 167 return bluetooth_adapter_client_.get(); |
| 141 } | 168 } |
| 142 | 169 |
| 143 // DBusThreadManager override. | 170 // DBusThreadManager override. |
| 144 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { | 171 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { |
| 145 return bluetooth_device_client_.get(); | 172 return bluetooth_device_client_.get(); |
| 146 } | 173 } |
| 147 | 174 |
| 148 // DBusThreadManager override. | 175 // DBusThreadManager override. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return speech_synthesizer_client_.get(); | 267 return speech_synthesizer_client_.get(); |
| 241 } | 268 } |
| 242 | 269 |
| 243 // DBusThreadManager override. | 270 // DBusThreadManager override. |
| 244 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { | 271 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { |
| 245 return update_engine_client_.get(); | 272 return update_engine_client_.get(); |
| 246 } | 273 } |
| 247 | 274 |
| 248 scoped_ptr<base::Thread> dbus_thread_; | 275 scoped_ptr<base::Thread> dbus_thread_; |
| 249 scoped_refptr<dbus::Bus> system_bus_; | 276 scoped_refptr<dbus::Bus> system_bus_; |
| 277 scoped_refptr<dbus::Bus> ibus_bus_; |
| 250 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; | 278 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; |
| 251 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; | 279 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; |
| 252 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; | 280 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; |
| 253 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; | 281 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; |
| 254 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_; | 282 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_; |
| 255 scoped_ptr<CashewClient> cashew_client_; | 283 scoped_ptr<CashewClient> cashew_client_; |
| 256 scoped_ptr<CrosDisksClient> cros_disks_client_; | 284 scoped_ptr<CrosDisksClient> cros_disks_client_; |
| 257 scoped_ptr<CryptohomeClient> cryptohome_client_; | 285 scoped_ptr<CryptohomeClient> cryptohome_client_; |
| 258 scoped_ptr<DebugDaemonClient> debugdaemon_client_; | 286 scoped_ptr<DebugDaemonClient> debugdaemon_client_; |
| 259 scoped_ptr<FlimflamDeviceClient> flimflam_device_client_; | 287 scoped_ptr<FlimflamDeviceClient> flimflam_device_client_; |
| 260 scoped_ptr<FlimflamIPConfigClient> flimflam_ipconfig_client_; | 288 scoped_ptr<FlimflamIPConfigClient> flimflam_ipconfig_client_; |
| 261 scoped_ptr<FlimflamManagerClient> flimflam_manager_client_; | 289 scoped_ptr<FlimflamManagerClient> flimflam_manager_client_; |
| 262 scoped_ptr<FlimflamNetworkClient> flimflam_network_client_; | 290 scoped_ptr<FlimflamNetworkClient> flimflam_network_client_; |
| 263 scoped_ptr<FlimflamProfileClient> flimflam_profile_client_; | 291 scoped_ptr<FlimflamProfileClient> flimflam_profile_client_; |
| 264 scoped_ptr<FlimflamServiceClient> flimflam_service_client_; | 292 scoped_ptr<FlimflamServiceClient> flimflam_service_client_; |
| 265 scoped_ptr<GsmSMSClient> gsm_sms_client_; | 293 scoped_ptr<GsmSMSClient> gsm_sms_client_; |
| 266 scoped_ptr<ImageBurnerClient> image_burner_client_; | 294 scoped_ptr<ImageBurnerClient> image_burner_client_; |
| 267 scoped_ptr<IntrospectableClient> introspectable_client_; | 295 scoped_ptr<IntrospectableClient> introspectable_client_; |
| 268 scoped_ptr<PowerManagerClient> power_manager_client_; | 296 scoped_ptr<PowerManagerClient> power_manager_client_; |
| 269 scoped_ptr<SessionManagerClient> session_manager_client_; | 297 scoped_ptr<SessionManagerClient> session_manager_client_; |
| 270 scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_; | 298 scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_; |
| 271 scoped_ptr<UpdateEngineClient> update_engine_client_; | 299 scoped_ptr<UpdateEngineClient> update_engine_client_; |
| 300 |
| 301 std::string ibus_address_; |
| 272 }; | 302 }; |
| 273 | 303 |
| 274 // static | 304 // static |
| 275 void DBusThreadManager::Initialize() { | 305 void DBusThreadManager::Initialize() { |
| 276 if (g_dbus_thread_manager) { | 306 if (g_dbus_thread_manager) { |
| 277 LOG(WARNING) << "DBusThreadManager was already initialized"; | 307 LOG(WARNING) << "DBusThreadManager was already initialized"; |
| 278 return; | 308 return; |
| 279 } | 309 } |
| 280 g_dbus_thread_manager = new DBusThreadManagerImpl; | 310 g_dbus_thread_manager = new DBusThreadManagerImpl; |
| 281 VLOG(1) << "DBusThreadManager initialized"; | 311 VLOG(1) << "DBusThreadManager initialized"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 311 } | 341 } |
| 312 | 342 |
| 313 // static | 343 // static |
| 314 DBusThreadManager* DBusThreadManager::Get() { | 344 DBusThreadManager* DBusThreadManager::Get() { |
| 315 CHECK(g_dbus_thread_manager) | 345 CHECK(g_dbus_thread_manager) |
| 316 << "DBusThreadManager::Get() called before Initialize()"; | 346 << "DBusThreadManager::Get() called before Initialize()"; |
| 317 return g_dbus_thread_manager; | 347 return g_dbus_thread_manager; |
| 318 } | 348 } |
| 319 | 349 |
| 320 } // namespace chromeos | 350 } // namespace chromeos |
| OLD | NEW |