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

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

Issue 1898643002: Refactor device::BluetoothGattXXX classes to split into remote/local. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_adapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_ADAPTER_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 11 matching lines...) Expand all
22 #include "device/bluetooth/bluetooth_advertisement.h" 22 #include "device/bluetooth/bluetooth_advertisement.h"
23 #include "device/bluetooth/bluetooth_audio_sink.h" 23 #include "device/bluetooth/bluetooth_audio_sink.h"
24 #include "device/bluetooth/bluetooth_device.h" 24 #include "device/bluetooth/bluetooth_device.h"
25 #include "device/bluetooth/bluetooth_export.h" 25 #include "device/bluetooth/bluetooth_export.h"
26 26
27 namespace device { 27 namespace device {
28 28
29 class BluetoothAdvertisement; 29 class BluetoothAdvertisement;
30 class BluetoothDiscoveryFilter; 30 class BluetoothDiscoveryFilter;
31 class BluetoothDiscoverySession; 31 class BluetoothDiscoverySession;
32 class BluetoothGattCharacteristic; 32 class BluetoothRemoteGattCharacteristic;
33 class BluetoothGattDescriptor; 33 class BluetoothRemoteGattDescriptor;
34 class BluetoothGattService; 34 class BluetoothRemoteGattService;
35 class BluetoothSocket; 35 class BluetoothSocket;
36 class BluetoothUUID; 36 class BluetoothUUID;
37 struct BluetoothAdapterDeleter; 37 struct BluetoothAdapterDeleter;
38 enum class UMABluetoothDiscoverySessionOutcome; 38 enum class UMABluetoothDiscoverySessionOutcome;
39 39
40 // BluetoothAdapter represents a local Bluetooth adapter which may be used to 40 // BluetoothAdapter represents a local Bluetooth adapter which may be used to
41 // interact with remote Bluetooth devices. As well as providing support for 41 // interact with remote Bluetooth devices. As well as providing support for
42 // determining whether an adapter is present and whether the radio is powered, 42 // determining whether an adapter is present and whether the radio is powered,
43 // this class also provides support for obtaining the list of remote devices 43 // this class also provides support for obtaining the list of remote devices
44 // known to the adapter, discovering new devices, and providing notification of 44 // known to the adapter, discovering new devices, and providing notification of
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 // Called when the device |device| is removed from the adapter |adapter|, 106 // Called when the device |device| is removed from the adapter |adapter|,
107 // either as a result of a discovered device being lost between discovering 107 // either as a result of a discovered device being lost between discovering
108 // phases or pairing information deleted. |device| should not be 108 // phases or pairing information deleted. |device| should not be
109 // cached. Instead, copy its Bluetooth address. 109 // cached. Instead, copy its Bluetooth address.
110 virtual void DeviceRemoved(BluetoothAdapter* adapter, 110 virtual void DeviceRemoved(BluetoothAdapter* adapter,
111 BluetoothDevice* device) {} 111 BluetoothDevice* device) {}
112 112
113 // Called when a new GATT service |service| is added to the device |device|, 113 // Called when a new GATT service |service| is added to the device |device|,
114 // as the service is received from the device. Don't cache |service|. Store 114 // as the service is received from the device. Don't cache |service|. Store
115 // its identifier instead (i.e. BluetoothGattService::GetIdentifier). 115 // its identifier instead (i.e. BluetoothRemoteGattService::GetIdentifier).
116 virtual void GattServiceAdded(BluetoothAdapter* adapter, 116 virtual void GattServiceAdded(BluetoothAdapter* adapter,
117 BluetoothDevice* device, 117 BluetoothDevice* device,
118 BluetoothGattService* service) {} 118 BluetoothRemoteGattService* service) {}
119 119
120 // Called when the GATT service |service| is removed from the device 120 // Called when the GATT service |service| is removed from the device
121 // |device|. This can happen if the attribute database of the remote device 121 // |device|. This can happen if the attribute database of the remote device
122 // changes or when |device| gets removed. 122 // changes or when |device| gets removed.
123 virtual void GattServiceRemoved(BluetoothAdapter* adapter, 123 virtual void GattServiceRemoved(BluetoothAdapter* adapter,
124 BluetoothDevice* device, 124 BluetoothDevice* device,
125 BluetoothGattService* service) {} 125 BluetoothRemoteGattService* service) {}
126 126
127 // Called when all the GATT Services in |device| have been discovered 127 // Called when all the GATT Services in |device| have been discovered
128 // and GattServiceAdded has been called for each service. 128 // and GattServiceAdded has been called for each service.
129 virtual void GattServicesDiscovered(BluetoothAdapter* adapter, 129 virtual void GattServicesDiscovered(BluetoothAdapter* adapter,
130 BluetoothDevice* device) {} 130 BluetoothDevice* device) {}
131 131
132 // Called when all characteristic and descriptor discovery procedures are 132 // Called when all characteristic and descriptor discovery procedures are
133 // known to be completed for the GATT service |service|. This method will be 133 // known to be completed for the GATT service |service|. This method will be
134 // called after the initial discovery of a GATT service and will usually be 134 // called after the initial discovery of a GATT service and will usually be
135 // preceded by calls to GattCharacteristicAdded and GattDescriptorAdded. 135 // preceded by calls to GattCharacteristicAdded and GattDescriptorAdded.
136 virtual void GattDiscoveryCompleteForService( 136 virtual void GattDiscoveryCompleteForService(
137 BluetoothAdapter* adapter, 137 BluetoothAdapter* adapter,
138 BluetoothGattService* service) {} 138 BluetoothRemoteGattService* service) {}
139 139
140 // Called when properties of the remote GATT service |service| have changed. 140 // Called when properties of the remote GATT service |service| have changed.
141 // This will get called for properties such as UUID, as well as for changes 141 // This will get called for properties such as UUID, as well as for changes
142 // to the list of known characteristics and included services. Observers 142 // to the list of known characteristics and included services. Observers
143 // should read all GATT characteristic and descriptors objects and do any 143 // should read all GATT characteristic and descriptors objects and do any
144 // necessary set up required for a changed service. 144 // necessary set up required for a changed service.
145 virtual void GattServiceChanged(BluetoothAdapter* adapter, 145 virtual void GattServiceChanged(BluetoothAdapter* adapter,
146 BluetoothGattService* service) {} 146 BluetoothRemoteGattService* service) {}
147 147
148 // Called when the remote GATT characteristic |characteristic| has been 148 // Called when the remote GATT characteristic |characteristic| has been
149 // discovered. Use this to issue any initial read/write requests to the 149 // discovered. Use this to issue any initial read/write requests to the
150 // characteristic but don't cache the pointer as it may become invalid. 150 // characteristic but don't cache the pointer as it may become invalid.
151 // Instead, use the specially assigned identifier to obtain a characteristic 151 // Instead, use the specially assigned identifier to obtain a characteristic
152 // and cache that identifier as necessary, as it can be used to retrieve the 152 // and cache that identifier as necessary, as it can be used to retrieve the
153 // characteristic from its GATT service. The number of characteristics with 153 // characteristic from its GATT service. The number of characteristics with
154 // the same UUID belonging to a service depends on the particular profile 154 // the same UUID belonging to a service depends on the particular profile
155 // the remote device implements, hence the client of a GATT based profile 155 // the remote device implements, hence the client of a GATT based profile
156 // will usually operate on the whole set of characteristics and not just 156 // will usually operate on the whole set of characteristics and not just
157 // one. 157 // one.
158 virtual void GattCharacteristicAdded( 158 virtual void GattCharacteristicAdded(
159 BluetoothAdapter* adapter, 159 BluetoothAdapter* adapter,
160 BluetoothGattCharacteristic* characteristic) {} 160 BluetoothRemoteGattCharacteristic* characteristic) {}
161 161
162 // Called when a GATT characteristic |characteristic| has been removed from 162 // Called when a GATT characteristic |characteristic| has been removed from
163 // the system. 163 // the system.
164 virtual void GattCharacteristicRemoved( 164 virtual void GattCharacteristicRemoved(
165 BluetoothAdapter* adapter, 165 BluetoothAdapter* adapter,
166 BluetoothGattCharacteristic* characteristic) {} 166 BluetoothRemoteGattCharacteristic* characteristic) {}
167 167
168 // Called when the remote GATT characteristic descriptor |descriptor| has 168 // Called when the remote GATT characteristic descriptor |descriptor| has
169 // been discovered. Don't cache the arguments as the pointers may become 169 // been discovered. Don't cache the arguments as the pointers may become
170 // invalid. Instead, use the specially assigned identifier to obtain a 170 // invalid. Instead, use the specially assigned identifier to obtain a
171 // descriptor and cache that identifier as necessary. 171 // descriptor and cache that identifier as necessary.
172 virtual void GattDescriptorAdded(BluetoothAdapter* adapter, 172 virtual void GattDescriptorAdded(
173 BluetoothGattDescriptor* descriptor) {} 173 BluetoothAdapter* adapter,
174 BluetoothRemoteGattDescriptor* descriptor) {}
174 175
175 // Called when a GATT characteristic descriptor |descriptor| has been 176 // Called when a GATT characteristic descriptor |descriptor| has been
176 // removed from the system. 177 // removed from the system.
177 virtual void GattDescriptorRemoved(BluetoothAdapter* adapter, 178 virtual void GattDescriptorRemoved(
178 BluetoothGattDescriptor* descriptor) {} 179 BluetoothAdapter* adapter,
180 BluetoothRemoteGattDescriptor* descriptor) {}
179 181
180 // Called when the value of a characteristic has changed. This might be a 182 // Called when the value of a characteristic has changed. This might be a
181 // result of a read/write request to, or a notification/indication from, a 183 // result of a read/write request to, or a notification/indication from, a
182 // remote GATT characteristic. 184 // remote GATT characteristic.
183 virtual void GattCharacteristicValueChanged( 185 virtual void GattCharacteristicValueChanged(
184 BluetoothAdapter* adapter, 186 BluetoothAdapter* adapter,
185 BluetoothGattCharacteristic* characteristic, 187 BluetoothRemoteGattCharacteristic* characteristic,
186 const std::vector<uint8_t>& value) {} 188 const std::vector<uint8_t>& value) {}
187 189
188 // Called when the value of a characteristic descriptor has been updated. 190 // Called when the value of a characteristic descriptor has been updated.
189 virtual void GattDescriptorValueChanged(BluetoothAdapter* adapter, 191 virtual void GattDescriptorValueChanged(
190 BluetoothGattDescriptor* descriptor, 192 BluetoothAdapter* adapter,
191 const std::vector<uint8_t>& value) { 193 BluetoothRemoteGattDescriptor* descriptor,
192 } 194 const std::vector<uint8_t>& value) {}
193 }; 195 };
194 196
195 // Used to configure a listening servie. 197 // Used to configure a listening servie.
196 struct DEVICE_BLUETOOTH_EXPORT ServiceOptions { 198 struct DEVICE_BLUETOOTH_EXPORT ServiceOptions {
197 ServiceOptions(); 199 ServiceOptions();
198 ~ServiceOptions(); 200 ~ServiceOptions();
199 201
200 std::unique_ptr<int> channel; 202 std::unique_ptr<int> channel;
201 std::unique_ptr<int> psm; 203 std::unique_ptr<int> psm;
202 std::unique_ptr<std::string> name; 204 std::unique_ptr<std::string> name;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 const CreateAdvertisementErrorCallback& error_callback) = 0; 419 const CreateAdvertisementErrorCallback& error_callback) = 0;
418 420
419 // The following methods are used to send various events to observers. 421 // The following methods are used to send various events to observers.
420 void NotifyAdapterStateChanged(bool powered); 422 void NotifyAdapterStateChanged(bool powered);
421 #if defined(OS_CHROMEOS) || defined(OS_LINUX) 423 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
422 // This function is implemented for ChromeOS only, and the support on 424 // This function is implemented for ChromeOS only, and the support on
423 // Android, MaxOS and Windows should be added on demand in the future. 425 // Android, MaxOS and Windows should be added on demand in the future.
424 void NotifyDevicePairedChanged(BluetoothDevice* device, 426 void NotifyDevicePairedChanged(BluetoothDevice* device,
425 bool new_paired_status); 427 bool new_paired_status);
426 #endif 428 #endif
427 void NotifyGattServiceAdded(BluetoothGattService* service); 429 void NotifyGattServiceAdded(BluetoothRemoteGattService* service);
428 void NotifyGattServiceRemoved(BluetoothGattService* service); 430 void NotifyGattServiceRemoved(BluetoothRemoteGattService* service);
429 void NotifyGattServiceChanged(BluetoothGattService* service); 431 void NotifyGattServiceChanged(BluetoothRemoteGattService* service);
430 void NotifyGattServicesDiscovered(BluetoothDevice* device); 432 void NotifyGattServicesDiscovered(BluetoothDevice* device);
431 void NotifyGattDiscoveryComplete(BluetoothGattService* service); 433 void NotifyGattDiscoveryComplete(BluetoothRemoteGattService* service);
432 void NotifyGattCharacteristicAdded( 434 void NotifyGattCharacteristicAdded(
433 BluetoothGattCharacteristic* characteristic); 435 BluetoothRemoteGattCharacteristic* characteristic);
434 void NotifyGattCharacteristicRemoved( 436 void NotifyGattCharacteristicRemoved(
435 BluetoothGattCharacteristic* characteristic); 437 BluetoothRemoteGattCharacteristic* characteristic);
436 void NotifyGattDescriptorAdded(BluetoothGattDescriptor* descriptor); 438 void NotifyGattDescriptorAdded(BluetoothRemoteGattDescriptor* descriptor);
437 void NotifyGattDescriptorRemoved(BluetoothGattDescriptor* descriptor); 439 void NotifyGattDescriptorRemoved(BluetoothRemoteGattDescriptor* descriptor);
438 void NotifyGattCharacteristicValueChanged( 440 void NotifyGattCharacteristicValueChanged(
439 BluetoothGattCharacteristic* characteristic, 441 BluetoothRemoteGattCharacteristic* characteristic,
440 const std::vector<uint8_t>& value); 442 const std::vector<uint8_t>& value);
441 void NotifyGattDescriptorValueChanged(BluetoothGattDescriptor* descriptor, 443 void NotifyGattDescriptorValueChanged(
442 const std::vector<uint8_t>& value); 444 BluetoothRemoteGattDescriptor* descriptor,
445 const std::vector<uint8_t>& value);
443 446
444 protected: 447 protected:
445 friend class base::RefCounted<BluetoothAdapter>; 448 friend class base::RefCounted<BluetoothAdapter>;
446 friend class BluetoothDiscoverySession; 449 friend class BluetoothDiscoverySession;
447 friend class BluetoothTestBase; 450 friend class BluetoothTestBase;
448 451
449 typedef base::ScopedPtrHashMap<std::string, std::unique_ptr<BluetoothDevice>> 452 typedef base::ScopedPtrHashMap<std::string, std::unique_ptr<BluetoothDevice>>
450 DevicesMap; 453 DevicesMap;
451 typedef std::pair<BluetoothDevice::PairingDelegate*, PairingDelegatePriority> 454 typedef std::pair<BluetoothDevice::PairingDelegate*, PairingDelegatePriority>
452 PairingDelegatePair; 455 PairingDelegatePair;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 std::set<BluetoothDiscoverySession*> discovery_sessions_; 575 std::set<BluetoothDiscoverySession*> discovery_sessions_;
573 576
574 // Note: This should remain the last member so it'll be destroyed and 577 // Note: This should remain the last member so it'll be destroyed and
575 // invalidate its weak pointers before any other members are destroyed. 578 // invalidate its weak pointers before any other members are destroyed.
576 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; 579 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_;
577 }; 580 };
578 581
579 } // namespace device 582 } // namespace device
580 583
581 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ 584 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698