Chromium Code Reviews| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 SpeechSynthesizerClient::Create(client_type, system_bus_.get())); | 122 SpeechSynthesizerClient::Create(client_type, system_bus_.get())); |
| 123 // Create the update engine client. | 123 // Create the update engine client. |
| 124 update_engine_client_.reset( | 124 update_engine_client_.reset( |
| 125 UpdateEngineClient::Create(client_type, system_bus_.get())); | 125 UpdateEngineClient::Create(client_type, system_bus_.get())); |
| 126 } | 126 } |
| 127 | 127 |
| 128 virtual ~DBusThreadManagerImpl() { | 128 virtual ~DBusThreadManagerImpl() { |
| 129 // Shut down the bus. During the browser shutdown, it's ok to shut down | 129 // Shut down the bus. During the browser shutdown, it's ok to shut down |
| 130 // the bus synchronously. | 130 // the bus synchronously. |
| 131 system_bus_->ShutdownOnDBusThreadAndBlock(); | 131 system_bus_->ShutdownOnDBusThreadAndBlock(); |
| 132 ibus_bus_->ShutdownOnDBusThreadAndBlock(); | |
|
satorux1
2012/05/18 00:50:50
This looks unsafe. ibus_bus_ is optional, right?
Seigo Nonaka
2012/05/18 01:00:48
Yes, thanks.
On 2012/05/18 00:50:50, satorux1 wrot
| |
| 132 | 133 |
| 133 // Stop the D-Bus thread. | 134 // Stop the D-Bus thread. |
| 134 dbus_thread_->Stop(); | 135 dbus_thread_->Stop(); |
| 135 } | 136 } |
| 136 | 137 |
| 137 // DBusThreadManager override. | 138 // DBusThreadManager override. |
| 139 virtual void InitIBusBus(const std::string &ibus_address) OVERRIDE { | |
| 140 DCHECK(!ibus_bus_); | |
| 141 dbus::Bus::Options ibus_bus_options; | |
| 142 ibus_bus_options.bus_type = dbus::Bus::CUSTOM_ADDRESS; | |
| 143 ibus_bus_options.address = ibus_address; | |
| 144 ibus_bus_options.connection_type = dbus::Bus::PRIVATE; | |
| 145 ibus_bus_options.dbus_thread_message_loop_proxy = | |
| 146 dbus_thread_->message_loop_proxy(); | |
| 147 ibus_bus_ = new dbus::Bus(ibus_bus_options); | |
| 148 ibus_address_ = ibus_address; | |
| 149 VLOG(1) << "Connected to ibus-daemon.(address:" << ibus_address << ")"; | |
|
satorux1
2012/05/18 00:50:50
nit:
VLOG(1) << "Connected to ibus-daemon:" << ib
Seigo Nonaka
2012/05/18 01:00:48
Done.
| |
| 150 } | |
| 151 | |
| 152 // DBusThreadManager override. | |
| 138 virtual dbus::Bus* GetSystemBus() OVERRIDE { | 153 virtual dbus::Bus* GetSystemBus() OVERRIDE { |
| 139 return system_bus_.get(); | 154 return system_bus_.get(); |
| 140 } | 155 } |
| 141 | 156 |
| 142 // DBusThreadManager override. | 157 // DBusThreadManager override. |
| 158 virtual dbus::Bus* GetIBusBus() OVERRIDE { | |
| 159 return ibus_bus_.get(); | |
| 160 } | |
| 161 | |
| 162 // DBusThreadManager override. | |
| 143 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { | 163 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { |
| 144 return bluetooth_adapter_client_.get(); | 164 return bluetooth_adapter_client_.get(); |
| 145 } | 165 } |
| 146 | 166 |
| 147 // DBusThreadManager override. | 167 // DBusThreadManager override. |
| 148 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { | 168 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { |
| 149 return bluetooth_device_client_.get(); | 169 return bluetooth_device_client_.get(); |
| 150 } | 170 } |
| 151 | 171 |
| 152 // DBusThreadManager override. | 172 // DBusThreadManager override. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 return speech_synthesizer_client_.get(); | 264 return speech_synthesizer_client_.get(); |
| 245 } | 265 } |
| 246 | 266 |
| 247 // DBusThreadManager override. | 267 // DBusThreadManager override. |
| 248 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { | 268 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { |
| 249 return update_engine_client_.get(); | 269 return update_engine_client_.get(); |
| 250 } | 270 } |
| 251 | 271 |
| 252 scoped_ptr<base::Thread> dbus_thread_; | 272 scoped_ptr<base::Thread> dbus_thread_; |
| 253 scoped_refptr<dbus::Bus> system_bus_; | 273 scoped_refptr<dbus::Bus> system_bus_; |
| 274 scoped_refptr<dbus::Bus> ibus_bus_; | |
| 254 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; | 275 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; |
| 255 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; | 276 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; |
| 256 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; | 277 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; |
| 257 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; | 278 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; |
| 258 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_; | 279 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_; |
| 259 scoped_ptr<CashewClient> cashew_client_; | 280 scoped_ptr<CashewClient> cashew_client_; |
| 260 scoped_ptr<CrosDisksClient> cros_disks_client_; | 281 scoped_ptr<CrosDisksClient> cros_disks_client_; |
| 261 scoped_ptr<CryptohomeClient> cryptohome_client_; | 282 scoped_ptr<CryptohomeClient> cryptohome_client_; |
| 262 scoped_ptr<DebugDaemonClient> debugdaemon_client_; | 283 scoped_ptr<DebugDaemonClient> debugdaemon_client_; |
| 263 scoped_ptr<FlimflamDeviceClient> flimflam_device_client_; | 284 scoped_ptr<FlimflamDeviceClient> flimflam_device_client_; |
| 264 scoped_ptr<FlimflamIPConfigClient> flimflam_ipconfig_client_; | 285 scoped_ptr<FlimflamIPConfigClient> flimflam_ipconfig_client_; |
| 265 scoped_ptr<FlimflamManagerClient> flimflam_manager_client_; | 286 scoped_ptr<FlimflamManagerClient> flimflam_manager_client_; |
| 266 scoped_ptr<FlimflamNetworkClient> flimflam_network_client_; | 287 scoped_ptr<FlimflamNetworkClient> flimflam_network_client_; |
| 267 scoped_ptr<FlimflamProfileClient> flimflam_profile_client_; | 288 scoped_ptr<FlimflamProfileClient> flimflam_profile_client_; |
| 268 scoped_ptr<FlimflamServiceClient> flimflam_service_client_; | 289 scoped_ptr<FlimflamServiceClient> flimflam_service_client_; |
| 269 scoped_ptr<GsmSMSClient> gsm_sms_client_; | 290 scoped_ptr<GsmSMSClient> gsm_sms_client_; |
| 270 scoped_ptr<ImageBurnerClient> image_burner_client_; | 291 scoped_ptr<ImageBurnerClient> image_burner_client_; |
| 271 scoped_ptr<IntrospectableClient> introspectable_client_; | 292 scoped_ptr<IntrospectableClient> introspectable_client_; |
| 272 scoped_ptr<PowerManagerClient> power_manager_client_; | 293 scoped_ptr<PowerManagerClient> power_manager_client_; |
| 273 scoped_ptr<SessionManagerClient> session_manager_client_; | 294 scoped_ptr<SessionManagerClient> session_manager_client_; |
| 274 scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_; | 295 scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_; |
| 275 scoped_ptr<UpdateEngineClient> update_engine_client_; | 296 scoped_ptr<UpdateEngineClient> update_engine_client_; |
| 297 | |
| 298 std::string ibus_address_; | |
| 276 }; | 299 }; |
| 277 | 300 |
| 278 // static | 301 // static |
| 279 void DBusThreadManager::Initialize() { | 302 void DBusThreadManager::Initialize() { |
| 280 if (g_dbus_thread_manager) { | 303 if (g_dbus_thread_manager) { |
| 281 LOG(WARNING) << "DBusThreadManager was already initialized"; | 304 LOG(WARNING) << "DBusThreadManager was already initialized"; |
| 282 return; | 305 return; |
| 283 } | 306 } |
| 284 // Determine whether we use stub or real client implementations. | 307 // Determine whether we use stub or real client implementations. |
| 285 if (base::chromeos::IsRunningOnChromeOS()) { | 308 if (base::chromeos::IsRunningOnChromeOS()) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 } | 354 } |
| 332 | 355 |
| 333 // static | 356 // static |
| 334 DBusThreadManager* DBusThreadManager::Get() { | 357 DBusThreadManager* DBusThreadManager::Get() { |
| 335 CHECK(g_dbus_thread_manager) | 358 CHECK(g_dbus_thread_manager) |
| 336 << "DBusThreadManager::Get() called before Initialize()"; | 359 << "DBusThreadManager::Get() called before Initialize()"; |
| 337 return g_dbus_thread_manager; | 360 return g_dbus_thread_manager; |
| 338 } | 361 } |
| 339 | 362 |
| 340 } // namespace chromeos | 363 } // namespace chromeos |
| OLD | NEW |