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

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

Issue 1919683002: Adapter changes for implementing local GATT attributes and tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dbus_classes
Patch Set: 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 10 matching lines...) Expand all
21 BluetoothLocalGattService* included_service, 21 BluetoothLocalGattService* included_service,
22 BluetoothLocalGattService::Delegate* delegate) { 22 BluetoothLocalGattService::Delegate* delegate) {
23 bluez::BluetoothAdapterBlueZ* adapter_bluez = 23 bluez::BluetoothAdapterBlueZ* adapter_bluez =
24 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter); 24 static_cast<bluez::BluetoothAdapterBlueZ*>(adapter);
25 bluez::BluetoothLocalGattServiceBlueZ* service = 25 bluez::BluetoothLocalGattServiceBlueZ* service =
26 new bluez::BluetoothLocalGattServiceBlueZ(adapter_bluez, uuid, is_primary, 26 new bluez::BluetoothLocalGattServiceBlueZ(adapter_bluez, uuid, is_primary,
27 delegate); 27 delegate);
28 return service->weak_ptr_factory_.GetWeakPtr(); 28 return service->weak_ptr_factory_.GetWeakPtr();
29 } 29 }
30 30
31 } // device 31 } // namespace device
32 32
33 namespace bluez { 33 namespace bluez {
34 34
35 BluetoothLocalGattServiceBlueZ::BluetoothLocalGattServiceBlueZ( 35 BluetoothLocalGattServiceBlueZ::BluetoothLocalGattServiceBlueZ(
36 BluetoothAdapterBlueZ* adapter, 36 BluetoothAdapterBlueZ* adapter,
37 const device::BluetoothUUID& uuid, 37 const device::BluetoothUUID& uuid,
38 bool is_primary, 38 bool is_primary,
39 device::BluetoothLocalGattService::Delegate* delegate) 39 device::BluetoothLocalGattService::Delegate* delegate)
40 : BluetoothGattServiceBlueZ(adapter, AddGuidToObjectPath("/service")), 40 : BluetoothGattServiceBlueZ(
41 adapter,
42 AddGuidToObjectPath(adapter->GetApplicationObjectPath().value() +
43 "/service")),
41 uuid_(uuid), 44 uuid_(uuid),
42 is_primary_(is_primary), 45 is_primary_(is_primary),
43 delegate_(delegate), 46 delegate_(delegate),
44 weak_ptr_factory_(this) { 47 weak_ptr_factory_(this) {
45 // TODO(rkc): Get base application path from adapter and prefix it here.
46 VLOG(1) << "Creating local GATT service with identifier: " << GetIdentifier(); 48 VLOG(1) << "Creating local GATT service with identifier: " << GetIdentifier();
47 adapter->AddLocalGattService(base::WrapUnique(this)); 49 adapter->AddLocalGattService(base::WrapUnique(this));
48 } 50 }
49 51
50 BluetoothLocalGattServiceBlueZ::~BluetoothLocalGattServiceBlueZ() {} 52 BluetoothLocalGattServiceBlueZ::~BluetoothLocalGattServiceBlueZ() {}
51 53
52 device::BluetoothUUID BluetoothLocalGattServiceBlueZ::GetUUID() const { 54 device::BluetoothUUID BluetoothLocalGattServiceBlueZ::GetUUID() const {
53 return uuid_; 55 return uuid_;
54 } 56 }
55 57
56 bool BluetoothLocalGattServiceBlueZ::IsPrimary() const { 58 bool BluetoothLocalGattServiceBlueZ::IsPrimary() const {
57 return is_primary_; 59 return is_primary_;
58 } 60 }
59 61
60 void BluetoothLocalGattServiceBlueZ::Register( 62 void BluetoothLocalGattServiceBlueZ::Register(
61 const base::Closure& callback, 63 const base::Closure& callback,
62 const ErrorCallback& error_callback) { 64 const ErrorCallback& error_callback) {
63 // GetAdapter()->RegisterGattService(this, callback, error_callback); 65 GetAdapter()->RegisterGattService(this, callback, error_callback);
64 } 66 }
65 67
66 void BluetoothLocalGattServiceBlueZ::Unregister( 68 void BluetoothLocalGattServiceBlueZ::Unregister(
67 const base::Closure& callback, 69 const base::Closure& callback,
68 const ErrorCallback& error_callback) { 70 const ErrorCallback& error_callback) {
69 DCHECK(GetAdapter()); 71 DCHECK(GetAdapter());
70 // GetAdapter()->UnregisterGattService(this, callback, error_callback); 72 GetAdapter()->UnregisterGattService(this, callback, error_callback);
71 } 73 }
72 74
73 const std::vector<std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ>>& 75 const std::vector<std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ>>&
74 BluetoothLocalGattServiceBlueZ::GetCharacteristics() const { 76 BluetoothLocalGattServiceBlueZ::GetCharacteristics() const {
75 return characteristics_; 77 return characteristics_;
76 } 78 }
77 79
78 // static 80 // static
79 dbus::ObjectPath BluetoothLocalGattServiceBlueZ::AddGuidToObjectPath( 81 dbus::ObjectPath BluetoothLocalGattServiceBlueZ::AddGuidToObjectPath(
80 const std::string& path) { 82 const std::string& path) {
81 std::string GuidString = base::GenerateGUID(); 83 std::string GuidString = base::GenerateGUID();
82 base::RemoveChars(GuidString, "-", &GuidString); 84 base::RemoveChars(GuidString, "-", &GuidString);
83 85
84 return dbus::ObjectPath(path + GuidString); 86 return dbus::ObjectPath(path + GuidString);
85 } 87 }
86 88
87 void BluetoothLocalGattServiceBlueZ::AddCharacteristic( 89 void BluetoothLocalGattServiceBlueZ::AddCharacteristic(
88 std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ> characteristic) { 90 std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ> characteristic) {
89 characteristics_.push_back(std::move(characteristic)); 91 characteristics_.push_back(std::move(characteristic));
90 } 92 }
91 93
92 } // namespace bluez 94 } // namespace bluez
OLDNEW
« no previous file with comments | « device/bluetooth/bluez/bluetooth_adapter_bluez.cc ('k') | device/bluetooth/test/bluetooth_gatt_server_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698