Index: net/nqe/network_id.h |
diff --git a/net/nqe/network_id.h b/net/nqe/network_id.h |
index 4620ce3bd92b9f81ad5804cf810149aba8a4368e..9ca1e8c3a48dd505d15a336e0afc1f2960d0c72e 100644 |
--- a/net/nqe/network_id.h |
+++ b/net/nqe/network_id.h |
@@ -26,11 +26,30 @@ namespace internal { |
// same name (e.g., different Wi-Fi networks with same SSID). |
// This is a protected member to expose it to tests. |
struct NET_EXPORT_PRIVATE NetworkID { |
+ static NetworkID FromString(const std::string& network_id) { |
+ size_t separator_index = network_id.find(kValueSeparator); |
+ DCHECK_NE(std::string::npos, separator_index); |
+ if (separator_index == std::string::npos) { |
+ return NetworkID(NetworkChangeNotifier::CONNECTION_UNKNOWN, |
+ std::string()); |
+ } |
+ return NetworkID(NetworkChangeNotifier::StringToConnectionType( |
+ network_id.substr(separator_index + 1)), |
+ network_id.substr(0, separator_index)); |
+ } |
NetworkID(NetworkChangeNotifier::ConnectionType type, const std::string& id) |
: type(type), id(id) {} |
NetworkID(const NetworkID& other) : type(other.type), id(other.id) {} |
~NetworkID() {} |
+ bool operator==(const NetworkID& other) const { |
+ return type == other.type && id == other.id; |
+ } |
+ |
+ bool operator!=(const NetworkID& other) const { |
+ return type != other.type || id != other.id; |
RyanSturm
2016/10/12 21:33:34
maybe something like this:
return !operator==(oth
tbansal1
2016/10/12 22:04:01
Done.
|
+ } |
+ |
NetworkID& operator=(const NetworkID& other) { |
type = other.type; |
id = other.id; |