Added DeviceDescription::version with Privet version.

Review URL: https://codereview.chromium.org/318893002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275318 0039d316-1c4b-4281-b951-d872f2087c98
parent b3df545e
......@@ -6,6 +6,7 @@
#include <vector>
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "chrome/browser/local_discovery/privet_constants.h"
#include "chrome/common/local_discovery/service_discovery_client.h"
......@@ -31,6 +32,14 @@ ConnectionStateFromString(const std::string& str) {
} // namespace
DeviceDescription::DeviceDescription()
: version(0),
connection_state(UNKNOWN) {
}
DeviceDescription::~DeviceDescription() {
}
void DeviceDescription::FillFromServiceDescription(
const ServiceDescription& service_description) {
address = service_description.address;
......@@ -48,7 +57,10 @@ void DeviceDescription::FillFromServiceDescription(
std::string key = i->substr(0, equals_pos);
std::string value = i->substr(equals_pos + 1);
if (LowerCaseEqualsASCII(key, kPrivetTxtKeyName)) {
if (LowerCaseEqualsASCII(key, kPrivetTxtKeyVersion)) {
if (!base::StringToInt(value, &version))
continue; // Unknown version.
} else if (LowerCaseEqualsASCII(key, kPrivetTxtKeyName)) {
name = value;
} else if (LowerCaseEqualsASCII(key, kPrivetTxtKeyDescription)) {
description = value;
......
......@@ -38,6 +38,7 @@ struct DeviceDescription {
std::string url;
std::string id;
std::string type;
int version;
ConnectionState connection_state;
// Attributes related to local HTTP
......
......@@ -45,6 +45,7 @@ const char kPrivetTypePrinter[] = "printer";
const char kPrivetTxtKeyName[] = "ty";
const char kPrivetTxtKeyDescription[] = "note";
const char kPrivetTxtKeyURL[] = "url";
const char kPrivetTxtKeyVersion[] = "txtvers";
const char kPrivetTxtKeyType[] = "type";
const char kPrivetTxtKeyID[] = "id";
const char kPrivetTxtKeyConnectionState[] = "cs";
......
......@@ -48,6 +48,7 @@ const double kPrivetMaximumTimeScaling = 1.2;
extern const char kPrivetTxtKeyName[];
extern const char kPrivetTxtKeyDescription[];
extern const char kPrivetTxtKeyURL[];
extern const char kPrivetTxtKeyVersion[];
extern const char kPrivetTxtKeyType[];
extern const char kPrivetTxtKeyID[];
extern const char kPrivetTxtKeyConnectionState[];
......
......@@ -6,10 +6,10 @@
namespace local_discovery {
DeviceDescription::DeviceDescription() : connection_state(UNKNOWN) {
PrivetDeviceLister::PrivetDeviceLister() {
}
DeviceDescription::~DeviceDescription() {
PrivetDeviceLister::~PrivetDeviceLister() {
}
}
} // namespace local_discovery
......@@ -17,6 +17,9 @@ namespace local_discovery {
class PrivetDeviceLister {
public:
PrivetDeviceLister();
virtual ~PrivetDeviceLister();
class Delegate {
public:
virtual void DeviceChanged(bool added,
......@@ -26,8 +29,6 @@ class PrivetDeviceLister {
virtual void DeviceCacheFlushed() = 0;
};
virtual ~PrivetDeviceLister() {}
// Start the PrivetServiceLister.
virtual void Start() = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment