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

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

Issue 1538173003: Implementing GATT connection/disconnect on OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sorting methods between bluetooth_adapter_mac.h and bluetooth_adapter_mac.mm Created 4 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_MAC_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_
7 7
8 #include <IOKit/IOReturn.h> 8 #include <IOKit/IOReturn.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 // Registers that a new |device| has connected to the local host. 91 // Registers that a new |device| has connected to the local host.
92 void DeviceConnected(IOBluetoothDevice* device); 92 void DeviceConnected(IOBluetoothDevice* device);
93 93
94 // We only use CoreBluetooth when OS X >= 10.10. This because the 94 // We only use CoreBluetooth when OS X >= 10.10. This because the
95 // CBCentralManager destructor was found to crash on the mac_chromium_rel_ng 95 // CBCentralManager destructor was found to crash on the mac_chromium_rel_ng
96 // builder running 10.9.5. May also cause blued to crash on OS X 10.9.5 96 // builder running 10.9.5. May also cause blued to crash on OS X 10.9.5
97 // (crbug.com/506287). 97 // (crbug.com/506287).
98 static bool IsLowEnergyAvailable(); 98 static bool IsLowEnergyAvailable();
99 99
100 // Resets |low_energy_central_manager_| to |central_manager| and sets 100 // Creates a GATT connection by calling CoreBluetooth APIs.
101 // |low_energy_central_manager_delegate_| as the manager's delegate. Should 101 void CreateGattConnection(BluetoothLowEnergyDeviceMac* device_mac);
102 // be called only when |IsLowEnergyAvailable()|. 102
103 void SetCentralManagerForTesting(CBCentralManager* central_manager); 103 // Close the GATT connection by calling CoreBluetooth APIs.
scheib 2016/02/10 18:59:45 Closes https://google.github.io/styleguide/cppguid
jlebel 2016/02/10 21:20:07 Done.
104 void DisconnectGatt(BluetoothLowEnergyDeviceMac* device_mac);
105
106 // Methods called from CBCentralManager delegate.
107 void DidConnectPeripheral(CBPeripheral* peripheral);
108 void DidFailToConnectPeripheral(CBPeripheral* peripheral, NSError* error);
109 void DidDisconnectPeripheral(CBPeripheral* peripheral, NSError* error);
104 110
105 protected: 111 protected:
106 // BluetoothAdapter override: 112 // BluetoothAdapter override:
107 void RemovePairingDelegateInternal( 113 void RemovePairingDelegateInternal(
108 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; 114 device::BluetoothDevice::PairingDelegate* pairing_delegate) override;
109 115
116 // Resets |low_energy_central_manager_| to |central_manager| and sets
117 // |low_energy_central_manager_delegate_| as the manager's delegate. Should
118 // be called only when |IsLowEnergyAvailable()|.
119 void SetCentralManagerForTesting(CBCentralManager* central_manager);
120 CBCentralManager* GetCentralManagerForTesting();
121
110 private: 122 private:
111 // The length of time that must elapse since the last Inquiry response (on 123 // The length of time that must elapse since the last Inquiry response (on
112 // Classic devices) or call to BluetoothLowEnergyDevice::Update() (on Low 124 // Classic devices) or call to BluetoothLowEnergyDevice::Update() (on Low
113 // Energy) before a discovered device is considered to be no longer available. 125 // Energy) before a discovered device is considered to be no longer available.
114 const static NSTimeInterval kDiscoveryTimeoutSec; 126 const static NSTimeInterval kDiscoveryTimeoutSec;
115 127
116 friend class BluetoothTestMac; 128 friend class BluetoothTestMac;
117 friend class BluetoothAdapterMacTest; 129 friend class BluetoothAdapterMacTest;
118 friend class BluetoothLowEnergyCentralManagerBridge; 130 friend class BluetoothLowEnergyCentralManagerBridge;
119 131
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 194 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
183 195
184 base::WeakPtrFactory<BluetoothAdapterMac> weak_ptr_factory_; 196 base::WeakPtrFactory<BluetoothAdapterMac> weak_ptr_factory_;
185 197
186 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterMac); 198 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterMac);
187 }; 199 };
188 200
189 } // namespace device 201 } // namespace device
190 202
191 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_ 203 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698