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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_service_bluez.h

Issue 1415573014: Reland "Add Linux support for the Bluetooth API" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix. Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h" 15 #include "base/observer_list.h"
15 #include "dbus/object_path.h" 16 #include "dbus/object_path.h"
16 #include "device/bluetooth/bluetooth_gatt_service.h" 17 #include "device/bluetooth/bluetooth_gatt_service.h"
17 #include "device/bluetooth/bluetooth_uuid.h" 18 #include "device/bluetooth/bluetooth_uuid.h"
18 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" 19 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h"
19 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" 20 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h"
20 21
21 namespace device { 22 namespace device {
22 23
23 class BluetoothAdapter; 24 class BluetoothAdapter;
24 class BluetoothGattCharacteristic; 25 class BluetoothGattCharacteristic;
25 26
26 } // namespace device 27 } // namespace device
27 28
28 namespace chromeos { 29 namespace bluez {
29 30
30 class BluetoothAdapterChromeOS; 31 class BluetoothAdapterBlueZ;
31 class BluetoothDeviceChromeOS; 32 class BluetoothDeviceBlueZ;
32 class BluetoothRemoteGattCharacteristicChromeOS; 33 class BluetoothRemoteGattCharacteristicBlueZ;
33 class BluetoothRemoteGattDescriptorChromeOS; 34 class BluetoothRemoteGattDescriptorBlueZ;
34 35
35 // The BluetoothRemoteGattServiceChromeOS class implements BluetootGattService 36 // The BluetoothRemoteGattServiceBlueZ class implements BluetootGattService
36 // for remote GATT services on the Chrome OS platform. 37 // for remote GATT services on the Chrome OS platform.
ortuno 2015/11/06 18:15:41 Leftover "Chrome OS" reference.
rkc 2015/11/25 00:48:16 Done.
37 class BluetoothRemoteGattServiceChromeOS 38 class BluetoothRemoteGattServiceBlueZ
38 : public device::BluetoothGattService, 39 : public device::BluetoothGattService,
39 public bluez::BluetoothGattServiceClient::Observer, 40 public bluez::BluetoothGattServiceClient::Observer,
40 public bluez::BluetoothGattCharacteristicClient::Observer { 41 public bluez::BluetoothGattCharacteristicClient::Observer {
41 public: 42 public:
42 // device::BluetoothGattService overrides. 43 // device::BluetoothGattService overrides.
43 std::string GetIdentifier() const override; 44 std::string GetIdentifier() const override;
44 device::BluetoothUUID GetUUID() const override; 45 device::BluetoothUUID GetUUID() const override;
45 bool IsLocal() const override; 46 bool IsLocal() const override;
46 bool IsPrimary() const override; 47 bool IsPrimary() const override;
47 device::BluetoothDevice* GetDevice() const override; 48 device::BluetoothDevice* GetDevice() const override;
(...skipping 12 matching lines...) Expand all
60 const ErrorCallback& error_callback) override; 61 const ErrorCallback& error_callback) override;
61 62
62 // Object path of the underlying service. 63 // Object path of the underlying service.
63 const dbus::ObjectPath& object_path() const { return object_path_; } 64 const dbus::ObjectPath& object_path() const { return object_path_; }
64 65
65 // Parses a named D-Bus error into a service error code. 66 // Parses a named D-Bus error into a service error code.
66 static device::BluetoothGattService::GattErrorCode DBusErrorToServiceError( 67 static device::BluetoothGattService::GattErrorCode DBusErrorToServiceError(
67 const std::string error_name); 68 const std::string error_name);
68 69
69 // Returns the adapter associated with this service. 70 // Returns the adapter associated with this service.
70 BluetoothAdapterChromeOS* GetAdapter() const; 71 BluetoothAdapterBlueZ* GetAdapter() const;
71 72
72 // Notifies its observers that the GATT service has changed. This is mainly 73 // Notifies its observers that the GATT service has changed. This is mainly
73 // used by BluetoothRemoteGattCharacteristicChromeOS instances to notify 74 // used by BluetoothRemoteGattCharacteristicBlueZ instances to notify
74 // service observers when characteristic descriptors get added and removed. 75 // service observers when characteristic descriptors get added and removed.
75 void NotifyServiceChanged(); 76 void NotifyServiceChanged();
76 77
77 // Notifies its observers that a descriptor |descriptor| belonging to 78 // Notifies its observers that a descriptor |descriptor| belonging to
78 // characteristic |characteristic| has been added or removed. This is used 79 // characteristic |characteristic| has been added or removed. This is used
79 // by BluetoothRemoteGattCharacteristicChromeOS instances to notify service 80 // by BluetoothRemoteGattCharacteristicBlueZ instances to notify service
80 // observers when characteristic descriptors get added and removed. If |added| 81 // observers when characteristic descriptors get added and removed. If |added|
81 // is true, an "Added" event will be sent. Otherwise, a "Removed" event will 82 // is true, an "Added" event will be sent. Otherwise, a "Removed" event will
82 // be sent. 83 // be sent.
83 void NotifyDescriptorAddedOrRemoved( 84 void NotifyDescriptorAddedOrRemoved(
84 BluetoothRemoteGattCharacteristicChromeOS* characteristic, 85 BluetoothRemoteGattCharacteristicBlueZ* characteristic,
85 BluetoothRemoteGattDescriptorChromeOS* descriptor, 86 BluetoothRemoteGattDescriptorBlueZ* descriptor,
86 bool added); 87 bool added);
87 88
88 // Notifies its observers that the value of a descriptor has changed. Called 89 // Notifies its observers that the value of a descriptor has changed. Called
89 // by BluetoothRemoteGattCharacteristicChromeOS instances to notify service 90 // by BluetoothRemoteGattCharacteristicBlueZ instances to notify service
90 // observers. 91 // observers.
91 void NotifyDescriptorValueChanged( 92 void NotifyDescriptorValueChanged(
92 BluetoothRemoteGattCharacteristicChromeOS* characteristic, 93 BluetoothRemoteGattCharacteristicBlueZ* characteristic,
93 BluetoothRemoteGattDescriptorChromeOS* descriptor, 94 BluetoothRemoteGattDescriptorBlueZ* descriptor,
94 const std::vector<uint8>& value); 95 const std::vector<uint8>& value);
95 96
96 private: 97 private:
97 friend class BluetoothDeviceChromeOS; 98 friend class BluetoothDeviceBlueZ;
98 99
99 typedef std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicChromeOS*> 100 typedef std::map<dbus::ObjectPath, BluetoothRemoteGattCharacteristicBlueZ*>
100 CharacteristicMap; 101 CharacteristicMap;
101 102
102 BluetoothRemoteGattServiceChromeOS(BluetoothAdapterChromeOS* adapter, 103 BluetoothRemoteGattServiceBlueZ(BluetoothAdapterBlueZ* adapter,
103 BluetoothDeviceChromeOS* device, 104 BluetoothDeviceBlueZ* device,
104 const dbus::ObjectPath& object_path); 105 const dbus::ObjectPath& object_path);
105 ~BluetoothRemoteGattServiceChromeOS() override; 106 ~BluetoothRemoteGattServiceBlueZ() override;
106 107
107 // bluez::BluetoothGattServiceClient::Observer override. 108 // bluez::BluetoothGattServiceClient::Observer override.
108 void GattServicePropertyChanged(const dbus::ObjectPath& object_path, 109 void GattServicePropertyChanged(const dbus::ObjectPath& object_path,
109 const std::string& property_name) override; 110 const std::string& property_name) override;
110 111
111 // bluez::BluetoothGattCharacteristicClient::Observer override. 112 // bluez::BluetoothGattCharacteristicClient::Observer override.
112 void GattCharacteristicAdded(const dbus::ObjectPath& object_path) override; 113 void GattCharacteristicAdded(const dbus::ObjectPath& object_path) override;
113 void GattCharacteristicRemoved(const dbus::ObjectPath& object_path) override; 114 void GattCharacteristicRemoved(const dbus::ObjectPath& object_path) override;
114 void GattCharacteristicPropertyChanged( 115 void GattCharacteristicPropertyChanged(
115 const dbus::ObjectPath& object_path, 116 const dbus::ObjectPath& object_path,
116 const std::string& property_name) override; 117 const std::string& property_name) override;
117 118
118 // Object path of the GATT service. 119 // Object path of the GATT service.
119 dbus::ObjectPath object_path_; 120 dbus::ObjectPath object_path_;
120 121
121 // The adapter associated with this service. It's ok to store a raw pointer 122 // The adapter associated with this service. It's ok to store a raw pointer
122 // here since |adapter_| indirectly owns this instance. 123 // here since |adapter_| indirectly owns this instance.
123 BluetoothAdapterChromeOS* adapter_; 124 BluetoothAdapterBlueZ* adapter_;
124 125
125 // The device this GATT service belongs to. It's ok to store a raw pointer 126 // The device this GATT service belongs to. It's ok to store a raw pointer
126 // here since |device_| owns this instance. 127 // here since |device_| owns this instance.
127 BluetoothDeviceChromeOS* device_; 128 BluetoothDeviceBlueZ* device_;
128 129
129 // Mapping from GATT characteristic object paths to characteristic objects. 130 // Mapping from GATT characteristic object paths to characteristic objects.
130 // owned by this service. Since the Chrome OS implementation uses object 131 // owned by this service. Since the Chrome OS implementation uses object
ortuno 2015/11/06 18:15:41 Leftover "Chrome OS" reference.
rkc 2015/11/25 00:48:16 Done.
131 // paths as unique identifiers, we also use this mapping to return 132 // paths as unique identifiers, we also use this mapping to return
132 // characteristics by identifier. 133 // characteristics by identifier.
133 CharacteristicMap characteristics_; 134 CharacteristicMap characteristics_;
134 135
135 // Indicates whether or not the characteristics of this service are known to 136 // Indicates whether or not the characteristics of this service are known to
136 // have been discovered. 137 // have been discovered.
137 bool discovery_complete_; 138 bool discovery_complete_;
138 139
139 // Note: This should remain the last member so it'll be destroyed and 140 // Note: This should remain the last member so it'll be destroyed and
140 // invalidate its weak pointers before any other members are destroyed. 141 // invalidate its weak pointers before any other members are destroyed.
141 base::WeakPtrFactory<BluetoothRemoteGattServiceChromeOS> weak_ptr_factory_; 142 base::WeakPtrFactory<BluetoothRemoteGattServiceBlueZ> weak_ptr_factory_;
142 143
143 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceChromeOS); 144 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattServiceBlueZ);
144 }; 145 };
145 146
146 } // namespace chromeos 147 } // namespace bluez
147 148
148 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_CHROMEOS_H_ 149 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_SERVICE_BLUEZ_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698