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

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

Issue 652403002: [Clean up] Expose ConnectToServiceInsecurely as a BluetoothDevice API on all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase: Restore deps rather than public_deps Created 6 years, 2 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_device_mac.h ('k') | device/bluetooth/bluetooth_device_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_device_mac.h" 5 #include "device/bluetooth/bluetooth_device_mac.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 11 matching lines...) Expand all
22 @interface IOBluetoothHostController (UndocumentedAPI) 22 @interface IOBluetoothHostController (UndocumentedAPI)
23 - (IOReturn) 23 - (IOReturn)
24 BluetoothHCIReadTransmitPowerLevel:(BluetoothConnectionHandle)connection 24 BluetoothHCIReadTransmitPowerLevel:(BluetoothConnectionHandle)connection
25 inType:(BluetoothHCITransmitPowerLevelType)type 25 inType:(BluetoothHCITransmitPowerLevelType)type
26 outTransmitPowerLevel:(BluetoothHCITransmitPowerLevel*)level; 26 outTransmitPowerLevel:(BluetoothHCITransmitPowerLevel*)level;
27 @end 27 @end
28 28
29 namespace device { 29 namespace device {
30 namespace { 30 namespace {
31 31
32 const char kApiUnavailable[] = "This API is not implemented on this platform.";
33
32 // Returns the first (should be, only) UUID contained within the 34 // Returns the first (should be, only) UUID contained within the
33 // |service_class_data|. Returns an invalid (empty) UUID if none is found. 35 // |service_class_data|. Returns an invalid (empty) UUID if none is found.
34 BluetoothUUID ExtractUuid(IOBluetoothSDPDataElement* service_class_data) { 36 BluetoothUUID ExtractUuid(IOBluetoothSDPDataElement* service_class_data) {
35 NSArray* inner_elements = [service_class_data getArrayValue]; 37 NSArray* inner_elements = [service_class_data getArrayValue];
36 IOBluetoothSDPUUID* sdp_uuid = nil; 38 IOBluetoothSDPUUID* sdp_uuid = nil;
37 for (IOBluetoothSDPDataElement* inner_element in inner_elements) { 39 for (IOBluetoothSDPDataElement* inner_element in inner_elements) {
38 if ([inner_element getTypeDescriptor] == kBluetoothSDPDataElementTypeUUID) { 40 if ([inner_element getTypeDescriptor] == kBluetoothSDPDataElementTypeUUID) {
39 sdp_uuid = [[inner_element getUUIDValue] getUUIDWithLength:16]; 41 sdp_uuid = [[inner_element getUUIDValue] getUUIDWithLength:16];
40 break; 42 break;
41 } 43 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 202
201 void BluetoothDeviceMac::ConnectToService( 203 void BluetoothDeviceMac::ConnectToService(
202 const BluetoothUUID& uuid, 204 const BluetoothUUID& uuid,
203 const ConnectToServiceCallback& callback, 205 const ConnectToServiceCallback& callback,
204 const ConnectToServiceErrorCallback& error_callback) { 206 const ConnectToServiceErrorCallback& error_callback) {
205 scoped_refptr<BluetoothSocketMac> socket = BluetoothSocketMac::CreateSocket(); 207 scoped_refptr<BluetoothSocketMac> socket = BluetoothSocketMac::CreateSocket();
206 socket->Connect( 208 socket->Connect(
207 device_.get(), uuid, base::Bind(callback, socket), error_callback); 209 device_.get(), uuid, base::Bind(callback, socket), error_callback);
208 } 210 }
209 211
212 void BluetoothDeviceMac::ConnectToServiceInsecurely(
213 const BluetoothUUID& uuid,
214 const ConnectToServiceCallback& callback,
215 const ConnectToServiceErrorCallback& error_callback) {
216 error_callback.Run(kApiUnavailable);
217 }
218
210 void BluetoothDeviceMac::CreateGattConnection( 219 void BluetoothDeviceMac::CreateGattConnection(
211 const GattConnectionCallback& callback, 220 const GattConnectionCallback& callback,
212 const ConnectErrorCallback& error_callback) { 221 const ConnectErrorCallback& error_callback) {
213 // TODO(armansito): Implement. 222 // TODO(armansito): Implement.
214 error_callback.Run(ERROR_UNSUPPORTED_DEVICE); 223 error_callback.Run(ERROR_UNSUPPORTED_DEVICE);
215 } 224 }
216 225
217 void BluetoothDeviceMac::StartConnectionMonitor( 226 void BluetoothDeviceMac::StartConnectionMonitor(
218 const base::Closure& callback, 227 const base::Closure& callback,
219 const ErrorCallback& error_callback) { 228 const ErrorCallback& error_callback) {
(...skipping 25 matching lines...) Expand all
245 254
246 return power_level; 255 return power_level;
247 } 256 }
248 257
249 // static 258 // static
250 std::string BluetoothDeviceMac::GetDeviceAddress(IOBluetoothDevice* device) { 259 std::string BluetoothDeviceMac::GetDeviceAddress(IOBluetoothDevice* device) {
251 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); 260 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString]));
252 } 261 }
253 262
254 } // namespace device 263 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_mac.h ('k') | device/bluetooth/bluetooth_device_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698