| 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 #include "device/bluetooth/bluetooth_l2cap_channel_mac.h" | 5 #include "device/bluetooth/bluetooth_l2cap_channel_mac.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/sdk_forward_declarations.h" | 8 #include "base/mac/sdk_forward_declarations.h" |
| 9 #include "device/bluetooth/bluetooth_device_mac.h" | 9 #include "device/bluetooth/bluetooth_classic_device_mac.h" |
| 10 #include "device/bluetooth/bluetooth_socket_mac.h" | 10 #include "device/bluetooth/bluetooth_socket_mac.h" |
| 11 | 11 |
| 12 // A simple delegate class for an open L2CAP channel that forwards methods to | 12 // A simple delegate class for an open L2CAP channel that forwards methods to |
| 13 // its wrapped |channel_|. | 13 // its wrapped |channel_|. |
| 14 @interface BluetoothL2capChannelDelegate | 14 @interface BluetoothL2capChannelDelegate |
| 15 : NSObject <IOBluetoothL2CAPChannelDelegate> { | 15 : NSObject <IOBluetoothL2CAPChannelDelegate> { |
| 16 @private | 16 @private |
| 17 device::BluetoothL2capChannelMac* channel_; // weak | 17 device::BluetoothL2capChannelMac* channel_; // weak |
| 18 } | 18 } |
| 19 | 19 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 IOReturn status) { | 135 IOReturn status) { |
| 136 if (channel_) { | 136 if (channel_) { |
| 137 DCHECK_EQ(channel_, channel); | 137 DCHECK_EQ(channel_, channel); |
| 138 } else { | 138 } else { |
| 139 // The (potentially) asynchronous connection occurred synchronously. | 139 // The (potentially) asynchronous connection occurred synchronously. |
| 140 // Should only be reachable from OpenAsync(). | 140 // Should only be reachable from OpenAsync(). |
| 141 DCHECK_EQ(status, kIOReturnSuccess); | 141 DCHECK_EQ(status, kIOReturnSuccess); |
| 142 } | 142 } |
| 143 | 143 |
| 144 socket()->OnChannelOpenComplete( | 144 socket()->OnChannelOpenComplete( |
| 145 BluetoothDeviceMac::GetDeviceAddress([channel getDevice]), status); | 145 BluetoothClassicDeviceMac::GetDeviceAddress([channel getDevice]), status); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void BluetoothL2capChannelMac::OnChannelClosed( | 148 void BluetoothL2capChannelMac::OnChannelClosed( |
| 149 IOBluetoothL2CAPChannel* channel) { | 149 IOBluetoothL2CAPChannel* channel) { |
| 150 DCHECK_EQ(channel_, channel); | 150 DCHECK_EQ(channel_, channel); |
| 151 socket()->OnChannelClosed(); | 151 socket()->OnChannelClosed(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void BluetoothL2capChannelMac::OnChannelDataReceived( | 154 void BluetoothL2capChannelMac::OnChannelDataReceived( |
| 155 IOBluetoothL2CAPChannel* channel, | 155 IOBluetoothL2CAPChannel* channel, |
| 156 void* data, | 156 void* data, |
| 157 size_t length) { | 157 size_t length) { |
| 158 DCHECK_EQ(channel_, channel); | 158 DCHECK_EQ(channel_, channel); |
| 159 socket()->OnChannelDataReceived(data, length); | 159 socket()->OnChannelDataReceived(data, length); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void BluetoothL2capChannelMac::OnChannelWriteComplete( | 162 void BluetoothL2capChannelMac::OnChannelWriteComplete( |
| 163 IOBluetoothL2CAPChannel* channel, | 163 IOBluetoothL2CAPChannel* channel, |
| 164 void* refcon, | 164 void* refcon, |
| 165 IOReturn status) { | 165 IOReturn status) { |
| 166 // Note: We use "CHECK" below to ensure we never run into unforeseen | 166 // Note: We use "CHECK" below to ensure we never run into unforeseen |
| 167 // occurrences of asynchronous callbacks, which could lead to data | 167 // occurrences of asynchronous callbacks, which could lead to data |
| 168 // corruption. | 168 // corruption. |
| 169 CHECK_EQ(channel_, channel); | 169 CHECK_EQ(channel_, channel); |
| 170 socket()->OnChannelWriteComplete(refcon, status); | 170 socket()->OnChannelWriteComplete(refcon, status); |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace device | 173 } // namespace device |
| OLD | NEW |