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

Unified Diff: device/bluetooth/bluetooth_uuid.cc

Issue 285633003: Bluetooth UUIDs should be case-insensitive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_uuid.h ('k') | device/bluetooth/bluetooth_uuid_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_uuid.cc
diff --git a/device/bluetooth/bluetooth_uuid.cc b/device/bluetooth/bluetooth_uuid.cc
index 354c0d1b27fe8ae06a2b363b9ccd02f22063c125..4623576db74d9425af38760532bd2a515a18bfa2 100644
--- a/device/bluetooth/bluetooth_uuid.cc
+++ b/device/bluetooth/bluetooth_uuid.cc
@@ -14,7 +14,6 @@ namespace {
const char* kCommonUuidPostfix = "-0000-1000-8000-00805f9b34fb";
const char* kCommonUuidPrefix = "0000";
-const int kUuidSize = 36;
// Returns the canonical, 128-bit canonical, and the format of the UUID
// in |canonical|, |canonical_128|, and |format| based on |uuid|.
@@ -36,24 +35,7 @@ void GetCanonicalUuid(std::string uuid,
if (!(uuid.size() == 4 || uuid.size() == 8 || uuid.size() == 36))
return;
- if (uuid.size() == 4 || uuid.size() == 8) {
- for (size_t i = 0; i < uuid.size(); ++i) {
- if (!IsHexDigit(uuid[i]))
- return;
- }
- if (uuid.size() == 4) {
- canonical->assign(uuid);
- canonical_128->assign(kCommonUuidPrefix + uuid + kCommonUuidPostfix);
- *format = BluetoothUUID::kFormat16Bit;
- return;
- }
- canonical->assign(uuid);
- canonical_128->assign(uuid + kCommonUuidPostfix);
- *format = BluetoothUUID::kFormat32Bit;
- return;
- }
-
- for (int i = 0; i < kUuidSize; ++i) {
+ for (size_t i = 0; i < uuid.size(); ++i) {
if (i == 8 || i == 13 || i == 18 || i == 23) {
if (uuid[i] != '-')
return;
@@ -65,8 +47,16 @@ void GetCanonicalUuid(std::string uuid,
}
canonical->assign(uuid);
- canonical_128->assign(uuid);
- *format = BluetoothUUID::kFormat128Bit;
+ if (uuid.size() == 4) {
+ canonical_128->assign(kCommonUuidPrefix + uuid + kCommonUuidPostfix);
+ *format = BluetoothUUID::kFormat16Bit;
+ } else if (uuid.size() == 8) {
+ canonical_128->assign(uuid + kCommonUuidPostfix);
+ *format = BluetoothUUID::kFormat32Bit;
+ } else {
+ canonical_128->assign(uuid);
+ *format = BluetoothUUID::kFormat128Bit;
+ }
}
} // namespace
« no previous file with comments | « device/bluetooth/bluetooth_uuid.h ('k') | device/bluetooth/bluetooth_uuid_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698