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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
11 #include "chromeos/dbus/bluetooth_adapter_client.h" | 11 #include "chromeos/dbus/bluetooth_adapter_client.h" |
12 #include "chromeos/dbus/bluetooth_agent_manager_client.h" | 12 #include "chromeos/dbus/bluetooth_agent_manager_client.h" |
13 #include "chromeos/dbus/bluetooth_device_client.h" | 13 #include "chromeos/dbus/bluetooth_device_client.h" |
14 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" | 14 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" |
15 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" | 15 #include "chromeos/dbus/bluetooth_gatt_descriptor_client.h" |
16 #include "chromeos/dbus/bluetooth_gatt_manager_client.h" | 16 #include "chromeos/dbus/bluetooth_gatt_manager_client.h" |
17 #include "chromeos/dbus/bluetooth_gatt_service_client.h" | 17 #include "chromeos/dbus/bluetooth_gatt_service_client.h" |
18 #include "chromeos/dbus/bluetooth_input_client.h" | 18 #include "chromeos/dbus/bluetooth_input_client.h" |
19 #include "chromeos/dbus/bluetooth_profile_manager_client.h" | 19 #include "chromeos/dbus/bluetooth_profile_manager_client.h" |
20 #include "chromeos/dbus/cras_audio_client.h" | 20 #include "chromeos/dbus/cras_audio_client.h" |
21 #include "chromeos/dbus/cros_disks_client.h" | 21 #include "chromeos/dbus/cros_disks_client.h" |
22 #include "chromeos/dbus/cryptohome_client.h" | 22 #include "chromeos/dbus/cryptohome_client.h" |
23 #include "chromeos/dbus/dbus_client.h" | 23 #include "chromeos/dbus/dbus_client.h" |
24 #include "chromeos/dbus/dbus_client_bundle.h" | 24 #include "chromeos/dbus/dbus_client_bundle.h" |
25 #include "chromeos/dbus/debug_daemon_client.h" | 25 #include "chromeos/dbus/debug_daemon_client.h" |
26 #include "chromeos/dbus/easy_unlock_client.h" | 26 #include "chromeos/dbus/easy_unlock_client.h" |
27 #include "chromeos/dbus/fake_dbus_thread_manager.h" | |
28 #include "chromeos/dbus/gsm_sms_client.h" | 27 #include "chromeos/dbus/gsm_sms_client.h" |
29 #include "chromeos/dbus/image_burner_client.h" | 28 #include "chromeos/dbus/image_burner_client.h" |
30 #include "chromeos/dbus/introspectable_client.h" | 29 #include "chromeos/dbus/introspectable_client.h" |
31 #include "chromeos/dbus/lorgnette_manager_client.h" | 30 #include "chromeos/dbus/lorgnette_manager_client.h" |
32 #include "chromeos/dbus/modem_messaging_client.h" | 31 #include "chromeos/dbus/modem_messaging_client.h" |
33 #include "chromeos/dbus/nfc_adapter_client.h" | 32 #include "chromeos/dbus/nfc_adapter_client.h" |
34 #include "chromeos/dbus/nfc_device_client.h" | 33 #include "chromeos/dbus/nfc_device_client.h" |
35 #include "chromeos/dbus/nfc_manager_client.h" | 34 #include "chromeos/dbus/nfc_manager_client.h" |
36 #include "chromeos/dbus/nfc_record_client.h" | 35 #include "chromeos/dbus/nfc_record_client.h" |
37 #include "chromeos/dbus/nfc_tag_client.h" | 36 #include "chromeos/dbus/nfc_tag_client.h" |
38 #include "chromeos/dbus/permission_broker_client.h" | 37 #include "chromeos/dbus/permission_broker_client.h" |
39 #include "chromeos/dbus/power_manager_client.h" | 38 #include "chromeos/dbus/power_manager_client.h" |
40 #include "chromeos/dbus/power_policy_controller.h" | 39 #include "chromeos/dbus/power_policy_controller.h" |
41 #include "chromeos/dbus/session_manager_client.h" | 40 #include "chromeos/dbus/session_manager_client.h" |
42 #include "chromeos/dbus/shill_device_client.h" | 41 #include "chromeos/dbus/shill_device_client.h" |
43 #include "chromeos/dbus/shill_ipconfig_client.h" | 42 #include "chromeos/dbus/shill_ipconfig_client.h" |
44 #include "chromeos/dbus/shill_manager_client.h" | 43 #include "chromeos/dbus/shill_manager_client.h" |
45 #include "chromeos/dbus/shill_profile_client.h" | 44 #include "chromeos/dbus/shill_profile_client.h" |
46 #include "chromeos/dbus/shill_service_client.h" | 45 #include "chromeos/dbus/shill_service_client.h" |
47 #include "chromeos/dbus/sms_client.h" | 46 #include "chromeos/dbus/sms_client.h" |
48 #include "chromeos/dbus/system_clock_client.h" | 47 #include "chromeos/dbus/system_clock_client.h" |
49 #include "chromeos/dbus/update_engine_client.h" | 48 #include "chromeos/dbus/update_engine_client.h" |
50 #include "dbus/bus.h" | 49 #include "dbus/bus.h" |
51 #include "dbus/dbus_statistics.h" | 50 #include "dbus/dbus_statistics.h" |
52 | 51 |
53 namespace chromeos { | 52 namespace chromeos { |
54 | 53 |
55 static DBusThreadManager* g_dbus_thread_manager = NULL; | 54 static DBusThreadManager* g_dbus_thread_manager = NULL; |
56 static DBusThreadManager* g_dbus_thread_manager_for_testing = NULL; | 55 static bool g_using_dbus_thread_manager_for_testing = false; |
57 | 56 |
58 DBusClientBundle::DBusClientTypeMask | 57 DBusClientBundle::DBusClientTypeMask |
59 DBusThreadManager::unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; | 58 DBusThreadManager::unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; |
60 | 59 |
61 // The DBusThreadManager implementation used in production. | 60 DBusThreadManager::DBusThreadManager() { |
62 class DBusThreadManagerImpl : public DBusThreadManager { | 61 dbus::statistics::Initialize(); |
63 public: | 62 if (!DBusThreadManager::IsUsingStub(DBusClientBundle::ALL_CLIENTS)) { |
64 DBusThreadManagerImpl() { | |
65 // Create the D-Bus thread. | 63 // Create the D-Bus thread. |
66 base::Thread::Options thread_options; | 64 base::Thread::Options thread_options; |
67 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; | 65 thread_options.message_loop_type = base::MessageLoop::TYPE_IO; |
68 dbus_thread_.reset(new base::Thread("D-Bus thread")); | 66 dbus_thread_.reset(new base::Thread("D-Bus thread")); |
69 dbus_thread_->StartWithOptions(thread_options); | 67 dbus_thread_->StartWithOptions(thread_options); |
70 | 68 |
71 // Create the connection to the system bus. | 69 // Create the connection to the system bus. |
72 dbus::Bus::Options system_bus_options; | 70 dbus::Bus::Options system_bus_options; |
73 system_bus_options.bus_type = dbus::Bus::SYSTEM; | 71 system_bus_options.bus_type = dbus::Bus::SYSTEM; |
74 system_bus_options.connection_type = dbus::Bus::PRIVATE; | 72 system_bus_options.connection_type = dbus::Bus::PRIVATE; |
75 system_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); | 73 system_bus_options.dbus_task_runner = dbus_thread_->message_loop_proxy(); |
76 system_bus_ = new dbus::Bus(system_bus_options); | 74 system_bus_ = new dbus::Bus(system_bus_options); |
77 | |
78 CreateDefaultClients(); | |
79 } | 75 } |
80 | 76 |
81 virtual ~DBusThreadManagerImpl() { | 77 CreateDefaultClients(); |
82 // PowerPolicyController's destructor depends on PowerManagerClient. | 78 } |
83 power_policy_controller_.reset(); | 79 |
84 | 80 DBusThreadManager::~DBusThreadManager() { |
85 // Delete all D-Bus clients before shutting down the system bus. | 81 // PowerPolicyController's destructor depends on PowerManagerClient. |
86 client_bundle_.reset(); | 82 power_policy_controller_.reset(); |
87 | 83 |
88 // Shut down the bus. During the browser shutdown, it's ok to shut down | 84 // Delete all D-Bus clients before shutting down the system bus. |
89 // the bus synchronously. | 85 client_bundle_.reset(); |
| 86 |
| 87 // Shut down the bus. During the browser shutdown, it's ok to shut down |
| 88 // the bus synchronously. |
| 89 if (system_bus_) |
90 system_bus_->ShutdownOnDBusThreadAndBlock(); | 90 system_bus_->ShutdownOnDBusThreadAndBlock(); |
91 | 91 |
92 // Stop the D-Bus thread. | 92 // Stop the D-Bus thread. |
| 93 if (dbus_thread_) |
93 dbus_thread_->Stop(); | 94 dbus_thread_->Stop(); |
| 95 |
| 96 dbus::statistics::Shutdown(); |
| 97 |
| 98 if (g_dbus_thread_manager == NULL) |
| 99 return; // Called form Shutdown() or local test instance. |
| 100 |
| 101 // There should never be both a global instance and a local instance. |
| 102 CHECK(this == g_dbus_thread_manager); |
| 103 if (g_using_dbus_thread_manager_for_testing) { |
| 104 g_dbus_thread_manager = NULL; |
| 105 g_using_dbus_thread_manager_for_testing = false; |
| 106 VLOG(1) << "DBusThreadManager destroyed"; |
| 107 } else { |
| 108 LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()"; |
94 } | 109 } |
95 | 110 } |
96 void SetupDefaultEnvironment() { | 111 |
97 return client_bundle_->SetupDefaultEnvironment(); | 112 dbus::Bus* DBusThreadManager::GetSystemBus() { |
98 } | 113 return system_bus_.get(); |
99 | 114 } |
100 virtual dbus::Bus* GetSystemBus() OVERRIDE { | 115 |
101 return system_bus_.get(); | 116 BluetoothAdapterClient* DBusThreadManager::GetBluetoothAdapterClient() { |
102 } | 117 return client_bundle_->bluetooth_adapter_client(); |
103 | 118 } |
104 virtual BluetoothAdapterClient* GetBluetoothAdapterClient() OVERRIDE { | 119 |
105 return client_bundle_->bluetooth_adapter_client(); | 120 BluetoothAgentManagerClient* |
106 } | 121 DBusThreadManager::GetBluetoothAgentManagerClient() { |
107 | 122 return client_bundle_->bluetooth_agent_manager_client(); |
108 virtual BluetoothAgentManagerClient* GetBluetoothAgentManagerClient() | 123 } |
109 OVERRIDE { | 124 |
110 return client_bundle_->bluetooth_agent_manager_client(); | 125 BluetoothDeviceClient* DBusThreadManager::GetBluetoothDeviceClient() { |
111 } | 126 return client_bundle_->bluetooth_device_client(); |
112 | 127 } |
113 virtual BluetoothDeviceClient* GetBluetoothDeviceClient() OVERRIDE { | 128 |
114 return client_bundle_->bluetooth_device_client(); | 129 BluetoothGattCharacteristicClient* |
115 } | 130 DBusThreadManager::GetBluetoothGattCharacteristicClient() { |
116 | 131 return client_bundle_->bluetooth_gatt_characteristic_client(); |
117 virtual BluetoothGattCharacteristicClient* | 132 } |
118 GetBluetoothGattCharacteristicClient() OVERRIDE { | 133 |
119 return client_bundle_->bluetooth_gatt_characteristic_client(); | 134 BluetoothGattDescriptorClient* |
120 } | 135 DBusThreadManager::GetBluetoothGattDescriptorClient() { |
121 | 136 return client_bundle_->bluetooth_gatt_descriptor_client(); |
122 virtual BluetoothGattDescriptorClient* GetBluetoothGattDescriptorClient() | 137 } |
123 OVERRIDE { | 138 |
124 return client_bundle_->bluetooth_gatt_descriptor_client(); | 139 BluetoothGattManagerClient* |
125 } | 140 DBusThreadManager::GetBluetoothGattManagerClient() { |
126 | 141 return client_bundle_->bluetooth_gatt_manager_client(); |
127 virtual BluetoothGattManagerClient* GetBluetoothGattManagerClient() OVERRIDE { | 142 } |
128 return client_bundle_->bluetooth_gatt_manager_client(); | 143 |
129 } | 144 BluetoothGattServiceClient* |
130 | 145 DBusThreadManager::GetBluetoothGattServiceClient() { |
131 virtual BluetoothGattServiceClient* GetBluetoothGattServiceClient() OVERRIDE { | 146 return client_bundle_->bluetooth_gatt_service_client(); |
132 return client_bundle_->bluetooth_gatt_service_client(); | 147 } |
133 } | 148 |
134 | 149 BluetoothInputClient* DBusThreadManager::GetBluetoothInputClient() { |
135 virtual BluetoothInputClient* GetBluetoothInputClient() OVERRIDE { | 150 return client_bundle_->bluetooth_input_client(); |
136 return client_bundle_->bluetooth_input_client(); | 151 } |
137 } | 152 |
138 | 153 BluetoothProfileManagerClient* |
139 virtual BluetoothProfileManagerClient* GetBluetoothProfileManagerClient() | 154 DBusThreadManager::GetBluetoothProfileManagerClient() { |
140 OVERRIDE { | 155 return client_bundle_->bluetooth_profile_manager_client(); |
141 return client_bundle_->bluetooth_profile_manager_client(); | 156 } |
142 } | 157 |
143 | 158 CrasAudioClient* DBusThreadManager::GetCrasAudioClient() { |
144 virtual CrasAudioClient* GetCrasAudioClient() OVERRIDE { | 159 return client_bundle_->cras_audio_client(); |
145 return client_bundle_->cras_audio_client(); | 160 } |
146 } | 161 |
147 | 162 CrosDisksClient* DBusThreadManager::GetCrosDisksClient() { |
148 virtual CrosDisksClient* GetCrosDisksClient() OVERRIDE { | 163 return client_bundle_->cros_disks_client(); |
149 return client_bundle_->cros_disks_client(); | 164 } |
150 } | 165 |
151 | 166 CryptohomeClient* DBusThreadManager::GetCryptohomeClient() { |
152 virtual CryptohomeClient* GetCryptohomeClient() OVERRIDE { | 167 return client_bundle_->cryptohome_client(); |
153 return client_bundle_->cryptohome_client(); | 168 } |
154 } | 169 |
155 | 170 DebugDaemonClient* DBusThreadManager::GetDebugDaemonClient() { |
156 virtual DebugDaemonClient* GetDebugDaemonClient() OVERRIDE { | 171 return client_bundle_->debug_daemon_client(); |
157 return client_bundle_->debug_daemon_client(); | 172 } |
158 } | 173 |
159 | 174 EasyUnlockClient* DBusThreadManager::GetEasyUnlockClient() { |
160 virtual EasyUnlockClient* GetEasyUnlockClient() OVERRIDE { | 175 return client_bundle_->easy_unlock_client(); |
161 return client_bundle_->easy_unlock_client(); | 176 } |
162 } | 177 LorgnetteManagerClient* |
163 virtual LorgnetteManagerClient* GetLorgnetteManagerClient() OVERRIDE { | 178 DBusThreadManager::GetLorgnetteManagerClient() { |
164 return client_bundle_->lorgnette_manager_client(); | 179 return client_bundle_->lorgnette_manager_client(); |
165 } | 180 } |
166 | 181 |
167 virtual ShillDeviceClient* GetShillDeviceClient() OVERRIDE { | 182 ShillDeviceClient* |
168 return client_bundle_->shill_device_client(); | 183 DBusThreadManager::GetShillDeviceClient() { |
169 } | 184 return client_bundle_->shill_device_client(); |
170 | 185 } |
171 virtual ShillIPConfigClient* GetShillIPConfigClient() OVERRIDE { | 186 |
172 return client_bundle_->shill_ipconfig_client(); | 187 ShillIPConfigClient* |
173 } | 188 DBusThreadManager::GetShillIPConfigClient() { |
174 | 189 return client_bundle_->shill_ipconfig_client(); |
175 virtual ShillManagerClient* GetShillManagerClient() OVERRIDE { | 190 } |
176 return client_bundle_->shill_manager_client(); | 191 |
177 } | 192 ShillManagerClient* |
178 | 193 DBusThreadManager::GetShillManagerClient() { |
179 virtual ShillServiceClient* GetShillServiceClient() OVERRIDE { | 194 return client_bundle_->shill_manager_client(); |
180 return client_bundle_->shill_service_client(); | 195 } |
181 } | 196 |
182 | 197 ShillServiceClient* |
183 virtual ShillProfileClient* GetShillProfileClient() OVERRIDE { | 198 DBusThreadManager::GetShillServiceClient() { |
184 return client_bundle_->shill_profile_client(); | 199 return client_bundle_->shill_service_client(); |
185 } | 200 } |
186 | 201 |
187 virtual GsmSMSClient* GetGsmSMSClient() OVERRIDE { | 202 ShillProfileClient* |
188 return client_bundle_->gsm_sms_client(); | 203 DBusThreadManager::GetShillProfileClient() { |
189 } | 204 return client_bundle_->shill_profile_client(); |
190 | 205 } |
191 virtual ImageBurnerClient* GetImageBurnerClient() OVERRIDE { | 206 |
192 return client_bundle_->image_burner_client(); | 207 GsmSMSClient* DBusThreadManager::GetGsmSMSClient() { |
193 } | 208 return client_bundle_->gsm_sms_client(); |
194 | 209 } |
195 virtual IntrospectableClient* GetIntrospectableClient() OVERRIDE { | 210 |
196 return client_bundle_->introspectable_client(); | 211 ImageBurnerClient* DBusThreadManager::GetImageBurnerClient() { |
197 } | 212 return client_bundle_->image_burner_client(); |
198 | 213 } |
199 virtual ModemMessagingClient* GetModemMessagingClient() OVERRIDE { | 214 |
200 return client_bundle_->modem_messaging_client(); | 215 IntrospectableClient* DBusThreadManager::GetIntrospectableClient() { |
201 } | 216 return client_bundle_->introspectable_client(); |
202 | 217 } |
203 virtual NfcAdapterClient* GetNfcAdapterClient() OVERRIDE { | 218 |
204 return client_bundle_->nfc_adapter_client(); | 219 ModemMessagingClient* DBusThreadManager::GetModemMessagingClient() { |
205 } | 220 return client_bundle_->modem_messaging_client(); |
206 | 221 } |
207 virtual NfcDeviceClient* GetNfcDeviceClient() OVERRIDE { | 222 |
208 return client_bundle_->nfc_device_client(); | 223 NfcAdapterClient* DBusThreadManager::GetNfcAdapterClient() { |
209 } | 224 return client_bundle_->nfc_adapter_client(); |
210 | 225 } |
211 virtual NfcManagerClient* GetNfcManagerClient() OVERRIDE { | 226 |
212 return client_bundle_->nfc_manager_client(); | 227 NfcDeviceClient* DBusThreadManager::GetNfcDeviceClient() { |
213 } | 228 return client_bundle_->nfc_device_client(); |
214 | 229 } |
215 virtual NfcRecordClient* GetNfcRecordClient() OVERRIDE { | 230 |
216 return client_bundle_->nfc_record_client(); | 231 NfcManagerClient* DBusThreadManager::GetNfcManagerClient() { |
217 } | 232 return client_bundle_->nfc_manager_client(); |
218 | 233 } |
219 virtual NfcTagClient* GetNfcTagClient() OVERRIDE { | 234 |
220 return client_bundle_->nfc_tag_client(); | 235 NfcRecordClient* DBusThreadManager::GetNfcRecordClient() { |
221 } | 236 return client_bundle_->nfc_record_client(); |
222 | 237 } |
223 virtual PermissionBrokerClient* GetPermissionBrokerClient() OVERRIDE { | 238 |
224 return client_bundle_->permission_broker_client(); | 239 NfcTagClient* DBusThreadManager::GetNfcTagClient() { |
225 } | 240 return client_bundle_->nfc_tag_client(); |
226 | 241 } |
227 virtual PowerManagerClient* GetPowerManagerClient() OVERRIDE { | 242 |
228 return client_bundle_->power_manager_client(); | 243 PermissionBrokerClient* DBusThreadManager::GetPermissionBrokerClient() { |
229 } | 244 return client_bundle_->permission_broker_client(); |
230 | 245 } |
231 virtual SessionManagerClient* GetSessionManagerClient() OVERRIDE { | 246 |
232 return client_bundle_->session_manager_client(); | 247 PowerManagerClient* DBusThreadManager::GetPowerManagerClient() { |
233 } | 248 return client_bundle_->power_manager_client(); |
234 | 249 } |
235 virtual SMSClient* GetSMSClient() OVERRIDE { | 250 |
236 return client_bundle_->sms_client(); | 251 SessionManagerClient* DBusThreadManager::GetSessionManagerClient() { |
237 } | 252 return client_bundle_->session_manager_client(); |
238 | 253 } |
239 virtual SystemClockClient* GetSystemClockClient() OVERRIDE { | 254 |
240 return client_bundle_->system_clock_client(); | 255 SMSClient* DBusThreadManager::GetSMSClient() { |
241 } | 256 return client_bundle_->sms_client(); |
242 | 257 } |
243 virtual UpdateEngineClient* GetUpdateEngineClient() OVERRIDE { | 258 |
244 return client_bundle_->update_engine_client(); | 259 SystemClockClient* DBusThreadManager::GetSystemClockClient() { |
245 } | 260 return client_bundle_->system_clock_client(); |
246 | 261 } |
247 virtual PowerPolicyController* GetPowerPolicyController() OVERRIDE { | 262 |
248 return power_policy_controller_.get(); | 263 UpdateEngineClient* DBusThreadManager::GetUpdateEngineClient() { |
249 } | 264 return client_bundle_->update_engine_client(); |
250 | 265 } |
251 private: | 266 |
252 // Constructs all clients and stores them in the respective *_client_ member | 267 PowerPolicyController* DBusThreadManager::GetPowerPolicyController() { |
253 // variable. | 268 return power_policy_controller_.get(); |
254 void CreateDefaultClients() { | 269 } |
255 client_bundle_.reset(new DBusClientBundle()); | 270 |
256 // TODO(crbug.com/345586): Move PowerPolicyController out of | 271 void DBusThreadManager::CreateDefaultClients() { |
257 // DBusThreadManagerImpl. | 272 client_bundle_.reset(new DBusClientBundle()); |
258 power_policy_controller_.reset(new PowerPolicyController); | 273 // TODO(crbug.com/345586): Move PowerPolicyController out of |
259 } | 274 // DBusThreadManager. |
260 | 275 power_policy_controller_.reset(new PowerPolicyController); |
261 scoped_ptr<base::Thread> dbus_thread_; | 276 } |
262 scoped_refptr<dbus::Bus> system_bus_; | 277 |
263 scoped_ptr<DBusClientBundle> client_bundle_; | 278 void DBusThreadManager::InitializeClients() { |
264 scoped_ptr<PowerPolicyController> power_policy_controller_; | 279 GetBluetoothAdapterClient()->Init(GetSystemBus()); |
265 | 280 GetBluetoothAgentManagerClient()->Init(GetSystemBus()); |
266 DISALLOW_COPY_AND_ASSIGN(DBusThreadManagerImpl); | 281 GetBluetoothDeviceClient()->Init(GetSystemBus()); |
267 }; | 282 GetBluetoothGattCharacteristicClient()->Init(GetSystemBus()); |
| 283 GetBluetoothGattDescriptorClient()->Init(GetSystemBus()); |
| 284 GetBluetoothGattManagerClient()->Init(GetSystemBus()); |
| 285 GetBluetoothGattServiceClient()->Init(GetSystemBus()); |
| 286 GetBluetoothInputClient()->Init(GetSystemBus()); |
| 287 GetBluetoothProfileManagerClient()->Init(GetSystemBus()); |
| 288 GetCrasAudioClient()->Init(GetSystemBus()); |
| 289 GetCrosDisksClient()->Init(GetSystemBus()); |
| 290 GetCryptohomeClient()->Init(GetSystemBus()); |
| 291 GetDebugDaemonClient()->Init(GetSystemBus()); |
| 292 GetEasyUnlockClient()->Init(GetSystemBus()); |
| 293 GetGsmSMSClient()->Init(GetSystemBus()); |
| 294 GetImageBurnerClient()->Init(GetSystemBus()); |
| 295 GetIntrospectableClient()->Init(GetSystemBus()); |
| 296 GetLorgnetteManagerClient()->Init(GetSystemBus()); |
| 297 GetModemMessagingClient()->Init(GetSystemBus()); |
| 298 GetPermissionBrokerClient()->Init(GetSystemBus()); |
| 299 GetPowerManagerClient()->Init(GetSystemBus()); |
| 300 GetSessionManagerClient()->Init(GetSystemBus()); |
| 301 GetShillDeviceClient()->Init(GetSystemBus()); |
| 302 GetShillIPConfigClient()->Init(GetSystemBus()); |
| 303 GetShillManagerClient()->Init(GetSystemBus()); |
| 304 GetShillServiceClient()->Init(GetSystemBus()); |
| 305 GetShillProfileClient()->Init(GetSystemBus()); |
| 306 GetSMSClient()->Init(GetSystemBus()); |
| 307 GetSystemClockClient()->Init(GetSystemBus()); |
| 308 GetUpdateEngineClient()->Init(GetSystemBus()); |
| 309 |
| 310 // Initialize the NFC clients in the correct order. The order of |
| 311 // initialization matters due to dependencies that exist between the |
| 312 // client objects. |
| 313 GetNfcManagerClient()->Init(GetSystemBus()); |
| 314 GetNfcAdapterClient()->Init(GetSystemBus()); |
| 315 GetNfcDeviceClient()->Init(GetSystemBus()); |
| 316 GetNfcTagClient()->Init(GetSystemBus()); |
| 317 GetNfcRecordClient()->Init(GetSystemBus()); |
| 318 |
| 319 // PowerPolicyController is dependent on PowerManagerClient, so |
| 320 // initialize it after the main list of clients. |
| 321 if (GetPowerPolicyController()) |
| 322 GetPowerPolicyController()->Init(this); |
| 323 |
| 324 // This must be called after the list of clients so they've each had a |
| 325 // chance to register with their object g_dbus_thread_managers. |
| 326 if (GetSystemBus()) |
| 327 GetSystemBus()->GetManagedObjects(); |
| 328 |
| 329 client_bundle_->SetupDefaultEnvironment(); |
| 330 } |
268 | 331 |
269 // static | 332 // static |
270 bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) { | 333 bool DBusThreadManager::IsUsingStub(DBusClientBundle::DBusClientType client) { |
271 return !(unstub_client_mask_ & client); | 334 return !(unstub_client_mask_ & client); |
272 } | 335 } |
273 | 336 |
274 // static | 337 // static |
275 void DBusThreadManager::Initialize() { | 338 void DBusThreadManager::Initialize() { |
276 // If we initialize DBusThreadManager twice we may also be shutting it down | 339 // If we initialize DBusThreadManager twice we may also be shutting it down |
277 // early; do not allow that. | 340 // early; do not allow that. |
| 341 if (g_using_dbus_thread_manager_for_testing) |
| 342 return; |
| 343 |
278 CHECK(g_dbus_thread_manager == NULL); | 344 CHECK(g_dbus_thread_manager == NULL); |
279 | |
280 if (g_dbus_thread_manager_for_testing) { | |
281 g_dbus_thread_manager = g_dbus_thread_manager_for_testing; | |
282 InitializeClients(); | |
283 VLOG(1) << "DBusThreadManager initialized with test implementation"; | |
284 return; | |
285 } | |
286 | |
287 bool use_dbus_stub = !base::SysInfo::IsRunningOnChromeOS() || | 345 bool use_dbus_stub = !base::SysInfo::IsRunningOnChromeOS() || |
288 CommandLine::ForCurrentProcess()->HasSwitch( | 346 CommandLine::ForCurrentProcess()->HasSwitch( |
289 chromeos::switches::kDbusStub); | 347 chromeos::switches::kDbusStub); |
290 bool force_unstub_clients = CommandLine::ForCurrentProcess()->HasSwitch( | 348 bool force_unstub_clients = CommandLine::ForCurrentProcess()->HasSwitch( |
291 chromeos::switches::kDbusUnstubClients); | 349 chromeos::switches::kDbusUnstubClients); |
292 // Determine whether we use stub or real client implementations. | 350 // Determine whether we use stub or real client implementations. |
293 if (force_unstub_clients) { | 351 if (force_unstub_clients) { |
294 InitializeWithPartialStub( | 352 InitializeWithPartialStub( |
295 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 353 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
296 chromeos::switches::kDbusUnstubClients)); | 354 chromeos::switches::kDbusUnstubClients)); |
297 } else if (use_dbus_stub) { | 355 } else if (use_dbus_stub) { |
298 InitializeWithStub(); | 356 InitializeWithStubs(); |
299 } else { | 357 } else { |
300 InitializeRegular(); | 358 InitializeRegular(); |
301 } | 359 } |
302 } | 360 } |
303 | 361 |
304 // static | 362 // static |
305 void DBusThreadManager::SetInstanceForTesting( | 363 scoped_ptr<DBusThreadManagerSetter> DBusThreadManager::GetSetterForTesting() { |
306 DBusThreadManager* dbus_thread_manager) { | 364 if (!g_using_dbus_thread_manager_for_testing) { |
307 CHECK(!g_dbus_thread_manager); | 365 g_using_dbus_thread_manager_for_testing = true; |
308 CHECK(!g_dbus_thread_manager_for_testing); | 366 InitializeWithStubs(); |
309 g_dbus_thread_manager_for_testing = dbus_thread_manager; | 367 } |
| 368 |
| 369 return make_scoped_ptr(new DBusThreadManagerSetter()); |
310 } | 370 } |
311 | 371 |
312 // static | 372 // static |
313 void DBusThreadManager::InitializeForTesting( | 373 void DBusThreadManager::CreateGlobalInstance() { |
314 DBusThreadManager* dbus_thread_manager) { | 374 CHECK(!g_dbus_thread_manager); |
315 unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; | 375 g_dbus_thread_manager = new DBusThreadManager(); |
316 SetInstanceForTesting(dbus_thread_manager); | 376 g_dbus_thread_manager->InitializeClients(); |
317 Initialize(); | |
318 } | 377 } |
319 | 378 |
320 // static | 379 // static |
321 void DBusThreadManager::InitializeRegular() { | 380 void DBusThreadManager::InitializeRegular() { |
322 unstub_client_mask_ = DBusClientBundle::ALL_CLIENTS; | 381 unstub_client_mask_ = DBusClientBundle::ALL_CLIENTS; |
323 g_dbus_thread_manager = new DBusThreadManagerImpl(); | 382 CreateGlobalInstance(); |
324 InitializeClients(); | |
325 VLOG(1) << "DBusThreadManager initialized for Chrome OS"; | 383 VLOG(1) << "DBusThreadManager initialized for Chrome OS"; |
326 } | 384 } |
327 | 385 |
328 // static | 386 // static |
| 387 void DBusThreadManager::InitializeWithStubs() { |
| 388 unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; |
| 389 CreateGlobalInstance(); |
| 390 VLOG(1) << "DBusThreadManager created for testing"; |
| 391 } |
| 392 |
| 393 // static |
329 void DBusThreadManager::InitializeWithPartialStub( | 394 void DBusThreadManager::InitializeWithPartialStub( |
330 const std::string& unstub_clients) { | 395 const std::string& unstub_clients) { |
331 // If we initialize DBusThreadManager twice we may also be shutting it down | |
332 // early; do not allow that. | |
333 CHECK(g_dbus_thread_manager == NULL); | |
334 | |
335 unstub_client_mask_ = DBusClientBundle::ParseUnstubList(unstub_clients); | 396 unstub_client_mask_ = DBusClientBundle::ParseUnstubList(unstub_clients); |
336 // We should have something parsed correctly here. | 397 // We should have something parsed correctly here. |
337 if (unstub_client_mask_ == 0) { | 398 if (unstub_client_mask_ == 0) { |
338 LOG(FATAL) << "Switch values for --" | 399 LOG(FATAL) << "Switch values for --" |
339 << chromeos::switches::kDbusUnstubClients | 400 << chromeos::switches::kDbusUnstubClients |
340 << " cannot be parsed: " | 401 << " cannot be parsed: " |
341 << unstub_clients; | 402 << unstub_clients; |
342 } | 403 } |
343 DBusThreadManagerImpl* dbus_thread_manager = new DBusThreadManagerImpl(); | |
344 VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; | 404 VLOG(1) << "DBusThreadManager initialized for mixed runtime environment"; |
345 g_dbus_thread_manager = dbus_thread_manager; | 405 CreateGlobalInstance(); |
346 InitializeClients(); | |
347 dbus_thread_manager->SetupDefaultEnvironment(); | |
348 } | 406 } |
349 | 407 |
350 // static | 408 // static |
351 void DBusThreadManager::InitializeWithStub() { | |
352 unstub_client_mask_ = DBusClientBundle::NO_CLIENTS; | |
353 // If we initialize DBusThreadManager twice we may also be shutting it down | |
354 // early; do not allow that. | |
355 CHECK(g_dbus_thread_manager == NULL); | |
356 FakeDBusThreadManager* fake_dbus_thread_manager = new FakeDBusThreadManager; | |
357 fake_dbus_thread_manager->SetFakeClients(); | |
358 g_dbus_thread_manager = fake_dbus_thread_manager; | |
359 InitializeClients(); | |
360 fake_dbus_thread_manager->SetupDefaultEnvironment(); | |
361 VLOG(1) << "DBusThreadManager initialized with stub implementation"; | |
362 } | |
363 | |
364 // static | |
365 bool DBusThreadManager::IsInitialized() { | 409 bool DBusThreadManager::IsInitialized() { |
366 return g_dbus_thread_manager != NULL; | 410 return g_dbus_thread_manager != NULL; |
367 } | 411 } |
368 | 412 |
369 // static | 413 // static |
370 void DBusThreadManager::Shutdown() { | 414 void DBusThreadManager::Shutdown() { |
371 // If we called InitializeForTesting, this may get called more than once. | |
372 // Ensure that we only shutdown DBusThreadManager once. | 415 // Ensure that we only shutdown DBusThreadManager once. |
373 CHECK(g_dbus_thread_manager || g_dbus_thread_manager_for_testing); | 416 CHECK(g_dbus_thread_manager); |
374 DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager; | 417 DBusThreadManager* dbus_thread_manager = g_dbus_thread_manager; |
375 g_dbus_thread_manager = NULL; | 418 g_dbus_thread_manager = NULL; |
376 g_dbus_thread_manager_for_testing = NULL; | 419 g_using_dbus_thread_manager_for_testing = false; |
377 delete dbus_thread_manager; | 420 delete dbus_thread_manager; |
378 VLOG(1) << "DBusThreadManager Shutdown completed"; | 421 VLOG(1) << "DBusThreadManager Shutdown completed"; |
379 } | 422 } |
380 | 423 |
381 DBusThreadManager::DBusThreadManager() { | |
382 dbus::statistics::Initialize(); | |
383 } | |
384 | |
385 DBusThreadManager::~DBusThreadManager() { | |
386 dbus::statistics::Shutdown(); | |
387 if (g_dbus_thread_manager == NULL) | |
388 return; // Called form Shutdown() or local test instance. | |
389 // There should never be both a global instance and a local instance. | |
390 CHECK(this == g_dbus_thread_manager); | |
391 if (g_dbus_thread_manager_for_testing) { | |
392 g_dbus_thread_manager = NULL; | |
393 g_dbus_thread_manager_for_testing = NULL; | |
394 VLOG(1) << "DBusThreadManager destroyed"; | |
395 } else { | |
396 LOG(FATAL) << "~DBusThreadManager() called outside of Shutdown()"; | |
397 } | |
398 } | |
399 | |
400 // static | 424 // static |
401 DBusThreadManager* DBusThreadManager::Get() { | 425 DBusThreadManager* DBusThreadManager::Get() { |
402 CHECK(g_dbus_thread_manager) | 426 CHECK(g_dbus_thread_manager) |
403 << "DBusThreadManager::Get() called before Initialize()"; | 427 << "DBusThreadManager::Get() called before Initialize()"; |
404 return g_dbus_thread_manager; | 428 return g_dbus_thread_manager; |
405 } | 429 } |
406 | 430 |
407 // static | 431 DBusThreadManagerSetter::DBusThreadManagerSetter() { |
408 void DBusThreadManager::InitializeClients() { | 432 } |
409 InitClient(g_dbus_thread_manager->GetBluetoothAdapterClient()); | 433 |
410 InitClient(g_dbus_thread_manager->GetBluetoothAgentManagerClient()); | 434 DBusThreadManagerSetter::~DBusThreadManagerSetter() { |
411 InitClient(g_dbus_thread_manager->GetBluetoothDeviceClient()); | 435 } |
412 InitClient(g_dbus_thread_manager->GetBluetoothGattCharacteristicClient()); | 436 |
413 InitClient(g_dbus_thread_manager->GetBluetoothGattDescriptorClient()); | 437 void DBusThreadManagerSetter::SetBluetoothAdapterClient( |
414 InitClient(g_dbus_thread_manager->GetBluetoothGattManagerClient()); | 438 scoped_ptr<BluetoothAdapterClient> client) { |
415 InitClient(g_dbus_thread_manager->GetBluetoothGattServiceClient()); | 439 DBusThreadManager::Get()->client_bundle_->bluetooth_adapter_client_ = |
416 InitClient(g_dbus_thread_manager->GetBluetoothInputClient()); | 440 client.Pass(); |
417 InitClient(g_dbus_thread_manager->GetBluetoothProfileManagerClient()); | 441 } |
418 InitClient(g_dbus_thread_manager->GetCrasAudioClient()); | 442 |
419 InitClient(g_dbus_thread_manager->GetCrosDisksClient()); | 443 void DBusThreadManagerSetter::SetBluetoothAgentManagerClient( |
420 InitClient(g_dbus_thread_manager->GetCryptohomeClient()); | 444 scoped_ptr<BluetoothAgentManagerClient> client) { |
421 InitClient(g_dbus_thread_manager->GetDebugDaemonClient()); | 445 DBusThreadManager::Get()->client_bundle_->bluetooth_agent_manager_client_ = |
422 InitClient(g_dbus_thread_manager->GetEasyUnlockClient()); | 446 client.Pass(); |
423 InitClient(g_dbus_thread_manager->GetGsmSMSClient()); | 447 } |
424 InitClient(g_dbus_thread_manager->GetImageBurnerClient()); | 448 |
425 InitClient(g_dbus_thread_manager->GetIntrospectableClient()); | 449 void DBusThreadManagerSetter::SetBluetoothDeviceClient( |
426 InitClient(g_dbus_thread_manager->GetLorgnetteManagerClient()); | 450 scoped_ptr<BluetoothDeviceClient> client) { |
427 InitClient(g_dbus_thread_manager->GetModemMessagingClient()); | 451 DBusThreadManager::Get()->client_bundle_->bluetooth_device_client_ = |
428 InitClient(g_dbus_thread_manager->GetPermissionBrokerClient()); | 452 client.Pass(); |
429 InitClient(g_dbus_thread_manager->GetPowerManagerClient()); | 453 } |
430 InitClient(g_dbus_thread_manager->GetSessionManagerClient()); | 454 |
431 InitClient(g_dbus_thread_manager->GetShillDeviceClient()); | 455 void DBusThreadManagerSetter::SetBluetoothGattCharacteristicClient( |
432 InitClient(g_dbus_thread_manager->GetShillIPConfigClient()); | 456 scoped_ptr<BluetoothGattCharacteristicClient> client) { |
433 InitClient(g_dbus_thread_manager->GetShillManagerClient()); | 457 DBusThreadManager::Get()->client_bundle_-> |
434 InitClient(g_dbus_thread_manager->GetShillServiceClient()); | 458 bluetooth_gatt_characteristic_client_ = client.Pass(); |
435 InitClient(g_dbus_thread_manager->GetShillProfileClient()); | 459 } |
436 InitClient(g_dbus_thread_manager->GetSMSClient()); | 460 |
437 InitClient(g_dbus_thread_manager->GetSystemClockClient()); | 461 void DBusThreadManagerSetter::SetBluetoothGattDescriptorClient( |
438 InitClient(g_dbus_thread_manager->GetUpdateEngineClient()); | 462 scoped_ptr<BluetoothGattDescriptorClient> client) { |
439 | 463 DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_descriptor_client_ = |
440 // Initialize the NFC clients in the correct order. The order of | 464 client.Pass(); |
441 // initialization matters due to dependencies that exist between the | 465 } |
442 // client objects. | 466 |
443 InitClient(g_dbus_thread_manager->GetNfcManagerClient()); | 467 void DBusThreadManagerSetter::SetBluetoothGattManagerClient( |
444 InitClient(g_dbus_thread_manager->GetNfcAdapterClient()); | 468 scoped_ptr<BluetoothGattManagerClient> client) { |
445 InitClient(g_dbus_thread_manager->GetNfcDeviceClient()); | 469 DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_manager_client_ = |
446 InitClient(g_dbus_thread_manager->GetNfcTagClient()); | 470 client.Pass(); |
447 InitClient(g_dbus_thread_manager->GetNfcRecordClient()); | 471 } |
448 | 472 |
449 // PowerPolicyController is dependent on PowerManagerClient, so | 473 void DBusThreadManagerSetter::SetBluetoothGattServiceClient( |
450 // initialize it after the main list of clients. | 474 scoped_ptr<BluetoothGattServiceClient> client) { |
451 if (g_dbus_thread_manager->GetPowerPolicyController()) { | 475 DBusThreadManager::Get()->client_bundle_->bluetooth_gatt_service_client_ = |
452 g_dbus_thread_manager->GetPowerPolicyController()->Init( | 476 client.Pass(); |
453 g_dbus_thread_manager); | 477 } |
454 } | 478 |
455 | 479 void DBusThreadManagerSetter::SetBluetoothInputClient( |
456 // This must be called after the list of clients so they've each had a | 480 scoped_ptr<BluetoothInputClient> client) { |
457 // chance to register with their object g_dbus_thread_managers. | 481 DBusThreadManager::Get()->client_bundle_->bluetooth_input_client_ = |
458 if (g_dbus_thread_manager->GetSystemBus()) | 482 client.Pass(); |
459 g_dbus_thread_manager->GetSystemBus()->GetManagedObjects(); | 483 } |
460 } | 484 |
461 | 485 void DBusThreadManagerSetter::SetBluetoothProfileManagerClient( |
462 // static | 486 scoped_ptr<BluetoothProfileManagerClient> client) { |
463 void DBusThreadManager::InitClient(DBusClient* client) { | 487 DBusThreadManager::Get()->client_bundle_->bluetooth_profile_manager_client_ = |
464 if (client) | 488 client.Pass(); |
465 client->Init(g_dbus_thread_manager->GetSystemBus()); | 489 } |
| 490 |
| 491 void DBusThreadManagerSetter::SetCrasAudioClient( |
| 492 scoped_ptr<CrasAudioClient> client) { |
| 493 DBusThreadManager::Get()->client_bundle_->cras_audio_client_ = client.Pass(); |
| 494 } |
| 495 |
| 496 void DBusThreadManagerSetter::SetCrosDisksClient( |
| 497 scoped_ptr<CrosDisksClient> client) { |
| 498 DBusThreadManager::Get()->client_bundle_->cros_disks_client_ = client.Pass(); |
| 499 } |
| 500 |
| 501 void DBusThreadManagerSetter::SetCryptohomeClient( |
| 502 scoped_ptr<CryptohomeClient> client) { |
| 503 DBusThreadManager::Get()->client_bundle_->cryptohome_client_ = client.Pass(); |
| 504 } |
| 505 |
| 506 void DBusThreadManagerSetter::SetDebugDaemonClient( |
| 507 scoped_ptr<DebugDaemonClient> client) { |
| 508 DBusThreadManager::Get()->client_bundle_->debug_daemon_client_ = |
| 509 client.Pass(); |
| 510 } |
| 511 |
| 512 void DBusThreadManagerSetter::SetEasyUnlockClient( |
| 513 scoped_ptr<EasyUnlockClient> client) { |
| 514 DBusThreadManager::Get()->client_bundle_->easy_unlock_client_ = client.Pass(); |
| 515 } |
| 516 |
| 517 void DBusThreadManagerSetter::SetLorgnetteManagerClient( |
| 518 scoped_ptr<LorgnetteManagerClient> client) { |
| 519 DBusThreadManager::Get()->client_bundle_->lorgnette_manager_client_ = |
| 520 client.Pass(); |
| 521 } |
| 522 |
| 523 void DBusThreadManagerSetter::SetShillDeviceClient( |
| 524 scoped_ptr<ShillDeviceClient> client) { |
| 525 DBusThreadManager::Get()->client_bundle_->shill_device_client_ = |
| 526 client.Pass(); |
| 527 } |
| 528 |
| 529 void DBusThreadManagerSetter::SetShillIPConfigClient( |
| 530 scoped_ptr<ShillIPConfigClient> client) { |
| 531 DBusThreadManager::Get()->client_bundle_->shill_ipconfig_client_ = |
| 532 client.Pass(); |
| 533 } |
| 534 |
| 535 void DBusThreadManagerSetter::SetShillManagerClient( |
| 536 scoped_ptr<ShillManagerClient> client) { |
| 537 DBusThreadManager::Get()->client_bundle_->shill_manager_client_ = |
| 538 client.Pass(); |
| 539 } |
| 540 |
| 541 void DBusThreadManagerSetter::SetShillServiceClient( |
| 542 scoped_ptr<ShillServiceClient> client) { |
| 543 DBusThreadManager::Get()->client_bundle_->shill_service_client_ = |
| 544 client.Pass(); |
| 545 } |
| 546 |
| 547 void DBusThreadManagerSetter::SetShillProfileClient( |
| 548 scoped_ptr<ShillProfileClient> client) { |
| 549 DBusThreadManager::Get()->client_bundle_->shill_profile_client_ = |
| 550 client.Pass(); |
| 551 } |
| 552 |
| 553 void DBusThreadManagerSetter::SetGsmSMSClient( |
| 554 scoped_ptr<GsmSMSClient> client) { |
| 555 DBusThreadManager::Get()->client_bundle_->gsm_sms_client_ = client.Pass(); |
| 556 } |
| 557 |
| 558 void DBusThreadManagerSetter::SetImageBurnerClient( |
| 559 scoped_ptr<ImageBurnerClient> client) { |
| 560 DBusThreadManager::Get()->client_bundle_->image_burner_client_ = |
| 561 client.Pass(); |
| 562 } |
| 563 |
| 564 void DBusThreadManagerSetter::SetIntrospectableClient( |
| 565 scoped_ptr<IntrospectableClient> client) { |
| 566 DBusThreadManager::Get()->client_bundle_->introspectable_client_ = |
| 567 client.Pass(); |
| 568 } |
| 569 |
| 570 void DBusThreadManagerSetter::SetModemMessagingClient( |
| 571 scoped_ptr<ModemMessagingClient> client) { |
| 572 DBusThreadManager::Get()->client_bundle_->modem_messaging_client_ = |
| 573 client.Pass(); |
| 574 } |
| 575 |
| 576 void DBusThreadManagerSetter::SetNfcAdapterClient( |
| 577 scoped_ptr<NfcAdapterClient> client) { |
| 578 DBusThreadManager::Get()->client_bundle_->nfc_adapter_client_ = client.Pass(); |
| 579 } |
| 580 |
| 581 void DBusThreadManagerSetter::SetNfcDeviceClient( |
| 582 scoped_ptr<NfcDeviceClient> client) { |
| 583 DBusThreadManager::Get()->client_bundle_->nfc_device_client_ = client.Pass(); |
| 584 } |
| 585 |
| 586 void DBusThreadManagerSetter::SetNfcManagerClient( |
| 587 scoped_ptr<NfcManagerClient> client) { |
| 588 DBusThreadManager::Get()->client_bundle_->nfc_manager_client_ = client.Pass(); |
| 589 } |
| 590 |
| 591 void DBusThreadManagerSetter::SetNfcRecordClient( |
| 592 scoped_ptr<NfcRecordClient> client) { |
| 593 DBusThreadManager::Get()->client_bundle_->nfc_record_client_ = client.Pass(); |
| 594 } |
| 595 |
| 596 void DBusThreadManagerSetter::SetNfcTagClient( |
| 597 scoped_ptr<NfcTagClient> client) { |
| 598 DBusThreadManager::Get()->client_bundle_->nfc_tag_client_ = client.Pass(); |
| 599 } |
| 600 |
| 601 void DBusThreadManagerSetter::SetPermissionBrokerClient( |
| 602 scoped_ptr<PermissionBrokerClient> client) { |
| 603 DBusThreadManager::Get()->client_bundle_->permission_broker_client_ = |
| 604 client.Pass(); |
| 605 } |
| 606 |
| 607 void DBusThreadManagerSetter::SetPowerManagerClient( |
| 608 scoped_ptr<PowerManagerClient> client) { |
| 609 DBusThreadManager::Get()->power_policy_controller_.reset(); |
| 610 DBusThreadManager::Get()->client_bundle_->power_manager_client_ = |
| 611 client.Pass(); |
| 612 DBusThreadManager::Get()->power_policy_controller_.reset( |
| 613 new PowerPolicyController); |
| 614 DBusThreadManager::Get()->power_policy_controller_->Init( |
| 615 DBusThreadManager::Get()); |
| 616 } |
| 617 |
| 618 void DBusThreadManagerSetter::SetSessionManagerClient( |
| 619 scoped_ptr<SessionManagerClient> client) { |
| 620 DBusThreadManager::Get()->client_bundle_->session_manager_client_ = |
| 621 client.Pass(); |
| 622 } |
| 623 |
| 624 void DBusThreadManagerSetter::SetSMSClient(scoped_ptr<SMSClient> client) { |
| 625 DBusThreadManager::Get()->client_bundle_->sms_client_ = client.Pass(); |
| 626 } |
| 627 |
| 628 void DBusThreadManagerSetter::SetSystemClockClient( |
| 629 scoped_ptr<SystemClockClient> client) { |
| 630 DBusThreadManager::Get()->client_bundle_->system_clock_client_ = |
| 631 client.Pass(); |
| 632 } |
| 633 |
| 634 void DBusThreadManagerSetter::SetUpdateEngineClient( |
| 635 scoped_ptr<UpdateEngineClient> client) { |
| 636 DBusThreadManager::Get()->client_bundle_->update_engine_client_ = |
| 637 client.Pass(); |
466 } | 638 } |
467 | 639 |
468 } // namespace chromeos | 640 } // namespace chromeos |
OLD | NEW |