Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc

Issue 1914893002: DBus changes for implementing local GATT attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_classes
Patch Set: test leak fix Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc
diff --git a/device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc b/device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..30d7dcdd48ae38fe926b117bb98a63c248d718b2
--- /dev/null
+++ b/device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc
@@ -0,0 +1,83 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "device/bluetooth/dbus/bluetooth_gatt_application_service_provider.h"
+
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "base/memory/ptr_util.h"
+#include "device/bluetooth/bluetooth_uuid.h"
+#include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_application_service_provider_impl.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_delegate_wrapper.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_delegate_wrapper.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h"
+#include "device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h"
+#include "device/bluetooth/dbus/bluez_dbus_manager.h"
+#include "device/bluetooth/dbus/fake_bluetooth_gatt_application_service_provider.h"
+
+namespace bluez {
+
+BluetoothGattApplicationServiceProvider::
+ BluetoothGattApplicationServiceProvider() {}
+
+BluetoothGattApplicationServiceProvider::
+ ~BluetoothGattApplicationServiceProvider() {}
+
+// static
+void BluetoothGattApplicationServiceProvider::CreateAttributeServiceProviders(
+ dbus::Bus* bus,
+ const std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>& services,
+ std::vector<std::unique_ptr<BluetoothGattServiceServiceProvider>>*
+ service_providers,
+ std::vector<std::unique_ptr<BluetoothGattCharacteristicServiceProvider>>*
+ characteristic_providers,
+ std::vector<std::unique_ptr<BluetoothGattDescriptorServiceProvider>>*
+ descriptor_providers) {
+ for (const auto& service : services) {
+ service_providers->push_back(
+ base::WrapUnique(BluetoothGattServiceServiceProvider::Create(
+ bus, service.second->object_path(),
+ service.second->GetUUID().value(),
+ std::vector<dbus::ObjectPath>())));
+ for (const auto& characteristic : service.second->GetCharacteristics()) {
+ characteristic_providers->push_back(
+ base::WrapUnique(BluetoothGattCharacteristicServiceProvider::Create(
+ bus, characteristic->object_path(),
+ base::WrapUnique(new BluetoothGattCharacteristicDelegateWrapper(
+ service.second, characteristic.get())),
+ characteristic->GetUUID().value(), std::vector<std::string>(),
+ std::vector<std::string>(), service.second->object_path())));
+ for (const auto& descriptor : characteristic->GetDescriptors()) {
+ descriptor_providers->push_back(
+ base::WrapUnique(BluetoothGattDescriptorServiceProvider::Create(
+ bus, descriptor->object_path(),
+ base::WrapUnique(new BluetoothGattDescriptorDelegateWrapper(
+ service.second, descriptor.get())),
+ descriptor->GetUUID().value(), std::vector<std::string>(),
+ characteristic->object_path())));
+ }
+ }
+ }
+}
+
+// static
+std::unique_ptr<BluetoothGattApplicationServiceProvider>
+BluetoothGattApplicationServiceProvider::Create(
+ dbus::Bus* bus,
+ const dbus::ObjectPath& object_path,
+ const std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>&
+ services) {
+ if (!bluez::BluezDBusManager::Get()->IsUsingFakes()) {
+ return base::WrapUnique(new BluetoothGattApplicationServiceProviderImpl(
+ bus, object_path, services));
+ }
+ return base::WrapUnique(
+ new FakeBluetoothGattApplicationServiceProvider(object_path, services));
+}
+
+} // namespace bluez

Powered by Google App Engine
This is Rietveld 408576698