Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chromeos/dbus/dbus_thread_manager.cc

Issue 10159004: Extends DBusThreadManager to connect ibus-bus. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chromeos/dbus/bluetooth_input_client.h" 11 #include "chromeos/dbus/bluetooth_input_client.h"
12 #include "chromeos/dbus/bluetooth_manager_client.h" 12 #include "chromeos/dbus/bluetooth_manager_client.h"
13 #include "chromeos/dbus/bluetooth_node_client.h" 13 #include "chromeos/dbus/bluetooth_node_client.h"
14 #include "chromeos/dbus/cashew_client.h" 14 #include "chromeos/dbus/cashew_client.h"
15 #include "chromeos/dbus/cros_disks_client.h" 15 #include "chromeos/dbus/cros_disks_client.h"
16 #include "chromeos/dbus/cryptohome_client.h" 16 #include "chromeos/dbus/cryptohome_client.h"
17 #include "chromeos/dbus/dbus_client_implementation_type.h" 17 #include "chromeos/dbus/dbus_client_implementation_type.h"
18 #include "chromeos/dbus/debug_daemon_client.h" 18 #include "chromeos/dbus/debug_daemon_client.h"
19 #include "chromeos/dbus/flimflam_device_client.h" 19 #include "chromeos/dbus/flimflam_device_client.h"
20 #include "chromeos/dbus/flimflam_ipconfig_client.h" 20 #include "chromeos/dbus/flimflam_ipconfig_client.h"
21 #include "chromeos/dbus/flimflam_manager_client.h" 21 #include "chromeos/dbus/flimflam_manager_client.h"
22 #include "chromeos/dbus/flimflam_network_client.h" 22 #include "chromeos/dbus/flimflam_network_client.h"
23 #include "chromeos/dbus/flimflam_profile_client.h" 23 #include "chromeos/dbus/flimflam_profile_client.h"
24 #include "chromeos/dbus/flimflam_service_client.h" 24 #include "chromeos/dbus/flimflam_service_client.h"
25 #include "chromeos/dbus/gsm_sms_client.h" 25 #include "chromeos/dbus/gsm_sms_client.h"
26 #include "chromeos/dbus/ibus/ibus_util.h"
26 #include "chromeos/dbus/image_burner_client.h" 27 #include "chromeos/dbus/image_burner_client.h"
27 #include "chromeos/dbus/introspectable_client.h" 28 #include "chromeos/dbus/introspectable_client.h"
28 #include "chromeos/dbus/power_manager_client.h" 29 #include "chromeos/dbus/power_manager_client.h"
29 #include "chromeos/dbus/session_manager_client.h" 30 #include "chromeos/dbus/session_manager_client.h"
30 #include "chromeos/dbus/speech_synthesizer_client.h" 31 #include "chromeos/dbus/speech_synthesizer_client.h"
31 #include "chromeos/dbus/update_engine_client.h" 32 #include "chromeos/dbus/update_engine_client.h"
32 #include "dbus/bus.h" 33 #include "dbus/bus.h"
33 34
34 namespace chromeos { 35 namespace chromeos {
35
satorux1 2012/04/20 23:18:40 don't remove this.
Seigo Nonaka 2012/04/23 23:03:21 Done.
36 static DBusThreadManager* g_dbus_thread_manager = NULL; 36 static DBusThreadManager* g_dbus_thread_manager = NULL;
37 37
38 // The DBusThreadManager implementation used in production. 38 // The DBusThreadManager implementation used in production.
39 class DBusThreadManagerImpl : public DBusThreadManager { 39 class DBusThreadManagerImpl : public DBusThreadManager {
40 public: 40 public:
41 DBusThreadManagerImpl() { 41 DBusThreadManagerImpl() {
42 // Create the D-Bus thread. 42 // Create the D-Bus thread.
43 base::Thread::Options thread_options; 43 base::Thread::Options thread_options;
44 thread_options.message_loop_type = MessageLoop::TYPE_IO; 44 thread_options.message_loop_type = MessageLoop::TYPE_IO;
45 dbus_thread_.reset(new base::Thread("D-Bus thread")); 45 dbus_thread_.reset(new base::Thread("D-Bus thread"));
46 dbus_thread_->StartWithOptions(thread_options); 46 dbus_thread_->StartWithOptions(thread_options);
47 47
48 // Create the connection to the system bus. 48 // Create the connection to the system bus.
49 dbus::Bus::Options system_bus_options; 49 dbus::Bus::Options system_bus_options;
50 system_bus_options.bus_type = dbus::Bus::SYSTEM; 50 system_bus_options.bus_type = dbus::Bus::SYSTEM;
51 system_bus_options.connection_type = dbus::Bus::PRIVATE; 51 system_bus_options.connection_type = dbus::Bus::PRIVATE;
52 system_bus_options.dbus_thread_message_loop_proxy = 52 system_bus_options.dbus_thread_message_loop_proxy =
53 dbus_thread_->message_loop_proxy(); 53 dbus_thread_->message_loop_proxy();
54 system_bus_ = new dbus::Bus(system_bus_options); 54 system_bus_ = new dbus::Bus(system_bus_options);
55 55
56 // Create the connection to the ibus bus.
57 std::string ibus_address;
58 if (IBusUtil::GetIBusAddress(&ibus_address)) {
59 dbus::Bus::Options ibus_bus_options;
60 ibus_bus_options.bus_type = dbus::Bus::CUSTOM_ADDRESS;
61 ibus_bus_options.address = ibus_address;
62 ibus_bus_options.connection_type = dbus::Bus::PRIVATE;
63 ibus_bus_options.dbus_thread_message_loop_proxy =
64 dbus_thread_->message_loop_proxy();
65 ibus_bus_ = new dbus::Bus(ibus_bus_options);
66 VLOG(1) << "Connected to ibus-daemon.(address:" << ibus_address << ")";
67 } else {
68 LOG(ERROR) << "Can not connect to ibus-daemon.";
69 }
70
56 // Determine whether we use stub or real client implementations. 71 // Determine whether we use stub or real client implementations.
57 const DBusClientImplementationType client_type = 72 const DBusClientImplementationType client_type =
58 base::chromeos::IsRunningOnChromeOS() ? 73 base::chromeos::IsRunningOnChromeOS() ?
59 REAL_DBUS_CLIENT_IMPLEMENTATION : STUB_DBUS_CLIENT_IMPLEMENTATION; 74 REAL_DBUS_CLIENT_IMPLEMENTATION : STUB_DBUS_CLIENT_IMPLEMENTATION;
60 75
61 // Create the bluetooth clients. 76 // Create the bluetooth clients.
62 bluetooth_manager_client_.reset(BluetoothManagerClient::Create( 77 bluetooth_manager_client_.reset(BluetoothManagerClient::Create(
63 client_type, system_bus_.get())); 78 client_type, system_bus_.get()));
64 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create( 79 bluetooth_adapter_client_.reset(BluetoothAdapterClient::Create(
65 client_type, system_bus_.get(), bluetooth_manager_client_.get())); 80 client_type, system_bus_.get(), bluetooth_manager_client_.get()));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Stop the D-Bus thread. 144 // Stop the D-Bus thread.
130 dbus_thread_->Stop(); 145 dbus_thread_->Stop();
131 } 146 }
132 147
133 // DBusThreadManager override. 148 // DBusThreadManager override.
134 virtual dbus::Bus* GetSystemBus() OVERRIDE { 149 virtual dbus::Bus* GetSystemBus() OVERRIDE {
135 return system_bus_.get(); 150 return system_bus_.get();
136 } 151 }
137 152
138 // DBusThreadManager override. 153 // DBusThreadManager override.
154 virtual dbus::Bus* GetIBusBus() OVERRIDE {
155 return ibus_bus_.get();
156 }
157
158 // DBusThreadManager override.
139 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { 159 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE {
140 return bluetooth_adapter_client_.get(); 160 return bluetooth_adapter_client_.get();
141 } 161 }
142 162
143 // DBusThreadManager override. 163 // DBusThreadManager override.
144 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { 164 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE {
145 return bluetooth_device_client_.get(); 165 return bluetooth_device_client_.get();
146 } 166 }
147 167
148 // DBusThreadManager override. 168 // DBusThreadManager override.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 return speech_synthesizer_client_.get(); 260 return speech_synthesizer_client_.get();
241 } 261 }
242 262
243 // DBusThreadManager override. 263 // DBusThreadManager override.
244 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { 264 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE {
245 return update_engine_client_.get(); 265 return update_engine_client_.get();
246 } 266 }
247 267
248 scoped_ptr<base::Thread> dbus_thread_; 268 scoped_ptr<base::Thread> dbus_thread_;
249 scoped_refptr<dbus::Bus> system_bus_; 269 scoped_refptr<dbus::Bus> system_bus_;
270 scoped_refptr<dbus::Bus> ibus_bus_;
250 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; 271 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_;
251 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; 272 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_;
252 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; 273 scoped_ptr<BluetoothInputClient> bluetooth_input_client_;
253 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; 274 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_;
254 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_; 275 scoped_ptr<BluetoothNodeClient> bluetooth_node_client_;
255 scoped_ptr<CashewClient> cashew_client_; 276 scoped_ptr<CashewClient> cashew_client_;
256 scoped_ptr<CrosDisksClient> cros_disks_client_; 277 scoped_ptr<CrosDisksClient> cros_disks_client_;
257 scoped_ptr<CryptohomeClient> cryptohome_client_; 278 scoped_ptr<CryptohomeClient> cryptohome_client_;
258 scoped_ptr<DebugDaemonClient> debugdaemon_client_; 279 scoped_ptr<DebugDaemonClient> debugdaemon_client_;
259 scoped_ptr<FlimflamDeviceClient> flimflam_device_client_; 280 scoped_ptr<FlimflamDeviceClient> flimflam_device_client_;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 332 }
312 333
313 // static 334 // static
314 DBusThreadManager* DBusThreadManager::Get() { 335 DBusThreadManager* DBusThreadManager::Get() {
315 CHECK(g_dbus_thread_manager) 336 CHECK(g_dbus_thread_manager)
316 << "DBusThreadManager::Get() called before Initialize()"; 337 << "DBusThreadManager::Get() called before Initialize()";
317 return g_dbus_thread_manager; 338 return g_dbus_thread_manager;
318 } 339 }
319 340
320 } // namespace chromeos 341 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698