OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_socket_mac.h" | 5 #include "device/bluetooth/bluetooth_socket_mac.h" |
6 | 6 |
7 #import <IOBluetooth/objc/IOBluetoothDevice.h> | 7 #import <IOBluetooth/objc/IOBluetoothDevice.h> |
8 #import <IOBluetooth/objc/IOBluetoothRFCOMMChannel.h> | 8 #import <IOBluetooth/objc/IOBluetoothRFCOMMChannel.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 28 matching lines...) Expand all Loading... | |
39 data:(void*)dataPointer | 39 data:(void*)dataPointer |
40 length:(size_t)dataLength { | 40 length:(size_t)dataLength { |
41 socket_->OnDataReceived(rfcommChannel, dataPointer, dataLength); | 41 socket_->OnDataReceived(rfcommChannel, dataPointer, dataLength); |
42 } | 42 } |
43 | 43 |
44 @end | 44 @end |
45 | 45 |
46 namespace device { | 46 namespace device { |
47 | 47 |
48 BluetoothSocketMac::BluetoothSocketMac(IOBluetoothRFCOMMChannel* rfcomm_channel) | 48 BluetoothSocketMac::BluetoothSocketMac(IOBluetoothRFCOMMChannel* rfcomm_channel) |
49 : rfcomm_channel_(rfcomm_channel), | 49 : rfcomm_channel_(rfcomm_channel) { |
50 delegate_([[BluetoothRFCOMMChannelDelegate alloc] initWithSocket:this]) { | 50 [rfcomm_channel_ setDelegate:[[BluetoothRFCOMMChannelDelegate alloc] |
51 [rfcomm_channel_ setDelegate:delegate_]; | 51 initWithSocket:this]]; |
52 ResetIncomingDataBuffer(); | 52 ResetIncomingDataBuffer(); |
53 } | 53 } |
54 | 54 |
55 BluetoothSocketMac::~BluetoothSocketMac() { | 55 BluetoothSocketMac::~BluetoothSocketMac() { |
56 [rfcomm_channel_ release]; | 56 [rfcomm_channel_ closeChannel]; |
Mark Mentovai
2013/04/11 21:48:58
Does IOBluetoothRFCOMMChannel release its delegate
Mark Mentovai
2013/04/11 21:48:58
How does rfcomm_channel_ get released now?
youngki
2013/04/11 22:14:29
So.. I did a bunch of testing with a bluetooth app
Mark Mentovai
2013/04/11 22:24:37
youngki wrote:
youngki
2013/04/12 01:51:47
Thanks for pointing this out; and you are right, I
| |
57 [delegate_ release]; | |
58 } | 57 } |
59 | 58 |
60 // static | 59 // static |
61 scoped_refptr<BluetoothSocket> BluetoothSocketMac::CreateBluetoothSocket( | 60 scoped_refptr<BluetoothSocket> BluetoothSocketMac::CreateBluetoothSocket( |
62 const BluetoothServiceRecord& service_record) { | 61 const BluetoothServiceRecord& service_record) { |
63 BluetoothSocketMac* bluetooth_socket = NULL; | 62 BluetoothSocketMac* bluetooth_socket = NULL; |
64 if (service_record.SupportsRfcomm()) { | 63 if (service_record.SupportsRfcomm()) { |
65 const BluetoothServiceRecordMac* service_record_mac = | 64 const BluetoothServiceRecordMac* service_record_mac = |
66 static_cast<const BluetoothServiceRecordMac*>(&service_record); | 65 static_cast<const BluetoothServiceRecordMac*>(&service_record); |
67 IOBluetoothDevice* device = service_record_mac->GetIOBluetoothDevice(); | 66 IOBluetoothDevice* device = service_record_mac->GetIOBluetoothDevice(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 incoming_data_buffer_->set_offset( | 131 incoming_data_buffer_->set_offset( |
133 incoming_data_buffer_->offset() + data_size); | 132 incoming_data_buffer_->offset() + data_size); |
134 } | 133 } |
135 | 134 |
136 void BluetoothSocketMac::ResetIncomingDataBuffer() { | 135 void BluetoothSocketMac::ResetIncomingDataBuffer() { |
137 incoming_data_buffer_ = new net::GrowableIOBuffer(); | 136 incoming_data_buffer_ = new net::GrowableIOBuffer(); |
138 incoming_data_buffer_->SetCapacity(1024); | 137 incoming_data_buffer_->SetCapacity(1024); |
139 } | 138 } |
140 | 139 |
141 } // namespace device | 140 } // namespace device |
OLD | NEW |