OLD | NEW |
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 <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "device/bluetooth/bluetooth_device.h" | 17 #include "device/bluetooth/bluetooth_device.h" |
18 #include "device/bluetooth/bluetooth_export.h" | |
19 | 18 |
20 namespace device { | 19 namespace device { |
21 | 20 |
22 class BluetoothDiscoverySession; | 21 class BluetoothDiscoverySession; |
23 class BluetoothGattCharacteristic; | 22 class BluetoothGattCharacteristic; |
24 class BluetoothGattDescriptor; | 23 class BluetoothGattDescriptor; |
25 class BluetoothGattService; | 24 class BluetoothGattService; |
26 class BluetoothSocket; | 25 class BluetoothSocket; |
27 class BluetoothUUID; | 26 class BluetoothUUID; |
28 | 27 |
29 // BluetoothAdapter represents a local Bluetooth adapter which may be used to | 28 // BluetoothAdapter represents a local Bluetooth adapter which may be used to |
30 // interact with remote Bluetooth devices. As well as providing support for | 29 // interact with remote Bluetooth devices. As well as providing support for |
31 // determining whether an adapter is present and whether the radio is powered, | 30 // determining whether an adapter is present and whether the radio is powered, |
32 // this class also provides support for obtaining the list of remote devices | 31 // this class also provides support for obtaining the list of remote devices |
33 // known to the adapter, discovering new devices, and providing notification of | 32 // known to the adapter, discovering new devices, and providing notification of |
34 // updates to device information. | 33 // updates to device information. |
35 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapter | 34 class BluetoothAdapter : public base::RefCounted<BluetoothAdapter> { |
36 : public base::RefCounted<BluetoothAdapter> { | |
37 public: | 35 public: |
38 // Interface for observing changes from bluetooth adapters. | 36 // Interface for observing changes from bluetooth adapters. |
39 class Observer { | 37 class Observer { |
40 public: | 38 public: |
41 virtual ~Observer() {} | 39 virtual ~Observer() {} |
42 | 40 |
43 // Called when the presence of the adapter |adapter| changes. When |present| | 41 // Called when the presence of the adapter |adapter| changes. When |present| |
44 // is true the adapter is now present, false means the adapter has been | 42 // is true the adapter is now present, false means the adapter has been |
45 // removed from the system. | 43 // removed from the system. |
46 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, | 44 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 BluetoothGattCharacteristic* characteristic, | 151 BluetoothGattCharacteristic* characteristic, |
154 const std::vector<uint8>& value) {} | 152 const std::vector<uint8>& value) {} |
155 | 153 |
156 // Called when the value of a characteristic descriptor has been updated. | 154 // Called when the value of a characteristic descriptor has been updated. |
157 virtual void GattDescriptorValueChanged(BluetoothAdapter* adapter, | 155 virtual void GattDescriptorValueChanged(BluetoothAdapter* adapter, |
158 BluetoothGattDescriptor* descriptor, | 156 BluetoothGattDescriptor* descriptor, |
159 const std::vector<uint8>& value) {} | 157 const std::vector<uint8>& value) {} |
160 }; | 158 }; |
161 | 159 |
162 // Used to configure a listening servie. | 160 // Used to configure a listening servie. |
163 struct DEVICE_BLUETOOTH_EXPORT ServiceOptions { | 161 struct ServiceOptions { |
164 ServiceOptions(); | 162 ServiceOptions(); |
165 ~ServiceOptions(); | 163 ~ServiceOptions(); |
166 | 164 |
167 scoped_ptr<int> channel; | 165 scoped_ptr<int> channel; |
168 scoped_ptr<int> psm; | 166 scoped_ptr<int> psm; |
169 scoped_ptr<std::string> name; | 167 scoped_ptr<std::string> name; |
170 }; | 168 }; |
171 | 169 |
172 // The ErrorCallback is used for methods that can fail in which case it is | 170 // The ErrorCallback is used for methods that can fail in which case it is |
173 // called, in the success case the callback is simply not called. | 171 // called, in the success case the callback is simply not called. |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 std::set<BluetoothDiscoverySession*> discovery_sessions_; | 414 std::set<BluetoothDiscoverySession*> discovery_sessions_; |
417 | 415 |
418 // Note: This should remain the last member so it'll be destroyed and | 416 // Note: This should remain the last member so it'll be destroyed and |
419 // invalidate its weak pointers before any other members are destroyed. | 417 // invalidate its weak pointers before any other members are destroyed. |
420 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; | 418 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; |
421 }; | 419 }; |
422 | 420 |
423 } // namespace device | 421 } // namespace device |
424 | 422 |
425 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 423 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
OLD | NEW |