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