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

Unified Diff: net/nqe/network_id.h

Issue 2369673004: Wire NQE Prefs to Profile (Closed)
Patch Set: Added functionality for reading and writing multiple network IDs, Rebased, Addressed Ryan's comments Created 4 years, 2 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: 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;

Powered by Google App Engine
This is Rietveld 408576698