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/chromeos/chromeos_version.h" | 9 #include "base/chromeos/chromeos_version.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.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" | |
15 #include "chromeos/dbus/bluetooth_device_client.h" | |
16 #include "chromeos/dbus/bluetooth_input_client.h" | |
17 #include "chromeos/dbus/bluetooth_manager_client.h" | |
18 #include "chromeos/dbus/bluetooth_node_client.h" | |
19 #include "chromeos/dbus/bluetooth_out_of_band_client.h" | |
20 #include "chromeos/dbus/cras_audio_client.h" | 14 #include "chromeos/dbus/cras_audio_client.h" |
21 #include "chromeos/dbus/cros_disks_client.h" | 15 #include "chromeos/dbus/cros_disks_client.h" |
22 #include "chromeos/dbus/cryptohome_client.h" | 16 #include "chromeos/dbus/cryptohome_client.h" |
23 #include "chromeos/dbus/dbus_client_implementation_type.h" | 17 #include "chromeos/dbus/dbus_client_implementation_type.h" |
24 #include "chromeos/dbus/dbus_thread_manager_observer.h" | 18 #include "chromeos/dbus/dbus_thread_manager_observer.h" |
25 #include "chromeos/dbus/debug_daemon_client.h" | 19 #include "chromeos/dbus/debug_daemon_client.h" |
26 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" | 20 #include "chromeos/dbus/experimental_bluetooth_adapter_client.h" |
27 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" | 21 #include "chromeos/dbus/experimental_bluetooth_agent_manager_client.h" |
28 #include "chromeos/dbus/experimental_bluetooth_device_client.h" | 22 #include "chromeos/dbus/experimental_bluetooth_device_client.h" |
29 #include "chromeos/dbus/experimental_bluetooth_input_client.h" | 23 #include "chromeos/dbus/experimental_bluetooth_input_client.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 system_bus_options.bus_type = dbus::Bus::SYSTEM; | 76 system_bus_options.bus_type = dbus::Bus::SYSTEM; |
83 system_bus_options.connection_type = dbus::Bus::PRIVATE; | 77 system_bus_options.connection_type = dbus::Bus::PRIVATE; |
84 system_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); | 78 system_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); |
85 system_bus_ = new dbus::Bus(system_bus_options); | 79 system_bus_ = new dbus::Bus(system_bus_options); |
86 } | 80 } |
87 | 81 |
88 // InitializeClients gets called after g_dbus_thread_manager is set. | 82 // InitializeClients gets called after g_dbus_thread_manager is set. |
89 // NOTE: Clients that access other clients in their constructor must be | 83 // NOTE: Clients that access other clients in their constructor must be |
90 // construced in the correct order. | 84 // construced in the correct order. |
91 void InitializeClients() { | 85 void InitializeClients() { |
92 bluetooth_manager_client_.reset(BluetoothManagerClient::Create( | |
93 client_type_, system_bus_.get())); | |
94 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create( | |
95 client_type_, system_bus_.get(), bluetooth_manager_client_.get())); | |
96 bluetooth_device_client_.reset(BluetoothDeviceClient::Create( | |
97 client_type_, system_bus_.get(), bluetooth_adapter_client_.get())); | |
98 bluetooth_input_client_.reset(BluetoothInputClient::Create( | |
99 client_type_, system_bus_.get(), bluetooth_adapter_client_.get())); | |
100 bluetooth_node_client_.reset(BluetoothNodeClient::Create( | |
101 client_type_, system_bus_.get(), bluetooth_device_client_.get())); | |
102 bluetooth_out_of_band_client_.reset(BluetoothOutOfBandClient::Create( | |
103 client_type_, system_bus_.get())); | |
104 cras_audio_client_.reset(CrasAudioClient::Create( | 86 cras_audio_client_.reset(CrasAudioClient::Create( |
105 client_type_, system_bus_.get())); | 87 client_type_, system_bus_.get())); |
106 cros_disks_client_.reset( | 88 cros_disks_client_.reset( |
107 CrosDisksClient::Create(client_type_, system_bus_.get())); | 89 CrosDisksClient::Create(client_type_, system_bus_.get())); |
108 cryptohome_client_.reset( | 90 cryptohome_client_.reset( |
109 CryptohomeClient::Create(client_type_, system_bus_.get())); | 91 CryptohomeClient::Create(client_type_, system_bus_.get())); |
110 debug_daemon_client_.reset( | 92 debug_daemon_client_.reset( |
111 DebugDaemonClient::Create(client_type_, system_bus_.get())); | 93 DebugDaemonClient::Create(client_type_, system_bus_.get())); |
112 | 94 |
113 experimental_bluetooth_adapter_client_.reset( | 95 experimental_bluetooth_adapter_client_.reset( |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 220 |
239 // DBusThreadManager overrides: | 221 // DBusThreadManager overrides: |
240 virtual dbus::Bus* GetSystemBus() OVERRIDE { | 222 virtual dbus::Bus* GetSystemBus() OVERRIDE { |
241 return system_bus_.get(); | 223 return system_bus_.get(); |
242 } | 224 } |
243 | 225 |
244 virtual dbus::Bus* GetIBusBus() OVERRIDE { | 226 virtual dbus::Bus* GetIBusBus() OVERRIDE { |
245 return ibus_bus_.get(); | 227 return ibus_bus_.get(); |
246 } | 228 } |
247 | 229 |
248 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { | |
249 return bluetooth_adapter_client_.get(); | |
250 } | |
251 | |
252 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { | |
253 return bluetooth_device_client_.get(); | |
254 } | |
255 | |
256 virtual BluetoothInputClient* GetBluetoothInputClient() OVERRIDE { | |
257 return bluetooth_input_client_.get(); | |
258 } | |
259 | |
260 virtual BluetoothManagerClient* GetBluetoothManagerClient() OVERRIDE { | |
261 return bluetooth_manager_client_.get(); | |
262 } | |
263 | |
264 virtual BluetoothNodeClient* GetBluetoothNodeClient() OVERRIDE { | |
265 return bluetooth_node_client_.get(); | |
266 } | |
267 | |
268 virtual BluetoothOutOfBandClient* GetBluetoothOutOfBandClient() OVERRIDE { | |
269 return bluetooth_out_of_band_client_.get(); | |
270 } | |
271 | |
272 virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE { | 230 virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE { |
273 return cras_audio_client_.get(); | 231 return cras_audio_client_.get(); |
274 } | 232 } |
275 | 233 |
276 virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE { | 234 virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE { |
277 return cros_disks_client_.get(); | 235 return cros_disks_client_.get(); |
278 } | 236 } |
279 | 237 |
280 virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE { | 238 virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE { |
281 return cryptohome_client_.get(); | 239 return cryptohome_client_.get(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 DBusClientImplementationType client_type_; | 380 DBusClientImplementationType client_type_; |
423 DBusClientImplementationType client_type_override_; | 381 DBusClientImplementationType client_type_override_; |
424 | 382 |
425 // Note: Keep this before other members so they can call AddObserver() in | 383 // Note: Keep this before other members so they can call AddObserver() in |
426 // their c'tors. | 384 // their c'tors. |
427 ObserverList<DBusThreadManagerObserver> observers_; | 385 ObserverList<DBusThreadManagerObserver> observers_; |
428 | 386 |
429 scoped_ptr<base::Thread> dbus_thread_; | 387 scoped_ptr<base::Thread> dbus_thread_; |
430 scoped_refptr<dbus::Bus> system_bus_; | 388 scoped_refptr<dbus::Bus> system_bus_; |
431 scoped_refptr<dbus::Bus> ibus_bus_; | 389 scoped_refptr<dbus::Bus> ibus_bus_; |
432 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; | |
433 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; | |
434 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; | |
435 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; | |
436 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_; | |
437 scoped_ptr<BluetoothOutOfBandClient> bluetooth_out_of_band_client_; | |
438 scoped_ptr<CrasAudioClient> cras_audio_client_; | 390 scoped_ptr<CrasAudioClient> cras_audio_client_; |
439 scoped_ptr<CrosDisksClient> cros_disks_client_; | 391 scoped_ptr<CrosDisksClient> cros_disks_client_; |
440 scoped_ptr<CryptohomeClient> cryptohome_client_; | 392 scoped_ptr<CryptohomeClient> cryptohome_client_; |
441 scoped_ptr<DebugDaemonClient> debug_daemon_client_; | 393 scoped_ptr<DebugDaemonClient> debug_daemon_client_; |
442 scoped_ptr<ExperimentalBluetoothAdapterClient> | 394 scoped_ptr<ExperimentalBluetoothAdapterClient> |
443 experimental_bluetooth_adapter_client_; | 395 experimental_bluetooth_adapter_client_; |
444 scoped_ptr<ExperimentalBluetoothAgentManagerClient> | 396 scoped_ptr<ExperimentalBluetoothAgentManagerClient> |
445 experimental_bluetooth_agent_manager_client_; | 397 experimental_bluetooth_agent_manager_client_; |
446 scoped_ptr<ExperimentalBluetoothDeviceClient> | 398 scoped_ptr<ExperimentalBluetoothDeviceClient> |
447 experimental_bluetooth_device_client_; | 399 experimental_bluetooth_device_client_; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 510 } |
559 | 511 |
560 // static | 512 // static |
561 DBusThreadManager* DBusThreadManager::Get() { | 513 DBusThreadManager* DBusThreadManager::Get() { |
562 CHECK(g_dbus_thread_manager) | 514 CHECK(g_dbus_thread_manager) |
563 << "DBusThreadManager::Get() called before Initialize()"; | 515 << "DBusThreadManager::Get() called before Initialize()"; |
564 return g_dbus_thread_manager; | 516 return g_dbus_thread_manager; |
565 } | 517 } |
566 | 518 |
567 } // namespace chromeos | 519 } // namespace chromeos |
OLD | NEW |