| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 5 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "chrome/browser/chromeos/dbus/bluetooth_adapter_client.h" | 9 #include "chrome/browser/chromeos/dbus/bluetooth_adapter_client.h" |
| 10 #include "chrome/browser/chromeos/dbus/bluetooth_manager_client.h" | 10 #include "chrome/browser/chromeos/dbus/bluetooth_manager_client.h" |
| 11 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" | 11 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" |
| 12 #include "chrome/browser/chromeos/dbus/cros_disks_client.h" | 12 #include "chrome/browser/chromeos/dbus/cros_disks_client.h" |
| 13 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 13 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 14 #include "chrome/browser/chromeos/dbus/sensors_client.h" | 14 #include "chrome/browser/chromeos/dbus/sensors_client.h" |
| 15 #include "chrome/browser/chromeos/dbus/session_manager_client.h" | 15 #include "chrome/browser/chromeos/dbus/session_manager_client.h" |
| 16 #include "chrome/browser/chromeos/dbus/speech_synthesizer_client.h" | 16 #include "chrome/browser/chromeos/dbus/speech_synthesizer_client.h" |
| 17 #include "chrome/browser/chromeos/dbus/update_engine_client.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 18 #include "dbus/bus.h" | 19 #include "dbus/bus.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| 22 static DBusThreadManager* g_dbus_thread_manager = NULL; | 23 static DBusThreadManager* g_dbus_thread_manager = NULL; |
| 23 | 24 |
| 24 // The DBusThreadManager implementation used in production. | 25 // The DBusThreadManager implementation used in production. |
| 25 class DBusThreadManagerImpl : public DBusThreadManager { | 26 class DBusThreadManagerImpl : public DBusThreadManager { |
| 26 public: | 27 public: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 power_manager_client_.reset(PowerManagerClient::Create(system_bus_.get())); | 59 power_manager_client_.reset(PowerManagerClient::Create(system_bus_.get())); |
| 59 // Create the session manager client. | 60 // Create the session manager client. |
| 60 session_manager_client_.reset( | 61 session_manager_client_.reset( |
| 61 SessionManagerClient::Create(system_bus_.get())); | 62 SessionManagerClient::Create(system_bus_.get())); |
| 62 // Create the speech synthesizer client. | 63 // Create the speech synthesizer client. |
| 63 speech_synthesizer_client_.reset( | 64 speech_synthesizer_client_.reset( |
| 64 SpeechSynthesizerClient::Create(system_bus_.get())); | 65 SpeechSynthesizerClient::Create(system_bus_.get())); |
| 65 // Create the cros-disks client. | 66 // Create the cros-disks client. |
| 66 cros_disks_client_.reset( | 67 cros_disks_client_.reset( |
| 67 CrosDisksClient::Create(system_bus_.get())); | 68 CrosDisksClient::Create(system_bus_.get())); |
| 69 update_engine_client_.reset( |
| 70 UpdateEngineClient::Create(system_bus_.get())); |
| 68 } | 71 } |
| 69 | 72 |
| 70 virtual ~DBusThreadManagerImpl() { | 73 virtual ~DBusThreadManagerImpl() { |
| 71 // Shut down the bus. During the browser shutdown, it's ok to shut down | 74 // Shut down the bus. During the browser shutdown, it's ok to shut down |
| 72 // the bus synchronously. | 75 // the bus synchronously. |
| 73 system_bus_->ShutdownOnDBusThreadAndBlock(); | 76 system_bus_->ShutdownOnDBusThreadAndBlock(); |
| 74 | 77 |
| 75 // Stop the D-Bus thread. | 78 // Stop the D-Bus thread. |
| 76 dbus_thread_->Stop(); | 79 dbus_thread_->Stop(); |
| 77 } | 80 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 104 // DBusThreadManager override. | 107 // DBusThreadManager override. |
| 105 virtual SpeechSynthesizerClient* GetSpeechSynthesizerClient() OVERRIDE { | 108 virtual SpeechSynthesizerClient* GetSpeechSynthesizerClient() OVERRIDE { |
| 106 return speech_synthesizer_client_.get(); | 109 return speech_synthesizer_client_.get(); |
| 107 } | 110 } |
| 108 | 111 |
| 109 // DBusThreadManager override. | 112 // DBusThreadManager override. |
| 110 virtual CrosDisksClient* GetCrosDisksClient() { | 113 virtual CrosDisksClient* GetCrosDisksClient() { |
| 111 return cros_disks_client_.get(); | 114 return cros_disks_client_.get(); |
| 112 } | 115 } |
| 113 | 116 |
| 117 // DBusThreadManager override. |
| 118 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { |
| 119 return update_engine_client_.get(); |
| 120 } |
| 121 |
| 114 scoped_ptr<base::Thread> dbus_thread_; | 122 scoped_ptr<base::Thread> dbus_thread_; |
| 115 scoped_refptr<dbus::Bus> system_bus_; | 123 scoped_refptr<dbus::Bus> system_bus_; |
| 116 scoped_ptr<CrosDBusService> cros_dbus_service_; | 124 scoped_ptr<CrosDBusService> cros_dbus_service_; |
| 117 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; | 125 scoped_ptr<BluetoothAdapterClient> bluetooth_adapter_client_; |
| 118 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; | 126 scoped_ptr<BluetoothManagerClient> bluetooth_manager_client_; |
| 119 scoped_ptr<PowerManagerClient> power_manager_client_; | 127 scoped_ptr<PowerManagerClient> power_manager_client_; |
| 120 scoped_ptr<SensorsClient> sensors_client_; | 128 scoped_ptr<SensorsClient> sensors_client_; |
| 121 scoped_ptr<SessionManagerClient> session_manager_client_; | 129 scoped_ptr<SessionManagerClient> session_manager_client_; |
| 122 scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_; | 130 scoped_ptr<SpeechSynthesizerClient> speech_synthesizer_client_; |
| 123 scoped_ptr<CrosDisksClient> cros_disks_client_; | 131 scoped_ptr<CrosDisksClient> cros_disks_client_; |
| 132 scoped_ptr<UpdateEngineClient> update_engine_client_; |
| 124 }; | 133 }; |
| 125 | 134 |
| 126 // static | 135 // static |
| 127 void DBusThreadManager::Initialize() { | 136 void DBusThreadManager::Initialize() { |
| 128 if (g_dbus_thread_manager) { | 137 if (g_dbus_thread_manager) { |
| 129 LOG(WARNING) << "DBusThreadManager was already initialized"; | 138 LOG(WARNING) << "DBusThreadManager was already initialized"; |
| 130 return; | 139 return; |
| 131 } | 140 } |
| 132 g_dbus_thread_manager = new DBusThreadManagerImpl; | 141 g_dbus_thread_manager = new DBusThreadManagerImpl; |
| 133 VLOG(1) << "DBusThreadManager initialized"; | 142 VLOG(1) << "DBusThreadManager initialized"; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 163 } | 172 } |
| 164 | 173 |
| 165 // static | 174 // static |
| 166 DBusThreadManager* DBusThreadManager::Get() { | 175 DBusThreadManager* DBusThreadManager::Get() { |
| 167 CHECK(g_dbus_thread_manager) | 176 CHECK(g_dbus_thread_manager) |
| 168 << "DBusThreadManager::Get() called before Initialize()"; | 177 << "DBusThreadManager::Get() called before Initialize()"; |
| 169 return g_dbus_thread_manager; | 178 return g_dbus_thread_manager; |
| 170 } | 179 } |
| 171 | 180 |
| 172 } // namespace chromeos | 181 } // namespace chromeos |
| OLD | NEW |