summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-06 21:48:16 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-06 21:48:16 +0000
commitd9b987584ce7d54eebfad246e898ff2a12899678 (patch)
tree98b69b76482b4c52047289f0e22b86a703b7a9d0
parent076ebedaa781461c668ea435ef3af3ca707775d5 (diff)
downloadchromium_src-d9b987584ce7d54eebfad246e898ff2a12899678.zip
chromium_src-d9b987584ce7d54eebfad246e898ff2a12899678.tar.gz
chromium_src-d9b987584ce7d54eebfad246e898ff2a12899678.tar.bz2
[Bluetooth] Remove the deprecated BluetoothServiceRecordMac class.
Move the functionality we still need into the BluetoothDevice class. BUG=372495 TEST=none R=keybuk@chromium.org Review URL: https://codereview.chromium.org/317073011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275532 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--device/bluetooth/bluetooth.gyp2
-rw-r--r--device/bluetooth/bluetooth_device_mac.mm41
-rw-r--r--device/bluetooth/bluetooth_service_record_mac.h37
-rw-r--r--device/bluetooth/bluetooth_service_record_mac.mm79
-rw-r--r--device/bluetooth/bluetooth_service_record_mac_unittest.mm154
-rw-r--r--device/bluetooth/bluetooth_socket_mac.mm2
-rw-r--r--device/device_tests.gyp1
7 files changed, 35 insertions, 281 deletions
diff --git a/device/bluetooth/bluetooth.gyp b/device/bluetooth/bluetooth.gyp
index e5cefb4..9b90149 100644
--- a/device/bluetooth/bluetooth.gyp
+++ b/device/bluetooth/bluetooth.gyp
@@ -63,8 +63,6 @@
'bluetooth_remote_gatt_service_chromeos.h',
'bluetooth_service_record.cc',
'bluetooth_service_record.h',
- 'bluetooth_service_record_mac.h',
- 'bluetooth_service_record_mac.mm',
'bluetooth_service_record_win.cc',
'bluetooth_service_record_win.h',
'bluetooth_socket.cc',
diff --git a/device/bluetooth/bluetooth_device_mac.mm b/device/bluetooth/bluetooth_device_mac.mm
index 25c8134..60574b0 100644
--- a/device/bluetooth/bluetooth_device_mac.mm
+++ b/device/bluetooth/bluetooth_device_mac.mm
@@ -14,7 +14,6 @@
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "device/bluetooth/bluetooth_profile_mac.h"
-#include "device/bluetooth/bluetooth_service_record_mac.h"
#include "device/bluetooth/bluetooth_socket_mac.h"
#include "device/bluetooth/bluetooth_uuid.h"
@@ -41,6 +40,31 @@
outTransmitPowerLevel:(BluetoothHCITransmitPowerLevel*)level;
@end
+namespace {
+
+void ExtractUuid(IOBluetoothSDPDataElement* service_class_data,
+ std::string* uuid) {
+ NSArray* inner_elements = [service_class_data getArrayValue];
+ IOBluetoothSDPUUID* sdp_uuid = nil;
+ for (IOBluetoothSDPDataElement* inner_element in inner_elements) {
+ if ([inner_element getTypeDescriptor] == kBluetoothSDPDataElementTypeUUID) {
+ sdp_uuid = [[inner_element getUUIDValue] getUUIDWithLength:16];
+ break;
+ }
+ }
+ if (sdp_uuid != nil) {
+ const uint8* uuid_bytes = reinterpret_cast<const uint8*>([sdp_uuid bytes]);
+ *uuid = base::StringPrintf(
+ "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ uuid_bytes[0], uuid_bytes[1], uuid_bytes[2], uuid_bytes[3],
+ uuid_bytes[4], uuid_bytes[5], uuid_bytes[6], uuid_bytes[7],
+ uuid_bytes[8], uuid_bytes[9], uuid_bytes[10], uuid_bytes[11],
+ uuid_bytes[12], uuid_bytes[13], uuid_bytes[14], uuid_bytes[15]);
+ }
+}
+
+} // namespace
+
namespace device {
BluetoothDeviceMac::BluetoothDeviceMac(IOBluetoothDevice* device)
@@ -130,13 +154,18 @@ bool BluetoothDeviceMac::IsConnecting() const {
return false;
}
-// TODO(keybuk): BluetoothServiceRecord is deprecated; implement this method
-// without using BluetoothServiceRecord.
BluetoothDevice::UUIDList BluetoothDeviceMac::GetUUIDs() const {
UUIDList uuids;
- for (IOBluetoothSDPServiceRecord* service in [device_ services]) {
- BluetoothServiceRecordMac service_record(service);
- uuids.push_back(service_record.uuid());
+ for (IOBluetoothSDPServiceRecord* service_record in [device_ services]) {
+ const BluetoothSDPServiceAttributeID service_class_id = 1;
+ IOBluetoothSDPDataElement* service_class_data =
+ [service_record getAttributeDataElement:service_class_id];
+ if ([service_class_data getTypeDescriptor] ==
+ kBluetoothSDPDataElementTypeDataElementSequence) {
+ std::string uuid_str;
+ ExtractUuid(service_class_data, &uuid_str);
+ uuids.push_back(BluetoothUUID(uuid_str));
+ }
}
return uuids;
}
diff --git a/device/bluetooth/bluetooth_service_record_mac.h b/device/bluetooth/bluetooth_service_record_mac.h
deleted file mode 100644
index 13eb56b..0000000
--- a/device/bluetooth/bluetooth_service_record_mac.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef DEVICE_BLUETOOTH_BLUETOOTH_SERVICE_RECORD_MAC_H_
-#define DEVICE_BLUETOOTH_BLUETOOTH_SERVICE_RECORD_MAC_H_
-
-#include "device/bluetooth/bluetooth_service_record.h"
-
-#ifdef __OBJC__
-@class IOBluetoothDevice;
-@class IOBluetoothSDPServiceRecord;
-#else
-class IOBluetoothDevice;
-class IOBluetoothSDPServiceRecord;
-#endif
-
-namespace device {
-
-class BluetoothServiceRecordMac : public BluetoothServiceRecord {
- public:
- explicit BluetoothServiceRecordMac(IOBluetoothSDPServiceRecord* record);
- virtual ~BluetoothServiceRecordMac();
-
- IOBluetoothDevice* GetIOBluetoothDevice() const {
- return device_;
- }
-
- private:
- IOBluetoothDevice* device_;
-
- DISALLOW_COPY_AND_ASSIGN(BluetoothServiceRecordMac);
-};
-
-} // namespace device
-
-#endif // DEVICE_BLUETOOTH_BLUETOOTH_SERVICE_RECORD_MAC_H_
diff --git a/device/bluetooth/bluetooth_service_record_mac.mm b/device/bluetooth/bluetooth_service_record_mac.mm
deleted file mode 100644
index ee61b97..0000000
--- a/device/bluetooth/bluetooth_service_record_mac.mm
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "device/bluetooth/bluetooth_service_record_mac.h"
-
-#include <IOBluetooth/Bluetooth.h>
-#import <IOBluetooth/IOBluetoothUtilities.h>
-#import <IOBluetooth/objc/IOBluetoothDevice.h>
-#import <IOBluetooth/objc/IOBluetoothSDPDataElement.h>
-#import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
-#import <IOBluetooth/objc/IOBluetoothSDPUUID.h>
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/sys_string_conversions.h"
-
-namespace {
-
-void ExtractUuid(IOBluetoothSDPDataElement* service_class_data,
- std::string* uuid) {
- NSArray* inner_elements = [service_class_data getArrayValue];
- IOBluetoothSDPUUID* sdp_uuid = nil;
- for (IOBluetoothSDPDataElement* inner_element in inner_elements) {
- if ([inner_element getTypeDescriptor] == kBluetoothSDPDataElementTypeUUID) {
- sdp_uuid = [[inner_element getUUIDValue] getUUIDWithLength:16];
- break;
- }
- }
- if (sdp_uuid != nil) {
- const uint8* uuid_bytes = reinterpret_cast<const uint8*>([sdp_uuid bytes]);
- *uuid = base::StringPrintf(
- "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
- uuid_bytes[0], uuid_bytes[1], uuid_bytes[2], uuid_bytes[3],
- uuid_bytes[4], uuid_bytes[5], uuid_bytes[6], uuid_bytes[7],
- uuid_bytes[8], uuid_bytes[9], uuid_bytes[10], uuid_bytes[11],
- uuid_bytes[12], uuid_bytes[13], uuid_bytes[14], uuid_bytes[15]);
- }
-}
-
-} // namespace
-
-namespace device {
-
-BluetoothServiceRecordMac::BluetoothServiceRecordMac(
- IOBluetoothSDPServiceRecord* record)
- : BluetoothServiceRecord() {
- name_ = base::SysNSStringToUTF8([record getServiceName]);
- device_ = [[record device] retain];
- address_ = base::SysNSStringToUTF8(IOBluetoothNSStringFromDeviceAddress(
- [device_ getAddress]));
-
- // TODO(youngki): Extract these values from |record|.
- supports_hid_ = false;
- hid_reconnect_initiate_ = false;
- hid_normally_connectable_ = false;
-
- supports_rfcomm_ =
- [record getRFCOMMChannelID:&rfcomm_channel_] == kIOReturnSuccess;
-
- const BluetoothSDPServiceAttributeID service_class_id = 1;
-
- IOBluetoothSDPDataElement* service_class_data =
- [record getAttributeDataElement:service_class_id];
- if ([service_class_data getTypeDescriptor] ==
- kBluetoothSDPDataElementTypeDataElementSequence) {
- std::string uuid_str;
- ExtractUuid(service_class_data, &uuid_str);
- uuid_ = BluetoothUUID(uuid_str);
- }
-}
-
-BluetoothServiceRecordMac::~BluetoothServiceRecordMac() {
- [device_ release];
-}
-
-} // namespace device
diff --git a/device/bluetooth/bluetooth_service_record_mac_unittest.mm b/device/bluetooth/bluetooth_service_record_mac_unittest.mm
deleted file mode 100644
index b64ea67..0000000
--- a/device/bluetooth/bluetooth_service_record_mac_unittest.mm
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "device/bluetooth/bluetooth_service_record_mac.h"
-
-#import <IOBluetooth/objc/IOBluetoothSDPDataElement.h>
-#import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
-#import <IOBluetooth/objc/IOBluetoothSDPUUID.h>
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/sys_string_conversions.h"
-#include "device/bluetooth/bluetooth_uuid.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-const BluetoothSDPServiceAttributeID kServiceClassIDAttributeId = 0x0001;
-const BluetoothSDPServiceAttributeID kProtocolDescriptorListAttributeId =
- 0x0004;
-const BluetoothSDPServiceAttributeID kServiceNameAttributeId = 0x0100;
-
-const uint8 kRfcommChannel = 0x0c;
-const char kServiceName[] = "Headset Audio Gateway";
-
-const device::BluetoothUUID kExpectedRfcommUuid(
- "01234567-89ab-cdef-0123-456789abcdef");
-const device::BluetoothUUID kExpectedSerialUuid("1101");
-
-const int kMaxUuidSize = 16;
-
-} // namespace
-
-namespace device {
-
-class BluetoothServiceRecordMacTest : public testing::Test {
- public:
-
- IOBluetoothSDPUUID* ConvertUuid(const char* uuid_hex_char, size_t uuid_size) {
- std::vector<uint8> uuid_bytes_vector;
- uint8 uuid_buffer[kMaxUuidSize];
- base::HexStringToBytes(uuid_hex_char, &uuid_bytes_vector);
- std::copy(uuid_bytes_vector.begin(),
- uuid_bytes_vector.end(),
- uuid_buffer);
- return [IOBluetoothSDPUUID uuidWithBytes:uuid_buffer length:uuid_size];
- }
-
- IOBluetoothSDPDataElement* GetServiceClassId(IOBluetoothSDPUUID* uuid) {
- IOBluetoothSDPDataElement* uuid_element =
- [IOBluetoothSDPDataElement withElementValue:uuid];
- return [IOBluetoothSDPDataElement
- withElementValue:[NSArray arrayWithObject:uuid_element]];
- }
-
- IOBluetoothSDPDataElement* GetProtocolDescriptorList(bool supports_rfcomm) {
- NSMutableArray* protocol_descriptor_list_sequence = [NSMutableArray array];
-
- const uint8 l2cap_uuid_bytes[] = { 0x01, 0x00 };
-
- IOBluetoothSDPUUID* l2cap_uuid =
- [IOBluetoothSDPUUID uuidWithBytes:l2cap_uuid_bytes length:2];
- [protocol_descriptor_list_sequence
- addObject:[NSArray arrayWithObject:l2cap_uuid]];
-
- if (supports_rfcomm) {
- const uint8 rfcomm_uuid_bytes[] = { 0x00, 0x03 };
- IOBluetoothSDPUUID* rfcomm_uuid =
- [IOBluetoothSDPUUID uuidWithBytes:rfcomm_uuid_bytes length:2];
- NSNumber* rfcomm_channel =
- [NSNumber numberWithUnsignedChar:kRfcommChannel];
- [protocol_descriptor_list_sequence
- addObject:[NSArray
- arrayWithObjects:rfcomm_uuid, rfcomm_channel, nil]];
- }
-
- return [IOBluetoothSDPDataElement
- withElementValue:protocol_descriptor_list_sequence];
- }
-
- IOBluetoothSDPDataElement* GetServiceName(const std::string& service_name) {
- return [IOBluetoothSDPDataElement
- withElementValue:base::SysUTF8ToNSString(service_name)];
- }
-
- IOBluetoothSDPServiceRecord* GetServiceRecord(
- IOBluetoothSDPUUID* uuid, bool supports_rfcomm) {
- NSMutableDictionary* service_attrs = [NSMutableDictionary dictionary];
-
- if (uuid != nil) {
- [service_attrs
- setObject:GetServiceClassId(uuid)
- forKey:[NSNumber numberWithInt:kServiceClassIDAttributeId]];
- }
- [service_attrs
- setObject:GetProtocolDescriptorList(supports_rfcomm)
- forKey:[NSNumber numberWithInt:kProtocolDescriptorListAttributeId]];
- [service_attrs
- setObject:GetServiceName(kServiceName)
- forKey:[NSNumber numberWithInt:kServiceNameAttributeId]];
-
- return [IOBluetoothSDPServiceRecord withServiceDictionary:service_attrs
- device:nil];
- }
-};
-
-TEST_F(BluetoothServiceRecordMacTest, RfcommService) {
- const char rfcomm_uuid_bytes[] = "0123456789abcdef0123456789abcdef";
- IOBluetoothSDPUUID* rfcomm_uuid =
- ConvertUuid(rfcomm_uuid_bytes, sizeof(rfcomm_uuid_bytes) / 2);
-
- BluetoothServiceRecordMac record(GetServiceRecord(rfcomm_uuid, true));
- EXPECT_EQ(kServiceName, record.name());
- EXPECT_TRUE(record.SupportsRfcomm());
- EXPECT_EQ(kRfcommChannel, record.rfcomm_channel());
- EXPECT_EQ(kExpectedRfcommUuid, record.uuid());
-}
-
-TEST_F(BluetoothServiceRecordMacTest, ShortUuid) {
- const char short_uuid_bytes[] = "1101";
- IOBluetoothSDPUUID* short_uuid =
- ConvertUuid(short_uuid_bytes, sizeof(short_uuid_bytes) / 2);
-
- BluetoothServiceRecordMac record(GetServiceRecord(short_uuid, false));
- EXPECT_EQ(kExpectedSerialUuid, record.uuid());
-}
-
-TEST_F(BluetoothServiceRecordMacTest, MediumUuid) {
- const char medium_uuid_bytes[] = "00001101";
- IOBluetoothSDPUUID* medium_uuid =
- ConvertUuid(medium_uuid_bytes, sizeof(medium_uuid_bytes) / 2);
-
- BluetoothServiceRecordMac record(GetServiceRecord(medium_uuid, false));
- EXPECT_EQ(kExpectedSerialUuid, record.uuid());
-}
-
-TEST_F(BluetoothServiceRecordMacTest, UpperCaseUuid) {
- const char upper_case_uuid_bytes[] = "0123456789ABCDEF0123456789ABCDEF";
- IOBluetoothSDPUUID* upper_case_uuid =
- ConvertUuid(upper_case_uuid_bytes, sizeof(upper_case_uuid_bytes) / 2);
-
- BluetoothServiceRecordMac record(GetServiceRecord(upper_case_uuid, false));
- EXPECT_EQ(kExpectedRfcommUuid, record.uuid());
-}
-
-TEST_F(BluetoothServiceRecordMacTest, InvalidUuid) {
- BluetoothServiceRecordMac record(GetServiceRecord(nil, false));
- EXPECT_FALSE(record.uuid().IsValid());
-}
-
-} // namespace device
diff --git a/device/bluetooth/bluetooth_socket_mac.mm b/device/bluetooth/bluetooth_socket_mac.mm
index d258f0e..8284d8c 100644
--- a/device/bluetooth/bluetooth_socket_mac.mm
+++ b/device/bluetooth/bluetooth_socket_mac.mm
@@ -19,8 +19,6 @@
#include "base/strings/sys_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "device/bluetooth/bluetooth_device_mac.h"
-#include "device/bluetooth/bluetooth_service_record.h"
-#include "device/bluetooth/bluetooth_service_record_mac.h"
#include "net/base/io_buffer.h"
@interface BluetoothRFCOMMChannelDelegate
diff --git a/device/device_tests.gyp b/device/device_tests.gyp
index d3ec0b6..577b28d 100644
--- a/device/device_tests.gyp
+++ b/device/device_tests.gyp
@@ -29,7 +29,6 @@
'bluetooth/bluetooth_device_win_unittest.cc',
'bluetooth/bluetooth_chromeos_unittest.cc',
'bluetooth/bluetooth_gatt_chromeos_unittest.cc',
- 'bluetooth/bluetooth_service_record_mac_unittest.mm',
'bluetooth/bluetooth_service_record_win_unittest.cc',
'bluetooth/bluetooth_socket_chromeos_unittest.cc',
'bluetooth/bluetooth_task_manager_win_unittest.cc',