| OLD | NEW |
| 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_PROFILE_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ |
| 7 | 7 |
| 8 #import <IOBluetooth/IOBluetooth.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/mac/scoped_nsobject.h" |
| 12 #include "base/sequenced_task_runner.h" | 15 #include "base/sequenced_task_runner.h" |
| 13 #include "device/bluetooth/bluetooth_profile.h" | 16 #include "device/bluetooth/bluetooth_profile.h" |
| 14 #include "device/bluetooth/bluetooth_socket.h" | 17 #include "device/bluetooth/bluetooth_socket.h" |
| 15 #include "device/bluetooth/bluetooth_uuid.h" | 18 #include "device/bluetooth/bluetooth_uuid.h" |
| 16 | 19 |
| 17 #ifdef __OBJC__ | 20 @class BluetoothProfileMacHelper; |
| 18 @class IOBluetoothDevice; | 21 @class IOBluetoothDevice; |
| 19 #else | 22 @class IOBluetoothRFCOMMChannel; |
| 20 class IOBluetoothDevice; | |
| 21 #endif | |
| 22 | 23 |
| 23 namespace device { | 24 namespace device { |
| 24 | 25 |
| 25 class BluetoothProfileMac : public BluetoothProfile { | 26 class BluetoothProfileMac : public BluetoothProfile { |
| 26 public: | 27 public: |
| 27 // BluetoothProfile override. | 28 // BluetoothProfile override. |
| 28 virtual void Unregister() OVERRIDE; | 29 virtual void Unregister() OVERRIDE; |
| 29 virtual void SetConnectionCallback( | 30 virtual void SetConnectionCallback( |
| 30 const ConnectionCallback& callback) OVERRIDE; | 31 const ConnectionCallback& callback) OVERRIDE; |
| 31 | 32 |
| 32 // Makes an outgoing connection to |device|, calling |callback| on succes or | 33 // Makes an outgoing connection to |device|, calling |success_callback| on |
| 33 // |error_callback| on error. If successful, this method also calls | 34 // success or |error_callback| on error. If successful, this method also calls |
| 34 // |connection_callback_| before calling |callback|. | 35 // |connection_callback_| before calling |success_callback|. |
| 35 void Connect(IOBluetoothDevice* device, | 36 void Connect(IOBluetoothDevice* device, |
| 36 const base::Closure& success_callback, | 37 const base::Closure& success_callback, |
| 37 const BluetoothSocket::ErrorCompletionCallback& error_callback); | 38 const BluetoothSocket::ErrorCompletionCallback& error_callback); |
| 38 | 39 |
| 40 // Callback that is invoked when the OS detects a new incoming RFCOMM channel |
| 41 // connection. |rfcomm_channel| is the newly opened channel. |
| 42 void OnRFCOMMChannelOpened(IOBluetoothRFCOMMChannel* rfcomm_channel); |
| 43 |
| 39 private: | 44 private: |
| 40 friend BluetoothProfile; | 45 friend BluetoothProfile* CreateBluetoothProfileMac(const BluetoothUUID& uuid, |
| 46 const Options& options); |
| 41 | 47 |
| 42 BluetoothProfileMac(const BluetoothUUID& uuid, const std::string& name); | 48 BluetoothProfileMac(const BluetoothUUID& uuid, const Options& options); |
| 43 virtual ~BluetoothProfileMac(); | 49 virtual ~BluetoothProfileMac(); |
| 44 | 50 |
| 45 const BluetoothUUID uuid_; | 51 const BluetoothUUID uuid_; |
| 46 const std::string name_; | 52 const uint16 rfcomm_channel_id_; |
| 47 ConnectionCallback connection_callback_; | 53 ConnectionCallback connection_callback_; |
| 54 |
| 55 // A simple helper that registers for OS notifications and forwards them to |
| 56 // |this| profile. |
| 57 base::scoped_nsobject<BluetoothProfileMacHelper> helper_; |
| 58 |
| 59 // A handle to the service record registered in the system SDP server. |
| 60 // Used to eventually unregister the service. |
| 61 const BluetoothSDPServiceRecordHandle service_record_handle_; |
| 48 }; | 62 }; |
| 49 | 63 |
| 50 } // namespace device | 64 } // namespace device |
| 51 | 65 |
| 52 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ | 66 #endif // DEVICE_BLUETOOTH_BLUETOOTH_PROFILE_MAC_H_ |
| OLD | NEW |