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

Side by Side Diff: device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.cc

Issue 1920353002: Implement create attribute API functions for BTLE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@api_changes
Patch Set: owners Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/bluez/bluetooth_local_gatt_service_bluez.h> 5 #include <device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h>
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 GetAdapter()->RegisterGattService(this, callback, error_callback); 65 GetAdapter()->RegisterGattService(this, callback, error_callback);
66 } 66 }
67 67
68 void BluetoothLocalGattServiceBlueZ::Unregister( 68 void BluetoothLocalGattServiceBlueZ::Unregister(
69 const base::Closure& callback, 69 const base::Closure& callback,
70 const ErrorCallback& error_callback) { 70 const ErrorCallback& error_callback) {
71 DCHECK(GetAdapter()); 71 DCHECK(GetAdapter());
72 GetAdapter()->UnregisterGattService(this, callback, error_callback); 72 GetAdapter()->UnregisterGattService(this, callback, error_callback);
73 } 73 }
74 74
75 const std::vector<std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ>>& 75 device::BluetoothLocalGattCharacteristic*
76 BluetoothLocalGattServiceBlueZ::GetCharacteristic(
77 const std::string& identifier) {
78 const auto& service = characteristics_.find(dbus::ObjectPath(identifier));
79 return service == characteristics_.end() ? nullptr : service->second.get();
80 };
81
82 const std::map<dbus::ObjectPath,
83 std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ>>&
76 BluetoothLocalGattServiceBlueZ::GetCharacteristics() const { 84 BluetoothLocalGattServiceBlueZ::GetCharacteristics() const {
77 return characteristics_; 85 return characteristics_;
78 } 86 }
79 87
80 // static 88 // static
81 dbus::ObjectPath BluetoothLocalGattServiceBlueZ::AddGuidToObjectPath( 89 dbus::ObjectPath BluetoothLocalGattServiceBlueZ::AddGuidToObjectPath(
82 const std::string& path) { 90 const std::string& path) {
83 std::string GuidString = base::GenerateGUID(); 91 std::string GuidString = base::GenerateGUID();
84 base::RemoveChars(GuidString, "-", &GuidString); 92 base::RemoveChars(GuidString, "-", &GuidString);
85 93
86 return dbus::ObjectPath(path + GuidString); 94 return dbus::ObjectPath(path + GuidString);
87 } 95 }
88 96
89 void BluetoothLocalGattServiceBlueZ::AddCharacteristic( 97 void BluetoothLocalGattServiceBlueZ::AddCharacteristic(
90 std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ> characteristic) { 98 std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ> characteristic) {
91 characteristics_.push_back(std::move(characteristic)); 99 characteristics_[characteristic->object_path()] = std::move(characteristic);
92 } 100 }
93 101
94 } // namespace bluez 102 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698