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

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

Issue 791763005: Added bluetooth LE support on Mac platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_
7
8 #if defined(OS_IOS)
9 #import <CoreBluetooth/CoreBluetooth.h>
10 #else
11 #import <IOBluetooth/IOBluetooth.h>
12 #endif
13
14 #include "base/mac/scoped_nsobject.h"
15 #include "device/bluetooth/bluetooth_device.h"
16
17 @class BluetoothLowEnergyDiscoveryManagerMacBridge;
18
19 namespace device {
20
21 class BluetoothLowEnergyDeviceMac;
22 class BluetoothLowEnergyDiscoveryManagerMacDelegate;
23
24 // This class will scan for Bluetooth LE device on Mac.
25 class BluetoothLowEnergyDiscoveryManagerMac {
26 public:
27 // Interface for being notified of events during a device discovery session.
28 class Observer {
29 public:
30 virtual ~Observer() {}
31
Avi (use Gerrit) 2015/01/31 02:22:38 same here
dvh 2015/02/05 22:26:08 Done.
32 // Called when |this| manager has found a device.
33 virtual void DeviceFound(BluetoothLowEnergyDeviceMac* device) = 0;
34
35 // Called when |this| manager has updated on a device.
36 virtual void DeviceUpdated(BluetoothLowEnergyDeviceMac* device) = 0;
37 };
38
39 virtual ~BluetoothLowEnergyDiscoveryManagerMac();
40
41 // Returns true, if discovery is currently being performed.
42 virtual bool IsDiscovering() const;
43
44 // Initiates a discovery session.
45 // BluetoothLowEnergyDeviceMac objects discovered within a previous
46 // discovery session will be invalid.
47 virtual void StartDiscovery(BluetoothDevice::UUIDList services_uuids);
48
49 // Stops a discovery session.
50 virtual void StopDiscovery();
51
52 // Returns a new BluetoothLowEnergyDiscoveryManagerMac.
53 static BluetoothLowEnergyDiscoveryManagerMac* Create(Observer* observer);
54
55 protected:
56 // Called when a discovery or an update of a BLE device occurred.
57 virtual void DiscoveredPeripheral(CBPeripheral* peripheral,
58 NSDictionary* advertisementData,
59 int rssi);
60
61 // The device discovery can really be started when Bluetooth is powered on.
62 // The method TryStartDiscovery() is called when it's a good time to try to
63 // start the BLE device discovery. It will check if the discovery session has
64 // been started and if the Bluetooth is powered and then really start the
65 // CoreBluetooth BLE device discovery.
66 virtual void TryStartDiscovery();
67
68 private:
69 explicit BluetoothLowEnergyDiscoveryManagerMac(Observer* observer);
70 void ClearDevices();
71
72 friend class BluetoothLowEnergyDiscoveryManagerMacDelegate;
73
74 // Observer interested in notifications from us.
75 Observer* observer_;
76
77 // Underlaying CoreBluetooth central manager.
78 base::scoped_nsobject<CBCentralManager> manager_;
79
80 // Discovery has been initiated by calling the API StartDiscovery().
81 bool discovering_;
82
83 // A discovery has been initiated but has not started yet because it's
84 // waiting for Bluetooth to turn on.
85 bool pending_;
86
87 // Delegate of the central manager.
88 base::scoped_nsobject<BluetoothLowEnergyDiscoveryManagerMacBridge> bridge_;
89
90 // Map of the device identifiers to the discovered device.
91 std::map<const std::string, BluetoothLowEnergyDeviceMac*> devices_;
92
93 // List of service UUIDs to scan.
94 BluetoothDevice::UUIDList services_uuids_;
95
96 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDiscoveryManagerMac);
97 };
98
99 } // namespace device
100
101 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DISCOVERY_MANAGER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698