| 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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 // The ErrorCallback is used for methods that can fail in which case it | 73 // The ErrorCallback is used for methods that can fail in which case it |
| 74 // is called, in the success case the callback is simply not called. | 74 // is called, in the success case the callback is simply not called. |
| 75 typedef base::Callback<void()> ErrorCallback; | 75 typedef base::Callback<void()> ErrorCallback; |
| 76 | 76 |
| 77 // The BluetoothOutOfBandPairingDataCallback is used to return | 77 // The BluetoothOutOfBandPairingDataCallback is used to return |
| 78 // BluetoothOutOfBandPairingData to the caller. | 78 // BluetoothOutOfBandPairingData to the caller. |
| 79 typedef base::Callback<void(const BluetoothOutOfBandPairingData& data)> | 79 typedef base::Callback<void(const BluetoothOutOfBandPairingData& data)> |
| 80 BluetoothOutOfBandPairingDataCallback; | 80 BluetoothOutOfBandPairingDataCallback; |
| 81 | 81 |
| 82 typedef base::Callback<void(scoped_refptr<BluetoothAdapter> adapter)> | |
| 83 AdapterCallback; | |
| 84 | |
| 85 // Adds and removes observers for events on this bluetooth adapter, | 82 // Adds and removes observers for events on this bluetooth adapter, |
| 86 // if monitoring multiple adapters check the |adapter| parameter of | 83 // if monitoring multiple adapters check the |adapter| parameter of |
| 87 // observer methods to determine which adapter is issuing the event. | 84 // observer methods to determine which adapter is issuing the event. |
| 88 virtual void AddObserver(BluetoothAdapter::Observer* observer) = 0; | 85 virtual void AddObserver(BluetoothAdapter::Observer* observer) = 0; |
| 89 virtual void RemoveObserver( | 86 virtual void RemoveObserver( |
| 90 BluetoothAdapter::Observer* observer) = 0; | 87 BluetoothAdapter::Observer* observer) = 0; |
| 91 | 88 |
| 92 // The address of this adapter. The address format is "XX:XX:XX:XX:XX:XX", | 89 // The address of this adapter. The address format is "XX:XX:XX:XX:XX:XX", |
| 93 // where each XX is a hexadecimal number. | 90 // where each XX is a hexadecimal number. |
| 94 virtual const std::string& address() const; | 91 virtual const std::string& address() const; |
| 95 | 92 |
| 96 // The name of the adapter. | 93 // The name of the adapter. |
| 97 virtual const std::string& name() const; | 94 virtual const std::string& name() const; |
| 98 | 95 |
| 99 // Queue adapter callbacks to be run when the adapter is initialized. | |
| 100 virtual void QueueAdapterCallback(const AdapterCallback& callback); | |
| 101 | |
| 102 // Indicates whether the adapter is initialized and ready to use. | 96 // Indicates whether the adapter is initialized and ready to use. |
| 103 virtual bool IsInitialized() const = 0; | 97 virtual bool IsInitialized() const = 0; |
| 104 | 98 |
| 105 // Indicates whether the adapter is actually present on the system, for | 99 // Indicates whether the adapter is actually present on the system, for |
| 106 // the default adapter this indicates whether any adapter is present. An | 100 // the default adapter this indicates whether any adapter is present. An |
| 107 // adapter is only considered present if the address has been obtained. | 101 // adapter is only considered present if the address has been obtained. |
| 108 virtual bool IsPresent() const = 0; | 102 virtual bool IsPresent() const = 0; |
| 109 | 103 |
| 110 // Indicates whether the adapter radio is powered. | 104 // Indicates whether the adapter radio is powered. |
| 111 virtual bool IsPowered() const = 0; | 105 virtual bool IsPowered() const = 0; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 friend class base::RefCounted<BluetoothAdapter>; | 147 friend class base::RefCounted<BluetoothAdapter>; |
| 154 BluetoothAdapter(); | 148 BluetoothAdapter(); |
| 155 virtual ~BluetoothAdapter(); | 149 virtual ~BluetoothAdapter(); |
| 156 | 150 |
| 157 // Address of the adapter. | 151 // Address of the adapter. |
| 158 std::string address_; | 152 std::string address_; |
| 159 | 153 |
| 160 // Name of the adapter. | 154 // Name of the adapter. |
| 161 std::string name_; | 155 std::string name_; |
| 162 | 156 |
| 163 std::vector<AdapterCallback> adapter_callbacks_; | |
| 164 | |
| 165 // Devices paired with, connected to, discovered by, or visible to the | 157 // Devices paired with, connected to, discovered by, or visible to the |
| 166 // adapter. The key is the Bluetooth address of the device and the value | 158 // adapter. The key is the Bluetooth address of the device and the value |
| 167 // is the BluetoothDevice object whose lifetime is managed by the | 159 // is the BluetoothDevice object whose lifetime is managed by the |
| 168 // adapter instance. | 160 // adapter instance. |
| 169 typedef std::map<const std::string, BluetoothDevice*> DevicesMap; | 161 typedef std::map<const std::string, BluetoothDevice*> DevicesMap; |
| 170 DevicesMap devices_; | 162 DevicesMap devices_; |
| 171 }; | 163 }; |
| 172 | 164 |
| 173 } // namespace device | 165 } // namespace device |
| 174 | 166 |
| 175 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 167 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
| OLD | NEW |