Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / device / bluetooth / bluetooth_adapter_mac.h
blob08c4fb5e7786cb5671782ed04555aa09316ce01e
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_
8 #include <IOKit/IOReturn.h>
10 #include <string>
11 #include <vector>
13 #include "base/containers/hash_tables.h"
14 #include "base/mac/scoped_nsobject.h"
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h"
18 #include "device/bluetooth/bluetooth_adapter.h"
19 #include "device/bluetooth/bluetooth_audio_sink.h"
20 #include "device/bluetooth/bluetooth_discovery_manager_mac.h"
21 #include "device/bluetooth/bluetooth_export.h"
23 @class IOBluetoothDevice;
24 @class NSArray;
25 @class NSDate;
27 namespace base {
29 class SequencedTaskRunner;
31 } // namespace base
33 namespace device {
35 class BluetoothAdapterMacTest;
37 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterMac
38 : public BluetoothAdapter,
39 public BluetoothDiscoveryManagerMac::Observer {
40 public:
41 static base::WeakPtr<BluetoothAdapter> CreateAdapter();
43 // BluetoothAdapter:
44 std::string GetAddress() const override;
45 std::string GetName() const override;
46 void SetName(const std::string& name,
47 const base::Closure& callback,
48 const ErrorCallback& error_callback) override;
49 bool IsInitialized() const override;
50 bool IsPresent() const override;
51 bool IsPowered() const override;
52 void SetPowered(bool powered,
53 const base::Closure& callback,
54 const ErrorCallback& error_callback) override;
55 bool IsDiscoverable() const override;
56 void SetDiscoverable(bool discoverable,
57 const base::Closure& callback,
58 const ErrorCallback& error_callback) override;
59 bool IsDiscovering() const override;
60 void CreateRfcommService(
61 const BluetoothUUID& uuid,
62 const ServiceOptions& options,
63 const CreateServiceCallback& callback,
64 const CreateServiceErrorCallback& error_callback) override;
65 void CreateL2capService(
66 const BluetoothUUID& uuid,
67 const ServiceOptions& options,
68 const CreateServiceCallback& callback,
69 const CreateServiceErrorCallback& error_callback) override;
70 void RegisterAudioSink(
71 const BluetoothAudioSink::Options& options,
72 const AcquiredCallback& callback,
73 const BluetoothAudioSink::ErrorCallback& error_callback) override;
74 void RegisterAdvertisement(
75 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data,
76 const CreateAdvertisementCallback& callback,
77 const CreateAdvertisementErrorCallback& error_callback) override;
79 // BluetoothDiscoveryManagerMac::Observer overrides
80 void DeviceFound(IOBluetoothDevice* device) override;
81 void DiscoveryStopped(bool unexpected) override;
83 // Registers that a new |device| has connected to the local host.
84 void DeviceConnected(IOBluetoothDevice* device);
86 protected:
87 // BluetoothAdapter:
88 void RemovePairingDelegateInternal(
89 device::BluetoothDevice::PairingDelegate* pairing_delegate) override;
91 private:
92 friend class BluetoothAdapterMacTest;
94 BluetoothAdapterMac();
95 ~BluetoothAdapterMac() override;
97 // BluetoothAdapter:
98 void AddDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
99 const base::Closure& callback,
100 const ErrorCallback& error_callback) override;
101 void RemoveDiscoverySession(BluetoothDiscoveryFilter* discovery_filter,
102 const base::Closure& callback,
103 const ErrorCallback& error_callback) override;
104 void SetDiscoveryFilter(scoped_ptr<BluetoothDiscoveryFilter> discovery_filter,
105 const base::Closure& callback,
106 const ErrorCallback& error_callback) override;
108 void Init();
109 void InitForTest(scoped_refptr<base::SequencedTaskRunner> ui_task_runner);
110 void PollAdapter();
112 // Registers that a new |device| has replied to an Inquiry, is paired, or has
113 // connected to the local host.
114 void DeviceAdded(IOBluetoothDevice* device);
116 // Updates |devices_| to include the currently paired devices, as well as any
117 // connected, but unpaired, devices. Notifies observers if any previously
118 // paired or connected devices are no longer present.
119 void UpdateDevices();
121 std::string address_;
122 std::string name_;
123 bool powered_;
125 int num_discovery_sessions_;
127 // Discovery manager for Bluetooth Classic.
128 scoped_ptr<BluetoothDiscoveryManagerMac> classic_discovery_manager_;
130 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
132 base::WeakPtrFactory<BluetoothAdapterMac> weak_ptr_factory_;
134 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterMac);
137 } // namespace device
139 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_