OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bluetooth_le_advertisement_service_provider.h" | 5 #include "device/bluetooth/dbus/bluetooth_le_advertisement_service_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "chromeos/dbus/dbus_thread_manager.h" | |
13 #include "chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h" | |
14 #include "dbus/exported_object.h" | 12 #include "dbus/exported_object.h" |
15 #include "dbus/message.h" | 13 #include "dbus/message.h" |
| 14 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| 15 #include "device/bluetooth/dbus/fake_bluetooth_le_advertisement_service_provider
.h" |
16 #include "third_party/cros_system_api/dbus/service_constants.h" | 16 #include "third_party/cros_system_api/dbus/service_constants.h" |
17 | 17 |
18 namespace chromeos { | 18 namespace bluez { |
19 | 19 |
20 namespace { | 20 namespace { |
21 const char kErrorInvalidArgs[] = "org.freedesktop.DBus.Error.InvalidArgs"; | 21 const char kErrorInvalidArgs[] = "org.freedesktop.DBus.Error.InvalidArgs"; |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 // The BluetoothAdvertisementServiceProvider implementation used in production. | 24 // The BluetoothAdvertisementServiceProvider implementation used in production. |
25 class BluetoothAdvertisementServiceProviderImpl | 25 class BluetoothAdvertisementServiceProviderImpl |
26 : public BluetoothLEAdvertisementServiceProvider { | 26 : public BluetoothLEAdvertisementServiceProvider { |
27 public: | 27 public: |
28 BluetoothAdvertisementServiceProviderImpl( | 28 BluetoothAdvertisementServiceProviderImpl( |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // than we do. | 390 // than we do. |
391 // Note: This should remain the last member so it'll be destroyed and | 391 // Note: This should remain the last member so it'll be destroyed and |
392 // invalidate its weak pointers before any other members are destroyed. | 392 // invalidate its weak pointers before any other members are destroyed. |
393 base::WeakPtrFactory<BluetoothAdvertisementServiceProviderImpl> | 393 base::WeakPtrFactory<BluetoothAdvertisementServiceProviderImpl> |
394 weak_ptr_factory_; | 394 weak_ptr_factory_; |
395 | 395 |
396 DISALLOW_COPY_AND_ASSIGN(BluetoothAdvertisementServiceProviderImpl); | 396 DISALLOW_COPY_AND_ASSIGN(BluetoothAdvertisementServiceProviderImpl); |
397 }; | 397 }; |
398 | 398 |
399 BluetoothLEAdvertisementServiceProvider:: | 399 BluetoothLEAdvertisementServiceProvider:: |
400 BluetoothLEAdvertisementServiceProvider() { | 400 BluetoothLEAdvertisementServiceProvider() {} |
401 } | |
402 | 401 |
403 BluetoothLEAdvertisementServiceProvider:: | 402 BluetoothLEAdvertisementServiceProvider:: |
404 ~BluetoothLEAdvertisementServiceProvider() { | 403 ~BluetoothLEAdvertisementServiceProvider() {} |
405 } | |
406 | 404 |
407 // static | 405 // static |
408 scoped_ptr<BluetoothLEAdvertisementServiceProvider> | 406 scoped_ptr<BluetoothLEAdvertisementServiceProvider> |
409 BluetoothLEAdvertisementServiceProvider::Create( | 407 BluetoothLEAdvertisementServiceProvider::Create( |
410 dbus::Bus* bus, | 408 dbus::Bus* bus, |
411 const dbus::ObjectPath& object_path, | 409 const dbus::ObjectPath& object_path, |
412 Delegate* delegate, | 410 Delegate* delegate, |
413 AdvertisementType type, | 411 AdvertisementType type, |
414 scoped_ptr<UUIDList> service_uuids, | 412 scoped_ptr<UUIDList> service_uuids, |
415 scoped_ptr<ManufacturerData> manufacturer_data, | 413 scoped_ptr<ManufacturerData> manufacturer_data, |
416 scoped_ptr<UUIDList> solicit_uuids, | 414 scoped_ptr<UUIDList> solicit_uuids, |
417 scoped_ptr<ServiceData> service_data) { | 415 scoped_ptr<ServiceData> service_data) { |
418 if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) { | 416 if (!bluez::BluezDBusManager::Get()->IsUsingStub()) { |
419 return make_scoped_ptr(new BluetoothAdvertisementServiceProviderImpl( | 417 return make_scoped_ptr(new BluetoothAdvertisementServiceProviderImpl( |
420 bus, object_path, delegate, type, service_uuids.Pass(), | 418 bus, object_path, delegate, type, service_uuids.Pass(), |
421 manufacturer_data.Pass(), solicit_uuids.Pass(), service_data.Pass())); | 419 manufacturer_data.Pass(), solicit_uuids.Pass(), service_data.Pass())); |
422 } else { | 420 } else { |
423 return make_scoped_ptr( | 421 return make_scoped_ptr( |
424 new FakeBluetoothLEAdvertisementServiceProvider(object_path, delegate)); | 422 new FakeBluetoothLEAdvertisementServiceProvider(object_path, delegate)); |
425 } | 423 } |
426 } | 424 } |
427 | 425 |
428 } // namespace chromeos | 426 } // namespace bluez |
OLD | NEW |