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

Unified Diff: trunk/src/device/bluetooth/bluetooth_uuid.cc

Issue 224763003: Revert 261566 "device/bluetooth: Rename device::bluetooth_utils:..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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 | « trunk/src/device/bluetooth/bluetooth_uuid.h ('k') | trunk/src/device/bluetooth/bluetooth_uuid_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/device/bluetooth/bluetooth_uuid.cc
===================================================================
--- trunk/src/device/bluetooth/bluetooth_uuid.cc (revision 261569)
+++ trunk/src/device/bluetooth/bluetooth_uuid.cc (working copy)
@@ -1,101 +0,0 @@
-// Copyright 2014 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_uuid.h"
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "base/strings/string_util.h"
-
-namespace device {
-
-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|.
-void GetCanonicalUuid(std::string uuid,
- std::string* canonical,
- std::string* canonical_128,
- BluetoothUUID::Format* format) {
- // Initialize the values for the failure case.
- canonical->clear();
- canonical_128->clear();
- *format = BluetoothUUID::kFormatInvalid;
-
- if (uuid.empty())
- return;
-
- if (uuid.size() < 11 && uuid.find("0x") == 0)
- uuid = uuid.substr(2);
-
- 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) {
- if (i == 8 || i == 13 || i == 18 || i == 23) {
- if (uuid[i] != '-')
- return;
- } else {
- if (!IsHexDigit(uuid[i]))
- return;
- uuid[i] = tolower(uuid[i]);
- }
- }
-
- canonical->assign(uuid);
- canonical_128->assign(uuid);
- *format = BluetoothUUID::kFormat128Bit;
-}
-
-} // namespace
-
-
-BluetoothUUID::BluetoothUUID(const std::string& uuid) {
- GetCanonicalUuid(uuid, &value_, &canonical_value_, &format_);
-}
-
-BluetoothUUID::BluetoothUUID() : format_(kFormatInvalid) {
-}
-
-BluetoothUUID::~BluetoothUUID() {
-}
-
-bool BluetoothUUID::IsValid() const {
- return format_ != kFormatInvalid;
-}
-
-bool BluetoothUUID::operator<(const BluetoothUUID& uuid) const {
- return canonical_value_ < uuid.canonical_value_;
-}
-
-bool BluetoothUUID::operator==(const BluetoothUUID& uuid) const {
- return canonical_value_ == uuid.canonical_value_;
-}
-
-bool BluetoothUUID::operator!=(const BluetoothUUID& uuid) const {
- return canonical_value_ != uuid.canonical_value_;
-}
-
-} // namespace device
« no previous file with comments | « trunk/src/device/bluetooth/bluetooth_uuid.h ('k') | trunk/src/device/bluetooth/bluetooth_uuid_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698