OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHANNEL_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_CHANNEL_MAC_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_CHANNEL_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_CHANNEL_MAC_H_ |
7 | 7 |
8 #import <IOKit/IOReturn.h> | 8 #import <IOKit/IOReturn.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 | 13 |
| 14 @class IOBluetoothDevice; |
| 15 |
14 namespace device { | 16 namespace device { |
15 | 17 |
16 class BluetoothSocketMac; | 18 class BluetoothSocketMac; |
17 | 19 |
18 // Wraps a native RFCOMM or L2CAP channel. | 20 // Wraps a native RFCOMM or L2CAP channel. |
19 class BluetoothChannelMac { | 21 class BluetoothChannelMac { |
20 public: | 22 public: |
21 BluetoothChannelMac(); | 23 BluetoothChannelMac(); |
22 virtual ~BluetoothChannelMac(); | 24 virtual ~BluetoothChannelMac(); |
23 | 25 |
24 // Sets the channel's owning socket to |socket|. Should only be called if the | 26 // Sets the channel's owning socket to |socket|. Should only be called if the |
25 // socket was previously unset. Note: This can synchronously call back into | 27 // socket was previously unset. Note: This can synchronously call back into |
26 // socket->OnChannelOpenComplete(). | 28 // socket->OnChannelOpenComplete(). |
27 virtual void SetSocket(BluetoothSocketMac* socket); | 29 virtual void SetSocket(BluetoothSocketMac* socket); |
28 | 30 |
29 // Returns the Bluetooth address for the device associated with |this| | 31 // Returns the Bluetooth address for the device associated with |this| |
30 // channel. | 32 // channel. |
31 virtual std::string GetDeviceAddress() = 0; | 33 std::string GetDeviceAddress(); |
| 34 |
| 35 // Returns the Bluetooth device associated with |this| channel. |
| 36 virtual IOBluetoothDevice* GetDevice() = 0; |
32 | 37 |
33 // Returns the outgoing MTU (maximum transmission unit) for the channel. | 38 // Returns the outgoing MTU (maximum transmission unit) for the channel. |
34 virtual uint16_t GetOutgoingMTU() = 0; | 39 virtual uint16_t GetOutgoingMTU() = 0; |
35 | 40 |
36 // Writes |data| of length |length| bytes into the channel. The |refcon| is a | 41 // Writes |data| of length |length| bytes into the channel. The |refcon| is a |
37 // user-supplied value that gets passed to the write callback. | 42 // user-supplied value that gets passed to the write callback. |
38 // Returns kIOReturnSuccess if the data was buffered successfully. | 43 // Returns kIOReturnSuccess if the data was buffered successfully. |
39 // If the return value is an error condition none of the data was sent. | 44 // If the return value is an error condition none of the data was sent. |
40 // The number of bytes to be sent must not exceed the channel MTU. | 45 // The number of bytes to be sent must not exceed the channel MTU. |
41 // | 46 // |
42 // Once the data has been successfully passed to the hardware to be | 47 // Once the data has been successfully passed to the hardware to be |
43 // transmitted, the socket's method OnChannelWriteComplete() will be called | 48 // transmitted, the socket's method OnChannelWriteComplete() will be called |
44 // with the |refcon| that was passed to this method. | 49 // with the |refcon| that was passed to this method. |
45 virtual IOReturn WriteAsync(void* data, uint16_t length, void* refcon) = 0; | 50 virtual IOReturn WriteAsync(void* data, uint16_t length, void* refcon) = 0; |
46 | 51 |
47 protected: | 52 protected: |
48 BluetoothSocketMac* socket() { return socket_; } | 53 BluetoothSocketMac* socket() { return socket_; } |
49 | 54 |
50 private: | 55 private: |
51 // The socket that owns |this|. | 56 // The socket that owns |this|. |
52 BluetoothSocketMac* socket_; | 57 BluetoothSocketMac* socket_; |
53 | 58 |
54 DISALLOW_COPY_AND_ASSIGN(BluetoothChannelMac); | 59 DISALLOW_COPY_AND_ASSIGN(BluetoothChannelMac); |
55 }; | 60 }; |
56 | 61 |
57 } // namespace device | 62 } // namespace device |
58 | 63 |
59 #endif // DEVICE_BLUETOOTH_BLUETOOTH_CHANNEL_MAC_H_ | 64 #endif // DEVICE_BLUETOOTH_BLUETOOTH_CHANNEL_MAC_H_ |
OLD | NEW |