| OLD | NEW |
| 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 EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVENT_R
OUTER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVENT_R
OUTER_H_ |
| 6 #define EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVENT_R
OUTER_H_ | 6 #define EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVENT_R
OUTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 class BluetoothLowEnergyConnection; | 42 class BluetoothLowEnergyConnection; |
| 43 class BluetoothLowEnergyNotifySession; | 43 class BluetoothLowEnergyNotifySession; |
| 44 class Extension; | 44 class Extension; |
| 45 | 45 |
| 46 // The BluetoothLowEnergyEventRouter is used by the bluetoothLowEnergy API to | 46 // The BluetoothLowEnergyEventRouter is used by the bluetoothLowEnergy API to |
| 47 // interface with the internal Bluetooth API in device/bluetooth. | 47 // interface with the internal Bluetooth API in device/bluetooth. |
| 48 class BluetoothLowEnergyEventRouter | 48 class BluetoothLowEnergyEventRouter |
| 49 : public device::BluetoothAdapter::Observer { | 49 : public device::BluetoothAdapter::Observer { |
| 50 public: | 50 public: |
| 51 explicit BluetoothLowEnergyEventRouter(content::BrowserContext* context); | 51 explicit BluetoothLowEnergyEventRouter(content::BrowserContext* context); |
| 52 virtual ~BluetoothLowEnergyEventRouter(); | 52 ~BluetoothLowEnergyEventRouter() override; |
| 53 | 53 |
| 54 // Possible ways that an API method can fail or succeed. | 54 // Possible ways that an API method can fail or succeed. |
| 55 enum Status { | 55 enum Status { |
| 56 kStatusSuccess = 0, | 56 kStatusSuccess = 0, |
| 57 kStatusErrorPermissionDenied, | 57 kStatusErrorPermissionDenied, |
| 58 kStatusErrorNotFound, | 58 kStatusErrorNotFound, |
| 59 kStatusErrorAlreadyConnected, | 59 kStatusErrorAlreadyConnected, |
| 60 kStatusErrorAlreadyNotifying, | 60 kStatusErrorAlreadyNotifying, |
| 61 kStatusErrorNotConnected, | 61 kStatusErrorNotConnected, |
| 62 kStatusErrorNotNotifying, | 62 kStatusErrorNotNotifying, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 void WriteDescriptorValue(const Extension* extension, | 227 void WriteDescriptorValue(const Extension* extension, |
| 228 const std::string& instance_id, | 228 const std::string& instance_id, |
| 229 const std::vector<uint8>& value, | 229 const std::vector<uint8>& value, |
| 230 const base::Closure& callback, | 230 const base::Closure& callback, |
| 231 const ErrorCallback& error_callback); | 231 const ErrorCallback& error_callback); |
| 232 | 232 |
| 233 // Initializes the adapter for testing. Used by unit tests only. | 233 // Initializes the adapter for testing. Used by unit tests only. |
| 234 void SetAdapterForTesting(device::BluetoothAdapter* adapter); | 234 void SetAdapterForTesting(device::BluetoothAdapter* adapter); |
| 235 | 235 |
| 236 // device::BluetoothAdapter::Observer overrides. | 236 // device::BluetoothAdapter::Observer overrides. |
| 237 virtual void GattServiceAdded(device::BluetoothAdapter* adapter, | 237 void GattServiceAdded(device::BluetoothAdapter* adapter, |
| 238 device::BluetoothDevice* device, | 238 device::BluetoothDevice* device, |
| 239 device::BluetoothGattService* service) override; | 239 device::BluetoothGattService* service) override; |
| 240 virtual void GattServiceRemoved( | 240 void GattServiceRemoved(device::BluetoothAdapter* adapter, |
| 241 device::BluetoothAdapter* adapter, | 241 device::BluetoothDevice* device, |
| 242 device::BluetoothDevice* device, | 242 device::BluetoothGattService* service) override; |
| 243 device::BluetoothGattService* service) override; | 243 void GattDiscoveryCompleteForService( |
| 244 virtual void GattDiscoveryCompleteForService( | |
| 245 device::BluetoothAdapter* adapter, | 244 device::BluetoothAdapter* adapter, |
| 246 device::BluetoothGattService* service) override; | 245 device::BluetoothGattService* service) override; |
| 247 virtual void GattServiceChanged( | 246 void GattServiceChanged(device::BluetoothAdapter* adapter, |
| 248 device::BluetoothAdapter* adapter, | 247 device::BluetoothGattService* service) override; |
| 249 device::BluetoothGattService* service) override; | 248 void GattCharacteristicAdded( |
| 250 virtual void GattCharacteristicAdded( | |
| 251 device::BluetoothAdapter* adapter, | 249 device::BluetoothAdapter* adapter, |
| 252 device::BluetoothGattCharacteristic* characteristic) override; | 250 device::BluetoothGattCharacteristic* characteristic) override; |
| 253 virtual void GattCharacteristicRemoved( | 251 void GattCharacteristicRemoved( |
| 254 device::BluetoothAdapter* adapter, | 252 device::BluetoothAdapter* adapter, |
| 255 device::BluetoothGattCharacteristic* characteristic) override; | 253 device::BluetoothGattCharacteristic* characteristic) override; |
| 256 virtual void GattDescriptorAdded( | 254 void GattDescriptorAdded( |
| 257 device::BluetoothAdapter* adapter, | 255 device::BluetoothAdapter* adapter, |
| 258 device::BluetoothGattDescriptor* descriptor) override; | 256 device::BluetoothGattDescriptor* descriptor) override; |
| 259 virtual void GattDescriptorRemoved( | 257 void GattDescriptorRemoved( |
| 260 device::BluetoothAdapter* adapter, | 258 device::BluetoothAdapter* adapter, |
| 261 device::BluetoothGattDescriptor* descriptor) override; | 259 device::BluetoothGattDescriptor* descriptor) override; |
| 262 virtual void GattCharacteristicValueChanged( | 260 void GattCharacteristicValueChanged( |
| 263 device::BluetoothAdapter* adapter, | 261 device::BluetoothAdapter* adapter, |
| 264 device::BluetoothGattCharacteristic* characteristic, | 262 device::BluetoothGattCharacteristic* characteristic, |
| 265 const std::vector<uint8>& value) override; | 263 const std::vector<uint8>& value) override; |
| 266 virtual void GattDescriptorValueChanged( | 264 void GattDescriptorValueChanged(device::BluetoothAdapter* adapter, |
| 267 device::BluetoothAdapter* adapter, | 265 device::BluetoothGattDescriptor* descriptor, |
| 268 device::BluetoothGattDescriptor* descriptor, | 266 const std::vector<uint8>& value) override; |
| 269 const std::vector<uint8>& value) override; | |
| 270 | 267 |
| 271 private: | 268 private: |
| 272 // Called by BluetoothAdapterFactory. | 269 // Called by BluetoothAdapterFactory. |
| 273 void OnGetAdapter(const base::Closure& callback, | 270 void OnGetAdapter(const base::Closure& callback, |
| 274 scoped_refptr<device::BluetoothAdapter> adapter); | 271 scoped_refptr<device::BluetoothAdapter> adapter); |
| 275 | 272 |
| 276 // Initializes the identifier for all existing GATT objects and devices. | 273 // Initializes the identifier for all existing GATT objects and devices. |
| 277 // Called by OnGetAdapter and SetAdapterForTesting. | 274 // Called by OnGetAdapter and SetAdapterForTesting. |
| 278 void InitializeIdentifierMappings(); | 275 void InitializeIdentifierMappings(); |
| 279 | 276 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 // Note: This should remain the last member so it'll be destroyed and | 415 // Note: This should remain the last member so it'll be destroyed and |
| 419 // invalidate its weak pointers before any other members are destroyed. | 416 // invalidate its weak pointers before any other members are destroyed. |
| 420 base::WeakPtrFactory<BluetoothLowEnergyEventRouter> weak_ptr_factory_; | 417 base::WeakPtrFactory<BluetoothLowEnergyEventRouter> weak_ptr_factory_; |
| 421 | 418 |
| 422 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyEventRouter); | 419 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyEventRouter); |
| 423 }; | 420 }; |
| 424 | 421 |
| 425 } // namespace extensions | 422 } // namespace extensions |
| 426 | 423 |
| 427 #endif // EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVEN
T_ROUTER_H_ | 424 #endif // EXTENSIONS_BROWSER_API_BLUETOOTH_LOW_ENERGY_BLUETOOTH_LOW_ENERGY_EVEN
T_ROUTER_H_ |
| OLD | NEW |