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

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

Issue 50243005: ChromeOS: Remove unused IBus classes from chromeos/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.h ('k') | chromeos/dbus/fake_dbus_thread_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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_implementation_type.h" 22 #include "chromeos/dbus/dbus_client_implementation_type.h"
23 #include "chromeos/dbus/dbus_thread_manager_observer.h" 23 #include "chromeos/dbus/dbus_thread_manager_observer.h"
24 #include "chromeos/dbus/debug_daemon_client.h" 24 #include "chromeos/dbus/debug_daemon_client.h"
25 #include "chromeos/dbus/gsm_sms_client.h" 25 #include "chromeos/dbus/gsm_sms_client.h"
26 #include "chromeos/dbus/ibus/ibus_client.h" 26 #include "chromeos/dbus/ibus/ibus_client.h"
27 #include "chromeos/dbus/ibus/ibus_engine_factory_service.h"
28 #include "chromeos/dbus/ibus/ibus_engine_service.h"
29 #include "chromeos/dbus/image_burner_client.h" 27 #include "chromeos/dbus/image_burner_client.h"
30 #include "chromeos/dbus/introspectable_client.h" 28 #include "chromeos/dbus/introspectable_client.h"
31 #include "chromeos/dbus/modem_messaging_client.h" 29 #include "chromeos/dbus/modem_messaging_client.h"
32 #include "chromeos/dbus/nfc_adapter_client.h" 30 #include "chromeos/dbus/nfc_adapter_client.h"
33 #include "chromeos/dbus/nfc_device_client.h" 31 #include "chromeos/dbus/nfc_device_client.h"
34 #include "chromeos/dbus/nfc_manager_client.h" 32 #include "chromeos/dbus/nfc_manager_client.h"
35 #include "chromeos/dbus/nfc_tag_client.h" 33 #include "chromeos/dbus/nfc_tag_client.h"
36 #include "chromeos/dbus/permission_broker_client.h" 34 #include "chromeos/dbus/permission_broker_client.h"
37 #include "chromeos/dbus/power_manager_client.h" 35 #include "chromeos/dbus/power_manager_client.h"
38 #include "chromeos/dbus/power_policy_controller.h" 36 #include "chromeos/dbus/power_policy_controller.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 system_bus_->GetManagedObjects(); 127 system_bus_->GetManagedObjects();
130 } 128 }
131 129
132 virtual ~DBusThreadManagerImpl() { 130 virtual ~DBusThreadManagerImpl() {
133 FOR_EACH_OBSERVER(DBusThreadManagerObserver, observers_, 131 FOR_EACH_OBSERVER(DBusThreadManagerObserver, observers_,
134 OnDBusThreadManagerDestroying(this)); 132 OnDBusThreadManagerDestroying(this));
135 133
136 // Shut down the bus. During the browser shutdown, it's ok to shut down 134 // Shut down the bus. During the browser shutdown, it's ok to shut down
137 // the bus synchronously. 135 // the bus synchronously.
138 system_bus_->ShutdownOnDBusThreadAndBlock(); 136 system_bus_->ShutdownOnDBusThreadAndBlock();
139 if (ibus_bus_.get())
140 ibus_bus_->ShutdownOnDBusThreadAndBlock();
141
142 // Release IBusEngineService instances.
143 for (std::map<dbus::ObjectPath, IBusEngineService*>::iterator it
144 = ibus_engine_services_.begin();
145 it != ibus_engine_services_.end(); it++) {
146 delete it->second;
147 }
148 137
149 // Stop the D-Bus thread. 138 // Stop the D-Bus thread.
150 dbus_thread_->Stop(); 139 dbus_thread_->Stop();
151 } 140 }
152 141
153 // DBusThreadManager override. 142 // DBusThreadManager override.
154 virtual void AddObserver(DBusThreadManagerObserver* observer) OVERRIDE { 143 virtual void AddObserver(DBusThreadManagerObserver* observer) OVERRIDE {
155 DCHECK(observer); 144 DCHECK(observer);
156 observers_.AddObserver(observer); 145 observers_.AddObserver(observer);
157 } 146 }
158 147
159 // DBusThreadManager override. 148 // DBusThreadManager override.
160 virtual void RemoveObserver(DBusThreadManagerObserver* observer) OVERRIDE { 149 virtual void RemoveObserver(DBusThreadManagerObserver* observer) OVERRIDE {
161 DCHECK(observer); 150 DCHECK(observer);
162 observers_.RemoveObserver(observer); 151 observers_.RemoveObserver(observer);
163 } 152 }
164 153
165 // DBusThreadManager override. 154 // DBusThreadManager override.
166 virtual void InitIBusBus( 155 virtual void InitIBusBus(
167 const std::string &ibus_address, 156 const std::string &ibus_address,
168 const base::Closure& on_disconnected_callback) OVERRIDE { 157 const base::Closure& on_disconnected_callback) OVERRIDE {
169 DCHECK(!ibus_bus_.get()); 158 ibus_client_.reset(IBusClient::Create());
170 dbus::Bus::Options ibus_bus_options;
171 ibus_bus_options.bus_type = dbus::Bus::CUSTOM_ADDRESS;
172 ibus_bus_options.address = ibus_address;
173 ibus_bus_options.connection_type = dbus::Bus::PRIVATE;
174 ibus_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy();
175 ibus_bus_options.disconnected_callback = on_disconnected_callback;
176 ibus_bus_ = new dbus::Bus(ibus_bus_options);
177 ibus_address_ = ibus_address;
178 VLOG(1) << "Connected to ibus-daemon: " << ibus_address;
179
180 DBusClientImplementationType client_type = STUB_DBUS_CLIENT_IMPLEMENTATION;
181
182 ibus_client_.reset(
183 IBusClient::Create(client_type, ibus_bus_.get()));
184 ibus_engine_factory_service_.reset(
185 IBusEngineFactoryService::Create(ibus_bus_.get(), client_type));
186
187 ibus_engine_services_.clear();
188 } 159 }
189 160
190 // DBusThreadManager overrides: 161 // DBusThreadManager overrides:
191 virtual dbus::Bus* GetSystemBus() OVERRIDE { 162 virtual dbus::Bus* GetSystemBus() OVERRIDE {
192 return system_bus_.get(); 163 return system_bus_.get();
193 } 164 }
194 165
195 virtual dbus::Bus* GetIBusBus() OVERRIDE {
196 return ibus_bus_.get();
197 }
198
199 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { 166 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE {
200 return bluetooth_adapter_client_.get(); 167 return bluetooth_adapter_client_.get();
201 } 168 }
202 169
203 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() 170 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient()
204 OVERRIDE { 171 OVERRIDE {
205 return bluetooth_agent_manager_client_.get(); 172 return bluetooth_agent_manager_client_.get();
206 } 173 }
207 174
208 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { 175 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 278 }
312 279
313 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { 280 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE {
314 return update_engine_client_.get(); 281 return update_engine_client_.get();
315 } 282 }
316 283
317 virtual IBusClient* GetIBusClient() OVERRIDE { 284 virtual IBusClient* GetIBusClient() OVERRIDE {
318 return ibus_client_.get(); 285 return ibus_client_.get();
319 } 286 }
320 287
321 virtual IBusEngineFactoryService* GetIBusEngineFactoryService() OVERRIDE {
322 return ibus_engine_factory_service_.get();
323 }
324
325 virtual IBusEngineService* GetIBusEngineService(
326 const dbus::ObjectPath& object_path) OVERRIDE {
327 if (ibus_engine_services_.find(object_path)
328 == ibus_engine_services_.end()) {
329 ibus_engine_services_[object_path] = IBusEngineService::Create();
330 }
331 return ibus_engine_services_[object_path];
332 }
333
334 virtual void RemoveIBusEngineService(
335 const dbus::ObjectPath& object_path) OVERRIDE {
336 if (ibus_engine_services_.find(object_path) !=
337 ibus_engine_services_.end()) {
338 LOG(WARNING) << "Object path not found: " << object_path.value();
339 return;
340 }
341 delete ibus_engine_services_[object_path];
342 ibus_engine_services_.erase(object_path);
343 }
344
345 private: 288 private:
346 // Initializes |client| with the |system_bus_|. 289 // Initializes |client| with the |system_bus_|.
347 void InitClient(DBusClient* client) { 290 void InitClient(DBusClient* client) {
348 client->Init(system_bus_.get()); 291 client->Init(system_bus_.get());
349 } 292 }
350 293
351 // Constructs all clients -- stub or real implementation according to 294 // Constructs all clients -- stub or real implementation according to
352 // |client_type| and |client_type_override| -- and stores them in the 295 // |client_type| and |client_type_override| -- and stores them in the
353 // respective *_client_ member variable. 296 // respective *_client_ member variable.
354 void CreateDefaultClients(DBusClientImplementationType client_type, 297 void CreateDefaultClients(DBusClientImplementationType client_type,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 system_clock_client_.reset(SystemClockClient::Create(client_type)); 339 system_clock_client_.reset(SystemClockClient::Create(client_type));
397 update_engine_client_.reset(UpdateEngineClient::Create(client_type)); 340 update_engine_client_.reset(UpdateEngineClient::Create(client_type));
398 } 341 }
399 342
400 // Note: Keep this before other members so they can call AddObserver() in 343 // Note: Keep this before other members so they can call AddObserver() in
401 // their c'tors. 344 // their c'tors.
402 ObserverList<DBusThreadManagerObserver> observers_; 345 ObserverList<DBusThreadManagerObserver> observers_;
403 346
404 scoped_ptr<base::Thread> dbus_thread_; 347 scoped_ptr<base::Thread> dbus_thread_;
405 scoped_refptr<dbus::Bus> system_bus_; 348 scoped_refptr<dbus::Bus> system_bus_;
406 scoped_refptr<dbus::Bus> ibus_bus_;
407 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; 349 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_;
408 scoped_ptr<BluetoothAgentManagerClient> bluetooth_agent_manager_client_; 350 scoped_ptr<BluetoothAgentManagerClient> bluetooth_agent_manager_client_;
409 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_; 351 scoped_ptr<BluetoothDeviceClient> bluetooth_device_client_;
410 scoped_ptr<BluetoothInputClient> bluetooth_input_client_; 352 scoped_ptr<BluetoothInputClient> bluetooth_input_client_;
411 scoped_ptr<BluetoothProfileManagerClient> bluetooth_profile_manager_client_; 353 scoped_ptr<BluetoothProfileManagerClient> bluetooth_profile_manager_client_;
412 scoped_ptr<CrasAudioClient> cras_audio_client_; 354 scoped_ptr<CrasAudioClient> cras_audio_client_;
413 scoped_ptr<CrosDisksClient> cros_disks_client_; 355 scoped_ptr<CrosDisksClient> cros_disks_client_;
414 scoped_ptr<CryptohomeClient> cryptohome_client_; 356 scoped_ptr<CryptohomeClient> cryptohome_client_;
415 scoped_ptr<DebugDaemonClient> debug_daemon_client_; 357 scoped_ptr<DebugDaemonClient> debug_daemon_client_;
416 scoped_ptr<ShillDeviceClient> shill_device_client_; 358 scoped_ptr<ShillDeviceClient> shill_device_client_;
(...skipping 11 matching lines...) Expand all
428 scoped_ptr<NfcAdapterClient> nfc_adapter_client_; 370 scoped_ptr<NfcAdapterClient> nfc_adapter_client_;
429 scoped_ptr<NfcDeviceClient> nfc_device_client_; 371 scoped_ptr<NfcDeviceClient> nfc_device_client_;
430 scoped_ptr<NfcTagClient> nfc_tag_client_; 372 scoped_ptr<NfcTagClient> nfc_tag_client_;
431 scoped_ptr<PermissionBrokerClient> permission_broker_client_; 373 scoped_ptr<PermissionBrokerClient> permission_broker_client_;
432 scoped_ptr<SystemClockClient> system_clock_client_; 374 scoped_ptr<SystemClockClient> system_clock_client_;
433 scoped_ptr<PowerManagerClient> power_manager_client_; 375 scoped_ptr<PowerManagerClient> power_manager_client_;
434 scoped_ptr<SessionManagerClient> session_manager_client_; 376 scoped_ptr<SessionManagerClient> session_manager_client_;
435 scoped_ptr<SMSClient> sms_client_; 377 scoped_ptr<SMSClient> sms_client_;
436 scoped_ptr<UpdateEngineClient> update_engine_client_; 378 scoped_ptr<UpdateEngineClient> update_engine_client_;
437 scoped_ptr<IBusClient> ibus_client_; 379 scoped_ptr<IBusClient> ibus_client_;
438 scoped_ptr<IBusEngineFactoryService> ibus_engine_factory_service_;
439 std::map<dbus::ObjectPath, IBusEngineService*> ibus_engine_services_;
440 scoped_ptr<PowerPolicyController> power_policy_controller_; 380 scoped_ptr<PowerPolicyController> power_policy_controller_;
441 381
442 std::string ibus_address_;
443 }; 382 };
444 383
445 // static 384 // static
446 void DBusThreadManager::Initialize() { 385 void DBusThreadManager::Initialize() {
447 // Ignore Initialize() if we set a test DBusThreadManager. 386 // Ignore Initialize() if we set a test DBusThreadManager.
448 if (g_dbus_thread_manager_set_for_testing) 387 if (g_dbus_thread_manager_set_for_testing)
449 return; 388 return;
450 // If we initialize DBusThreadManager twice we may also be shutting it down 389 // If we initialize DBusThreadManager twice we may also be shutting it down
451 // early; do not allow that. 390 // early; do not allow that.
452 CHECK(g_dbus_thread_manager == NULL); 391 CHECK(g_dbus_thread_manager == NULL);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 } 464 }
526 465
527 // static 466 // static
528 DBusThreadManager* DBusThreadManager::Get() { 467 DBusThreadManager* DBusThreadManager::Get() {
529 CHECK(g_dbus_thread_manager) 468 CHECK(g_dbus_thread_manager)
530 << "DBusThreadManager::Get() called before Initialize()"; 469 << "DBusThreadManager::Get() called before Initialize()";
531 return g_dbus_thread_manager; 470 return g_dbus_thread_manager;
532 } 471 }
533 472
534 } // namespace chromeos 473 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.h ('k') | chromeos/dbus/fake_dbus_thread_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698