Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / device / bluetooth / bluetooth_l2cap_channel_mac.h
blobf843608d204f78e4464422c41b045e140314c387
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_L2CAP_CHANNEL_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_L2CAP_CHANNEL_MAC_H_
8 #import <IOBluetooth/IOBluetooth.h>
9 #import <IOKit/IOReturn.h>
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "device/bluetooth/bluetooth_channel_mac.h"
16 @class BluetoothL2capChannelDelegate;
18 namespace device {
20 class BluetoothL2capChannelMac : public BluetoothChannelMac {
21 public:
22 // Creates a new L2CAP channel wrapper with the given |socket| and native
23 // |channel|.
24 // NOTE: The |channel| is expected to already be retained.
25 BluetoothL2capChannelMac(BluetoothSocketMac* socket,
26 IOBluetoothL2CAPChannel* channel);
27 virtual ~BluetoothL2capChannelMac();
29 // Opens a new L2CAP channel with Channel ID |channel_id| to the target
30 // |device|. Returns the opened channel and sets |status| to kIOReturnSuccess
31 // if the open process was successfully started (or if an existing L2CAP
32 // channel was found). Otherwise, sets |status| to an error status.
33 static scoped_ptr<BluetoothL2capChannelMac> OpenAsync(
34 BluetoothSocketMac* socket,
35 IOBluetoothDevice* device,
36 BluetoothL2CAPPSM psm,
37 IOReturn* status);
39 // BluetoothChannelMac:
40 virtual void SetSocket(BluetoothSocketMac* socket) OVERRIDE;
41 virtual IOBluetoothDevice* GetDevice() OVERRIDE;
42 virtual uint16_t GetOutgoingMTU() OVERRIDE;
43 virtual IOReturn WriteAsync(void* data,
44 uint16_t length,
45 void* refcon) OVERRIDE;
47 void OnChannelOpenComplete(IOBluetoothL2CAPChannel* channel,
48 IOReturn status);
49 void OnChannelClosed(IOBluetoothL2CAPChannel* channel);
50 void OnChannelDataReceived(IOBluetoothL2CAPChannel* channel,
51 void* data,
52 size_t length);
53 void OnChannelWriteComplete(IOBluetoothL2CAPChannel* channel,
54 void* refcon,
55 IOReturn status);
57 private:
58 // The wrapped native L2CAP channel.
59 base::scoped_nsobject<IOBluetoothL2CAPChannel> channel_;
61 // The delegate for the native channel.
62 base::scoped_nsobject<BluetoothL2capChannelDelegate> delegate_;
64 DISALLOW_COPY_AND_ASSIGN(BluetoothL2capChannelMac);
67 } // namespace device
69 #endif // DEVICE_BLUETOOTH_BLUETOOTH_L2CAP_CHANNEL_MAC_H_