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

Side by Side Diff: device/bluetooth/bluetooth_service_record_win.cc

Issue 224893002: device/bluetooth: Rename device::bluetooth_utils::UUID to device::BluetoothUUID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_service_record_win.h" 5 #include "device/bluetooth/bluetooth_service_record_win.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "device/bluetooth/bluetooth_init_win.h" 12 #include "device/bluetooth/bluetooth_init_win.h"
13 #include "device/bluetooth/bluetooth_utils.h" 13 #include "device/bluetooth/bluetooth_uuid.h"
14 14
15 namespace { 15 namespace {
16 16
17 const uint16 kProtocolDescriptorListId = 4; 17 const uint16 kProtocolDescriptorListId = 4;
18 const uint16 kRfcommUuid = 3; 18 const uint16 kRfcommUuid = 3;
19 const uint16 kUuidId = 1; 19 const uint16 kUuidId = 1;
20 20
21 bool AdvanceToSdpType(const SDP_ELEMENT_DATA& sequence_data, 21 bool AdvanceToSdpType(const SDP_ELEMENT_DATA& sequence_data,
22 SDP_TYPE type, 22 SDP_TYPE type,
23 HBLUETOOTH_CONTAINER_ELEMENT* element, 23 HBLUETOOTH_CONTAINER_ELEMENT* element,
(...skipping 30 matching lines...) Expand all
54 SDP_TYPE_UINT, 54 SDP_TYPE_UINT,
55 &inner_sequence_element, 55 &inner_sequence_element,
56 &inner_sequence_data) && 56 &inner_sequence_data) &&
57 inner_sequence_data.specificType == SDP_ST_UINT8) { 57 inner_sequence_data.specificType == SDP_ST_UINT8) {
58 *rfcomm_channel = inner_sequence_data.data.uint8; 58 *rfcomm_channel = inner_sequence_data.data.uint8;
59 *supports_rfcomm = true; 59 *supports_rfcomm = true;
60 } 60 }
61 } 61 }
62 } 62 }
63 63
64 void ExtractUuid(const SDP_ELEMENT_DATA& uuid_data, std::string* uuid) { 64 void ExtractUuid(const SDP_ELEMENT_DATA& uuid_data,
65 device::BluetoothUUID* uuid) {
65 HBLUETOOTH_CONTAINER_ELEMENT inner_uuid_element = NULL; 66 HBLUETOOTH_CONTAINER_ELEMENT inner_uuid_element = NULL;
66 SDP_ELEMENT_DATA inner_uuid_data; 67 SDP_ELEMENT_DATA inner_uuid_data;
67 if (AdvanceToSdpType(uuid_data, 68 if (AdvanceToSdpType(uuid_data,
68 SDP_TYPE_UUID, 69 SDP_TYPE_UUID,
69 &inner_uuid_element, 70 &inner_uuid_element,
70 &inner_uuid_data)) { 71 &inner_uuid_data)) {
71 if (inner_uuid_data.specificType == SDP_ST_UUID16) { 72 if (inner_uuid_data.specificType == SDP_ST_UUID16) {
72 std::string uuid_hex = 73 std::string uuid_hex =
73 base::StringPrintf("%04x", inner_uuid_data.data.uuid16); 74 base::StringPrintf("%04x", inner_uuid_data.data.uuid16);
74 *uuid = device::bluetooth_utils::CanonicalUuid(uuid_hex); 75 *uuid = device::BluetoothUUID(uuid_hex);
75 } else if (inner_uuid_data.specificType == SDP_ST_UUID32) { 76 } else if (inner_uuid_data.specificType == SDP_ST_UUID32) {
76 std::string uuid_hex = 77 std::string uuid_hex =
77 base::StringPrintf("%08x", inner_uuid_data.data.uuid32); 78 base::StringPrintf("%08x", inner_uuid_data.data.uuid32);
78 *uuid = device::bluetooth_utils::CanonicalUuid(uuid_hex); 79 *uuid = device::BluetoothUUID(uuid_hex);
79 } else if (inner_uuid_data.specificType == SDP_ST_UUID128) { 80 } else if (inner_uuid_data.specificType == SDP_ST_UUID128) {
80 *uuid = base::StringPrintf( 81 *uuid = device::BluetoothUUID(base::StringPrintf(
81 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 82 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
82 inner_uuid_data.data.uuid128.Data1, 83 inner_uuid_data.data.uuid128.Data1,
83 inner_uuid_data.data.uuid128.Data2, 84 inner_uuid_data.data.uuid128.Data2,
84 inner_uuid_data.data.uuid128.Data3, 85 inner_uuid_data.data.uuid128.Data3,
85 inner_uuid_data.data.uuid128.Data4[0], 86 inner_uuid_data.data.uuid128.Data4[0],
86 inner_uuid_data.data.uuid128.Data4[1], 87 inner_uuid_data.data.uuid128.Data4[1],
87 inner_uuid_data.data.uuid128.Data4[2], 88 inner_uuid_data.data.uuid128.Data4[2],
88 inner_uuid_data.data.uuid128.Data4[3], 89 inner_uuid_data.data.uuid128.Data4[3],
89 inner_uuid_data.data.uuid128.Data4[4], 90 inner_uuid_data.data.uuid128.Data4[4],
90 inner_uuid_data.data.uuid128.Data4[5], 91 inner_uuid_data.data.uuid128.Data4[5],
91 inner_uuid_data.data.uuid128.Data4[6], 92 inner_uuid_data.data.uuid128.Data4[6],
92 inner_uuid_data.data.uuid128.Data4[7]); 93 inner_uuid_data.data.uuid128.Data4[7]));
93 } else { 94 } else {
94 uuid->clear(); 95 *uuid = device::BluetoothUUID();
95 } 96 }
96 } 97 }
97 } 98 }
98 99
99 BTH_ADDR ConvertToBthAddr(const std::string& address) { 100 BTH_ADDR ConvertToBthAddr(const std::string& address) {
100 BTH_ADDR bth_addr = 0; 101 BTH_ADDR bth_addr = 0;
101 std::string numbers_only; 102 std::string numbers_only;
102 for (int i = 0; i < 6; ++i) { 103 for (int i = 0; i < 6; ++i) {
103 numbers_only += address.substr(i * 3, 2); 104 numbers_only += address.substr(i * 3, 2);
104 } 105 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ExtractChannels(protocol_descriptor_list_data, 137 ExtractChannels(protocol_descriptor_list_data,
137 &supports_rfcomm_, 138 &supports_rfcomm_,
138 &rfcomm_channel_); 139 &rfcomm_channel_);
139 } 140 }
140 SDP_ELEMENT_DATA uuid_data; 141 SDP_ELEMENT_DATA uuid_data;
141 if (ERROR_SUCCESS == BluetoothSdpGetAttributeValue( 142 if (ERROR_SUCCESS == BluetoothSdpGetAttributeValue(
142 blob_data, 143 blob_data,
143 blob_size, 144 blob_size,
144 kUuidId, 145 kUuidId,
145 &uuid_data)) { 146 &uuid_data)) {
146 ExtractUuid(uuid_data, &uuid_); 147 ExtractUuid(uuid_data, &uuid_);
147 } 148 }
148 } 149 }
149 150
150 } // namespace device 151 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_service_record_mac_unittest.mm ('k') | device/bluetooth/bluetooth_service_record_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698