Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: device/bluetooth/bluetooth_socket_mac.mm

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ChromeOS Full build. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/bluetooth/bluetooth_socket_mac.h ('k') | device/bluetooth/bluetooth_socket_thread_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h> 9 #import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 << base::SysNSStringToUTF8([device addressString]) << "): (" << status 116 << base::SysNSStringToUTF8([device addressString]) << "): (" << status
117 << ")"; 117 << ")";
118 } 118 }
119 } 119 }
120 120
121 // TODO(youngki): Add support for L2CAP sockets as well. 121 // TODO(youngki): Add support for L2CAP sockets as well.
122 122
123 return scoped_refptr<BluetoothSocketMac>(bluetooth_socket); 123 return scoped_refptr<BluetoothSocketMac>(bluetooth_socket);
124 } 124 }
125 125
126 void BluetoothSocketMac::Close() { NOTIMPLEMENTED(); }
127
128 void BluetoothSocketMac::Disconnect(const base::Closure& callback) {
129 NOTIMPLEMENTED();
130 }
131
132 void BluetoothSocketMac::Receive(
133 int count,
134 const ReceiveCompletionCallback& success_callback,
135 const ReceiveErrorCompletionCallback& error_callback) {
136 NOTIMPLEMENTED();
137 }
138
139 void BluetoothSocketMac::Send(scoped_refptr<net::IOBuffer> buffer,
140 int buffer_size,
141 const SendCompletionCallback& success_callback,
142 const ErrorCompletionCallback& error_callback) {
143 NOTIMPLEMENTED();
144 }
145
146 #if 0
126 bool BluetoothSocketMac::Receive(net::GrowableIOBuffer* buffer) { 147 bool BluetoothSocketMac::Receive(net::GrowableIOBuffer* buffer) {
127 CHECK(buffer->offset() == 0); 148 CHECK(buffer->offset() == 0);
128 int length = incoming_data_buffer_->offset(); 149 int length = incoming_data_buffer_->offset();
129 if (length > 0) { 150 if (length > 0) {
130 buffer->SetCapacity(length); 151 buffer->SetCapacity(length);
131 memcpy(buffer->data(), incoming_data_buffer_->StartOfBuffer(), length); 152 memcpy(buffer->data(), incoming_data_buffer_->StartOfBuffer(), length);
132 buffer->set_offset(length); 153 buffer->set_offset(length);
133 154
134 ResetIncomingDataBuffer(); 155 ResetIncomingDataBuffer();
135 } 156 }
(...skipping 11 matching lines...) Expand all
147 return false; 168 return false;
148 } 169 }
149 170
150 buffer->DidConsume(bytes_written); 171 buffer->DidConsume(bytes_written);
151 return true; 172 return true;
152 } 173 }
153 174
154 std::string BluetoothSocketMac::GetLastErrorMessage() const { 175 std::string BluetoothSocketMac::GetLastErrorMessage() const {
155 return error_message_; 176 return error_message_;
156 } 177 }
157 178 #endif
158 void BluetoothSocketMac::OnDataReceived( 179 void BluetoothSocketMac::OnDataReceived(
159 IOBluetoothRFCOMMChannel* rfcomm_channel, void* data, size_t length) { 180 IOBluetoothRFCOMMChannel* rfcomm_channel, void* data, size_t length) {
160 DCHECK(rfcomm_channel_ == rfcomm_channel); 181 DCHECK(rfcomm_channel_ == rfcomm_channel);
161 CHECK_LT(length, static_cast<size_t>(std::numeric_limits<int>::max())); 182 CHECK_LT(length, static_cast<size_t>(std::numeric_limits<int>::max()));
162 int data_size = static_cast<int>(length); 183 int data_size = static_cast<int>(length);
163 if (incoming_data_buffer_->RemainingCapacity() < data_size) { 184 if (incoming_data_buffer_->RemainingCapacity() < data_size) {
164 int additional_capacity = 185 int additional_capacity =
165 std::max(data_size, incoming_data_buffer_->capacity()); 186 std::max(data_size, incoming_data_buffer_->capacity());
166 CHECK_LT( 187 CHECK_LT(
167 additional_capacity, 188 additional_capacity,
168 std::numeric_limits<int>::max() - incoming_data_buffer_->capacity()); 189 std::numeric_limits<int>::max() - incoming_data_buffer_->capacity());
169 incoming_data_buffer_->SetCapacity( 190 incoming_data_buffer_->SetCapacity(
170 incoming_data_buffer_->capacity() + additional_capacity); 191 incoming_data_buffer_->capacity() + additional_capacity);
171 } 192 }
172 memcpy(incoming_data_buffer_->data(), data, data_size); 193 memcpy(incoming_data_buffer_->data(), data, data_size);
173 incoming_data_buffer_->set_offset( 194 incoming_data_buffer_->set_offset(
174 incoming_data_buffer_->offset() + data_size); 195 incoming_data_buffer_->offset() + data_size);
175 } 196 }
176 197
177 void BluetoothSocketMac::ResetIncomingDataBuffer() { 198 void BluetoothSocketMac::ResetIncomingDataBuffer() {
178 incoming_data_buffer_ = new net::GrowableIOBuffer(); 199 incoming_data_buffer_ = new net::GrowableIOBuffer();
179 incoming_data_buffer_->SetCapacity(1024); 200 incoming_data_buffer_->SetCapacity(1024);
180 } 201 }
181 202
182 } // namespace device 203 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_socket_mac.h ('k') | device/bluetooth/bluetooth_socket_thread_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698