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

Unified Diff: device/bluetooth/bluetooth_service_record.cc

Issue 11884027: Separated BluetoothServiceRecord interface from BluetoothServiceRecordChromeOs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: changed namespace from device to chromeos. Created 7 years, 11 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
Index: device/bluetooth/bluetooth_service_record.cc
diff --git a/device/bluetooth/bluetooth_service_record.cc b/device/bluetooth/bluetooth_service_record.cc
index 0ea18d7dac697b52b196ae167b906243e99e2fd4..aa973735f7483b40218a99f5b1a584b2ea730298 100644
--- a/device/bluetooth/bluetooth_service_record.cc
+++ b/device/bluetooth/bluetooth_service_record.cc
@@ -4,119 +4,12 @@
#include "device/bluetooth/bluetooth_service_record.h"
-#include <string>
-#include <vector>
-
-#include "base/logging.h"
-#include "base/string_number_conversions.h"
-#include "device/bluetooth/bluetooth_utils.h"
-#include "third_party/libxml/chromium/libxml_utils.h"
-
-namespace {
-
-static const char* kAttributeNode = "attribute";
-static const char* kIdAttribute = "id";
-static const char* kProtocolDescriptorListId = "0x0004";
-static const char* kRfcommUuid = "0x0003";
-static const char* kSdpNameId = "0x0100";
-static const char* kSequenceNode = "sequence";
-static const char* kTextNode = "text";
-static const char* kUint8Node = "uint8";
-static const char* kUuidId = "0x0001";
-static const char* kUuidNode = "uuid";
-static const char* kValueAttribute = "value";
-
-bool AdvanceToTag(XmlReader* reader, const char* node_type) {
- do {
- if (!reader->Read())
- return false;
- } while (reader->NodeName() != node_type);
- return true;
-}
-
-bool ExtractTextValue(XmlReader* reader, std::string* value_out) {
- if (AdvanceToTag(reader, kTextNode)) {
- reader->NodeAttribute(kValueAttribute, value_out);
- return true;
- }
- return false;
-}
-
-} // namespace
-
namespace device {
-BluetoothServiceRecord::BluetoothServiceRecord(
- const std::string& address,
- const std::string& xml_data)
- : address_(address),
- supports_rfcomm_(false) {
-
- XmlReader reader;
- if (!reader.Load(xml_data))
- return;
-
- while (AdvanceToTag(&reader, kAttributeNode)) {
- std::string id;
- if (reader.NodeAttribute(kIdAttribute, &id)) {
- if (id == kSdpNameId) {
- ExtractTextValue(&reader, &name_);
- } else if (id == kProtocolDescriptorListId) {
- if (AdvanceToTag(&reader, kSequenceNode)) {
- ExtractChannels(&reader);
- }
- } else if (id == kUuidId) {
- if (AdvanceToTag(&reader, kSequenceNode)) {
- ExtractUuid(&reader);
- }
- }
- }
- // We don't care about anything else here, so find the closing tag
- AdvanceToTag(&reader, kAttributeNode);
- }
+BluetoothServiceRecord::BluetoothServiceRecord() {
}
-void BluetoothServiceRecord::ExtractChannels(XmlReader* reader) {
- const int start_depth = reader->Depth();
- do {
- if (reader->NodeName() == kSequenceNode) {
- if (AdvanceToTag(reader, kUuidNode)) {
- std::string type;
- if (reader->NodeAttribute(kValueAttribute, &type) &&
- type == kRfcommUuid) {
- if (AdvanceToTag(reader, kUint8Node)) {
- std::string channel_string;
- if (reader->NodeAttribute(kValueAttribute, &channel_string)) {
- std::vector<uint8> channel_bytes;
- if (base::HexStringToBytes(channel_string.substr(2),
- &channel_bytes)) {
- if (channel_bytes.size() == 1) {
- rfcomm_channel_ = channel_bytes[0];
- supports_rfcomm_ = true;
- }
- }
- }
- }
- }
- }
- }
- } while (AdvanceToTag(reader, kSequenceNode) &&
- reader->Depth() != start_depth);
-}
-
-void BluetoothServiceRecord::ExtractUuid(XmlReader* reader) {
- const int start_depth = reader->Depth();
- do {
- if (reader->NodeName() == kSequenceNode) {
- if (AdvanceToTag(reader, kUuidNode)) {
- if (!reader->NodeAttribute(kValueAttribute, &uuid_))
- uuid_.clear();
- }
- }
- } while (AdvanceToTag(reader, kSequenceNode) &&
- reader->Depth() != start_depth);
-
- uuid_ = device::bluetooth_utils::CanonicalUuid(uuid_);
+BluetoothServiceRecord::~BluetoothServiceRecord() {
}
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698