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 "device/bluetooth/dbus/bluez_dbus_manager.h" | 5 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
9 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
10 #include "dbus/bus.h" | 12 #include "dbus/bus.h" |
11 #include "dbus/dbus_statistics.h" | 13 #include "dbus/dbus_statistics.h" |
12 #include "device/bluetooth/dbus/bluetooth_adapter_client.h" | 14 #include "device/bluetooth/dbus/bluetooth_adapter_client.h" |
13 #include "device/bluetooth/dbus/bluetooth_agent_manager_client.h" | 15 #include "device/bluetooth/dbus/bluetooth_agent_manager_client.h" |
14 #include "device/bluetooth/dbus/bluetooth_device_client.h" | 16 #include "device/bluetooth/dbus/bluetooth_device_client.h" |
15 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" | 17 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" |
16 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" | 18 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" |
17 #include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" | 19 #include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" |
18 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" | 20 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" |
19 #include "device/bluetooth/dbus/bluetooth_input_client.h" | 21 #include "device/bluetooth/dbus/bluetooth_input_client.h" |
20 #include "device/bluetooth/dbus/bluetooth_le_advertising_manager_client.h" | 22 #include "device/bluetooth/dbus/bluetooth_le_advertising_manager_client.h" |
21 #include "device/bluetooth/dbus/bluetooth_media_client.h" | 23 #include "device/bluetooth/dbus/bluetooth_media_client.h" |
22 #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" | 24 #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" |
23 #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" | 25 #include "device/bluetooth/dbus/bluetooth_profile_manager_client.h" |
24 | 26 |
25 namespace bluez { | 27 namespace bluez { |
26 | 28 |
27 static BluezDBusManager* g_bluez_dbus_manager = nullptr; | 29 static BluezDBusManager* g_bluez_dbus_manager = nullptr; |
28 static bool g_using_bluez_dbus_manager_for_testing = false; | 30 static bool g_using_bluez_dbus_manager_for_testing = false; |
29 | 31 |
30 BluezDBusManager::BluezDBusManager( | 32 BluezDBusManager::BluezDBusManager( |
31 dbus::Bus* bus, | 33 dbus::Bus* bus, |
32 scoped_ptr<BluetoothDBusClientBundle> client_bundle) | 34 scoped_ptr<BluetoothDBusClientBundle> client_bundle) |
33 : bus_(bus), client_bundle_(client_bundle.Pass()) {} | 35 : bus_(bus), client_bundle_(std::move(client_bundle)) {} |
34 | 36 |
35 BluezDBusManager::~BluezDBusManager() { | 37 BluezDBusManager::~BluezDBusManager() { |
36 // Delete all D-Bus clients before shutting down the system bus. | 38 // Delete all D-Bus clients before shutting down the system bus. |
37 client_bundle_.reset(); | 39 client_bundle_.reset(); |
38 } | 40 } |
39 | 41 |
40 dbus::Bus* bluez::BluezDBusManager::GetSystemBus() { | 42 dbus::Bus* bluez::BluezDBusManager::GetSystemBus() { |
41 return bus_; | 43 return bus_; |
42 } | 44 } |
43 | 45 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 return g_bluez_dbus_manager; | 172 return g_bluez_dbus_manager; |
171 } | 173 } |
172 | 174 |
173 BluezDBusManagerSetter::BluezDBusManagerSetter() {} | 175 BluezDBusManagerSetter::BluezDBusManagerSetter() {} |
174 | 176 |
175 BluezDBusManagerSetter::~BluezDBusManagerSetter() {} | 177 BluezDBusManagerSetter::~BluezDBusManagerSetter() {} |
176 | 178 |
177 void BluezDBusManagerSetter::SetBluetoothAdapterClient( | 179 void BluezDBusManagerSetter::SetBluetoothAdapterClient( |
178 scoped_ptr<BluetoothAdapterClient> client) { | 180 scoped_ptr<BluetoothAdapterClient> client) { |
179 bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_adapter_client_ = | 181 bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_adapter_client_ = |
180 client.Pass(); | 182 std::move(client); |
181 } | 183 } |
182 | 184 |
183 void BluezDBusManagerSetter::SetBluetoothLEAdvertisingManagerClient( | 185 void BluezDBusManagerSetter::SetBluetoothLEAdvertisingManagerClient( |
184 scoped_ptr<BluetoothLEAdvertisingManagerClient> client) { | 186 scoped_ptr<BluetoothLEAdvertisingManagerClient> client) { |
185 bluez::BluezDBusManager::Get() | 187 bluez::BluezDBusManager::Get() |
186 ->client_bundle_->bluetooth_le_advertising_manager_client_ = | 188 ->client_bundle_->bluetooth_le_advertising_manager_client_ = |
187 client.Pass(); | 189 std::move(client); |
188 } | 190 } |
189 | 191 |
190 void BluezDBusManagerSetter::SetBluetoothAgentManagerClient( | 192 void BluezDBusManagerSetter::SetBluetoothAgentManagerClient( |
191 scoped_ptr<BluetoothAgentManagerClient> client) { | 193 scoped_ptr<BluetoothAgentManagerClient> client) { |
192 bluez::BluezDBusManager::Get() | 194 bluez::BluezDBusManager::Get() |
193 ->client_bundle_->bluetooth_agent_manager_client_ = client.Pass(); | 195 ->client_bundle_->bluetooth_agent_manager_client_ = std::move(client); |
194 } | 196 } |
195 | 197 |
196 void BluezDBusManagerSetter::SetBluetoothDeviceClient( | 198 void BluezDBusManagerSetter::SetBluetoothDeviceClient( |
197 scoped_ptr<BluetoothDeviceClient> client) { | 199 scoped_ptr<BluetoothDeviceClient> client) { |
198 bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_device_client_ = | 200 bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_device_client_ = |
199 client.Pass(); | 201 std::move(client); |
200 } | 202 } |
201 | 203 |
202 void BluezDBusManagerSetter::SetBluetoothGattCharacteristicClient( | 204 void BluezDBusManagerSetter::SetBluetoothGattCharacteristicClient( |
203 scoped_ptr<BluetoothGattCharacteristicClient> client) { | 205 scoped_ptr<BluetoothGattCharacteristicClient> client) { |
204 bluez::BluezDBusManager::Get() | 206 bluez::BluezDBusManager::Get() |
205 ->client_bundle_->bluetooth_gatt_characteristic_client_ = client.Pass(); | 207 ->client_bundle_->bluetooth_gatt_characteristic_client_ = |
| 208 std::move(client); |
206 } | 209 } |
207 | 210 |
208 void BluezDBusManagerSetter::SetBluetoothGattDescriptorClient( | 211 void BluezDBusManagerSetter::SetBluetoothGattDescriptorClient( |
209 scoped_ptr<BluetoothGattDescriptorClient> client) { | 212 scoped_ptr<BluetoothGattDescriptorClient> client) { |
210 bluez::BluezDBusManager::Get() | 213 bluez::BluezDBusManager::Get() |
211 ->client_bundle_->bluetooth_gatt_descriptor_client_ = client.Pass(); | 214 ->client_bundle_->bluetooth_gatt_descriptor_client_ = std::move(client); |
212 } | 215 } |
213 | 216 |
214 void BluezDBusManagerSetter::SetBluetoothGattManagerClient( | 217 void BluezDBusManagerSetter::SetBluetoothGattManagerClient( |
215 scoped_ptr<BluetoothGattManagerClient> client) { | 218 scoped_ptr<BluetoothGattManagerClient> client) { |
216 bluez::BluezDBusManager::Get() | 219 bluez::BluezDBusManager::Get() |
217 ->client_bundle_->bluetooth_gatt_manager_client_ = client.Pass(); | 220 ->client_bundle_->bluetooth_gatt_manager_client_ = std::move(client); |
218 } | 221 } |
219 | 222 |
220 void BluezDBusManagerSetter::SetBluetoothGattServiceClient( | 223 void BluezDBusManagerSetter::SetBluetoothGattServiceClient( |
221 scoped_ptr<BluetoothGattServiceClient> client) { | 224 scoped_ptr<BluetoothGattServiceClient> client) { |
222 bluez::BluezDBusManager::Get() | 225 bluez::BluezDBusManager::Get() |
223 ->client_bundle_->bluetooth_gatt_service_client_ = client.Pass(); | 226 ->client_bundle_->bluetooth_gatt_service_client_ = std::move(client); |
224 } | 227 } |
225 | 228 |
226 void BluezDBusManagerSetter::SetBluetoothInputClient( | 229 void BluezDBusManagerSetter::SetBluetoothInputClient( |
227 scoped_ptr<BluetoothInputClient> client) { | 230 scoped_ptr<BluetoothInputClient> client) { |
228 bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_input_client_ = | 231 bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_input_client_ = |
229 client.Pass(); | 232 std::move(client); |
230 } | 233 } |
231 | 234 |
232 void BluezDBusManagerSetter::SetBluetoothMediaClient( | 235 void BluezDBusManagerSetter::SetBluetoothMediaClient( |
233 scoped_ptr<BluetoothMediaClient> client) { | 236 scoped_ptr<BluetoothMediaClient> client) { |
234 bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_media_client_ = | 237 bluez::BluezDBusManager::Get()->client_bundle_->bluetooth_media_client_ = |
235 client.Pass(); | 238 std::move(client); |
236 } | 239 } |
237 | 240 |
238 void BluezDBusManagerSetter::SetBluetoothMediaTransportClient( | 241 void BluezDBusManagerSetter::SetBluetoothMediaTransportClient( |
239 scoped_ptr<BluetoothMediaTransportClient> client) { | 242 scoped_ptr<BluetoothMediaTransportClient> client) { |
240 bluez::BluezDBusManager::Get() | 243 bluez::BluezDBusManager::Get() |
241 ->client_bundle_->bluetooth_media_transport_client_ = client.Pass(); | 244 ->client_bundle_->bluetooth_media_transport_client_ = std::move(client); |
242 } | 245 } |
243 | 246 |
244 void BluezDBusManagerSetter::SetBluetoothProfileManagerClient( | 247 void BluezDBusManagerSetter::SetBluetoothProfileManagerClient( |
245 scoped_ptr<BluetoothProfileManagerClient> client) { | 248 scoped_ptr<BluetoothProfileManagerClient> client) { |
246 bluez::BluezDBusManager::Get() | 249 bluez::BluezDBusManager::Get() |
247 ->client_bundle_->bluetooth_profile_manager_client_ = client.Pass(); | 250 ->client_bundle_->bluetooth_profile_manager_client_ = std::move(client); |
248 } | 251 } |
249 | 252 |
250 } // namespace bluez | 253 } // namespace bluez |
OLD | NEW |