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

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

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Adding BluetoothAdapter::RetrievedConnectedPeripherals() and the implementation in BluetoothAdapter… Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_
7 7
8 #if defined(OS_IOS) 8 #if defined(OS_IOS)
9 #import <CoreBluetooth/CoreBluetooth.h> 9 #import <CoreBluetooth/CoreBluetooth.h>
10 #else 10 #else
11 #import <IOBluetooth/IOBluetooth.h> 11 #import <IOBluetooth/IOBluetooth.h>
12 #endif 12 #endif
13 13
14 #include "base/mac/scoped_nsobject.h" 14 #include "base/mac/scoped_nsobject.h"
15 #include "base/mac/sdk_forward_declarations.h" 15 #include "base/mac/sdk_forward_declarations.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "device/bluetooth/bluetooth_device.h" 18 #include "device/bluetooth/bluetooth_device.h"
19 19
20 namespace device { 20 namespace device {
21 21
22 // This class will scan for Bluetooth LE device on Mac. 22 // This class will scan for Bluetooth LE device on Mac.
23 class BluetoothLowEnergyDiscoveryManagerMac { 23 class BluetoothLowEnergyDiscoveryManagerMac {
24 public: 24 public:
25 // Interface for being notified of events during a device discovery session. 25 // Interface for being notified of events during a device discovery session.
26 class Observer { 26 class Observer {
27 public: 27 public:
28 // Called when |this| manager has found a device or an update on a device. 28 // Called when |this| manager has found a device or an update on a device.
29 // |advertisementData| can be nil if the peripheral is already connected.
29 virtual void LowEnergyDeviceUpdated(CBPeripheral* peripheral, 30 virtual void LowEnergyDeviceUpdated(CBPeripheral* peripheral,
30 NSDictionary* advertisementData, 31 NSDictionary* advertisementData,
31 int rssi) = 0; 32 int rssi) = 0;
32 33
33 protected: 34 protected:
34 virtual ~Observer() {} 35 virtual ~Observer() {}
35 }; 36 };
36 37
37 virtual ~BluetoothLowEnergyDiscoveryManagerMac(); 38 virtual ~BluetoothLowEnergyDiscoveryManagerMac();
38 39
39 // Returns true, if discovery is currently being performed. 40 // Returns true, if discovery is currently being performed.
40 virtual bool IsDiscovering() const; 41 virtual bool IsDiscovering() const;
41 42
42 // Initiates a discovery session. 43 // Initiates a discovery session.
43 // BluetoothLowEnergyDeviceMac objects discovered within a previous 44 // BluetoothLowEnergyDeviceMac objects discovered within a previous
44 // discovery session will be invalid. 45 // discovery session will be invalid.
45 virtual void StartDiscovery(BluetoothDevice::UUIDList services_uuids); 46 virtual void StartDiscovery(NSArray* services_uuids);
46 47
47 // Stops a discovery session. 48 // Stops a discovery session.
48 virtual void StopDiscovery(); 49 virtual void StopDiscovery();
49 50
50 // Returns a new BluetoothLowEnergyDiscoveryManagerMac. 51 // Returns a new BluetoothLowEnergyDiscoveryManagerMac.
51 static BluetoothLowEnergyDiscoveryManagerMac* Create(Observer* observer); 52 static BluetoothLowEnergyDiscoveryManagerMac* Create(Observer* observer);
52 53
53 virtual void SetCentralManager(CBCentralManager* central_manager); 54 virtual void SetCentralManager(CBCentralManager* central_manager);
54 55
55 protected: 56 protected:
(...skipping 22 matching lines...) Expand all
78 CBCentralManager* central_manager_ = nil; 79 CBCentralManager* central_manager_ = nil;
79 80
80 // Discovery has been initiated by calling the API StartDiscovery(). 81 // Discovery has been initiated by calling the API StartDiscovery().
81 bool discovering_; 82 bool discovering_;
82 83
83 // A discovery has been initiated but has not started yet because it's 84 // A discovery has been initiated but has not started yet because it's
84 // waiting for Bluetooth to turn on. 85 // waiting for Bluetooth to turn on.
85 bool pending_; 86 bool pending_;
86 87
87 // List of service UUIDs to scan. 88 // List of service UUIDs to scan.
88 BluetoothDevice::UUIDList services_uuids_; 89 base::scoped_nsobject<NSArray> services_uuids_;
89 90
90 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDiscoveryManagerMac); 91 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDiscoveryManagerMac);
91 }; 92 };
92 93
93 } // namespace device 94 } // namespace device
94 95
95 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_ 96 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698