| 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> | |
| 8 | |
| 9 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 10 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 11 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
| 12 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 13 #include "chromeos/chromeos_switches.h" | 11 #include "chromeos/chromeos_switches.h" |
| 14 #include "chromeos/dbus/bluetooth_adapter_client.h" | 12 #include "chromeos/dbus/bluetooth_adapter_client.h" |
| 15 #include "chromeos/dbus/bluetooth_agent_manager_client.h" | 13 #include "chromeos/dbus/bluetooth_agent_manager_client.h" |
| 16 #include "chromeos/dbus/bluetooth_device_client.h" | 14 #include "chromeos/dbus/bluetooth_device_client.h" |
| 17 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" | 15 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" |
| 18 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" | 16 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 scoped_ptr<SessionManagerClient> session_manager_client_; | 248 scoped_ptr<SessionManagerClient> session_manager_client_; |
| 251 scoped_ptr<SMSClient> sms_client_; | 249 scoped_ptr<SMSClient> sms_client_; |
| 252 scoped_ptr<UpdateEngineClient> update_engine_client_; | 250 scoped_ptr<UpdateEngineClient> update_engine_client_; |
| 253 | 251 |
| 254 DISALLOW_COPY_AND_ASSIGN(DBusClientBundle); | 252 DISALLOW_COPY_AND_ASSIGN(DBusClientBundle); |
| 255 }; | 253 }; |
| 256 | 254 |
| 257 // The DBusThreadManager implementation used in production. | 255 // The DBusThreadManager implementation used in production. |
| 258 class DBusThreadManagerImpl : public DBusThreadManager { | 256 class DBusThreadManagerImpl : public DBusThreadManager { |
| 259 public: | 257 public: |
| 260 explicit DBusThreadManagerImpl() { | 258 DBusThreadManagerImpl() { |
| 261 // Create the D-Bus thread. | 259 // Create the D-Bus thread. |
| 262 base::Thread::Options thread_options; | 260 base::Thread::Options thread_options; |
| 263 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 261 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 264 dbus_thread_.reset(new base::Thread("D-Bus thread")); | 262 dbus_thread_.reset(new base::Thread("D-Bus thread")); |
| 265 dbus_thread_->StartWithOptions(thread_options); | 263 dbus_thread_->StartWithOptions(thread_options); |
| 266 | 264 |
| 267 // Create the connection to the system bus. | 265 // Create the connection to the system bus. |
| 268 dbus::Bus::Options system_bus_options; | 266 dbus::Bus::Options system_bus_options; |
| 269 system_bus_options.bus_type = dbus::Bus::SYSTEM; | 267 system_bus_options.bus_type = dbus::Bus::SYSTEM; |
| 270 system_bus_options.connection_type = dbus::Bus::PRIVATE; | 268 system_bus_options.connection_type = dbus::Bus::PRIVATE; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 458 } |
| 461 | 459 |
| 462 // Note: Keep this before other members so they can call AddObserver() in | 460 // Note: Keep this before other members so they can call AddObserver() in |
| 463 // their c'tors. | 461 // their c'tors. |
| 464 ObserverList<DBusThreadManagerObserver> observers_; | 462 ObserverList<DBusThreadManagerObserver> observers_; |
| 465 | 463 |
| 466 scoped_ptr<base::Thread> dbus_thread_; | 464 scoped_ptr<base::Thread> dbus_thread_; |
| 467 scoped_refptr<dbus::Bus> system_bus_; | 465 scoped_refptr<dbus::Bus> system_bus_; |
| 468 scoped_ptr<DBusClientBundle> client_bundle_; | 466 scoped_ptr<DBusClientBundle> client_bundle_; |
| 469 scoped_ptr<PowerPolicyController> power_policy_controller_; | 467 scoped_ptr<PowerPolicyController> power_policy_controller_; |
| 468 |
| 469 DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerImpl); |
| 470 }; | 470 }; |
| 471 | 471 |
| 472 // static | 472 // static |
| 473 void DBusThreadManager::Initialize() { | 473 void DBusThreadManager::Initialize() { |
| 474 // If we initialize DBusThreadManager twice we may also be shutting it down | 474 // If we initialize DBusThreadManager twice we may also be shutting it down |
| 475 // early; do not allow that. | 475 // early; do not allow that. |
| 476 CHECK(g_dbus_thread_manager == NULL); | 476 CHECK(g_dbus_thread_manager == NULL); |
| 477 | 477 |
| 478 if (g_dbus_thread_manager_for_testing) { | 478 if (g_dbus_thread_manager_for_testing) { |
| 479 g_dbus_thread_manager = g_dbus_thread_manager_for_testing; | 479 g_dbus_thread_manager = g_dbus_thread_manager_for_testing; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); | 619 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); |
| 620 } | 620 } |
| 621 | 621 |
| 622 // static | 622 // static |
| 623 void DBusThreadManager::InitClient(DBusClient* client) { | 623 void DBusThreadManager::InitClient(DBusClient* client) { |
| 624 if (client) | 624 if (client) |
| 625 client->Init(g_dbus_thread_manager->GetSystemBus()); | 625 client->Init(g_dbus_thread_manager->GetSystemBus()); |
| 626 } | 626 } |
| 627 | 627 |
| 628 } // namespace chromeos | 628 } // namespace chromeos |
| OLD | NEW |