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_classic_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" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 [channel->delegate_ retain]; | 92 [channel->delegate_ retain]; |
93 IOBluetoothL2CAPChannel* l2cap_channel; | 93 IOBluetoothL2CAPChannel* l2cap_channel; |
94 *status = [device openL2CAPChannelAsync:&l2cap_channel | 94 *status = [device openL2CAPChannelAsync:&l2cap_channel |
95 withPSM:psm | 95 withPSM:psm |
96 delegate:channel->delegate_]; | 96 delegate:channel->delegate_]; |
97 if (*status == kIOReturnSuccess) | 97 if (*status == kIOReturnSuccess) |
98 channel->channel_.reset([l2cap_channel retain]); | 98 channel->channel_.reset([l2cap_channel retain]); |
99 else | 99 else |
100 channel.reset(); | 100 channel.reset(); |
101 | 101 |
102 return channel.Pass(); | 102 return channel; |
103 } | 103 } |
104 | 104 |
105 void BluetoothL2capChannelMac::SetSocket(BluetoothSocketMac* socket) { | 105 void BluetoothL2capChannelMac::SetSocket(BluetoothSocketMac* socket) { |
106 BluetoothChannelMac::SetSocket(socket); | 106 BluetoothChannelMac::SetSocket(socket); |
107 if (!this->socket()) | 107 if (!this->socket()) |
108 return; | 108 return; |
109 | 109 |
110 // Now that the socket is set, it's safe to associate a delegate, which can | 110 // Now that the socket is set, it's safe to associate a delegate, which can |
111 // call back to the socket. | 111 // call back to the socket. |
112 DCHECK(!delegate_); | 112 DCHECK(!delegate_); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |