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

Unified Diff: chromeos/network/shill_property_util.h

Issue 23712002: Cleanup network type matching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Generalized network type matching. Created 7 years, 3 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: chromeos/network/shill_property_util.h
diff --git a/chromeos/network/shill_property_util.h b/chromeos/network/shill_property_util.h
index 13d16a86f93f93eb8223cf03f43198ce8df8fa01..cf16efbf8a8a778a4a4db2a5f9770d88504df0c9 100644
--- a/chromeos/network/shill_property_util.h
+++ b/chromeos/network/shill_property_util.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/memory/scoped_ptr.h"
+#include "chromeos/chromeos_export.h"
namespace base {
class DictionaryValue;
@@ -49,6 +50,53 @@ bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
} // namespace shill_property_util
+class CHROMEOS_EXPORT NetworkTypePattern {
+ public:
+ // Matches any network.
+ static NetworkTypePattern Default();
+
+ // Matches wireless networks
+ static NetworkTypePattern Wireless();
+
+ // Matches cellular or wimax networks.
+ static NetworkTypePattern Mobile();
+
+ // Matches non virtual networks.
+ static NetworkTypePattern NonVirtual();
+
+ // Matches ethernet networks (with or without EAP).
+ static NetworkTypePattern Ethernet();
+
+ static NetworkTypePattern WiFi();
+ static NetworkTypePattern Cellular();
+ static NetworkTypePattern VPN();
+ static NetworkTypePattern Wimax();
+
+ // Matches only networks of exactly the type |shill_network_type|, which must
+ // be one of the types defined in service_constants.h (e.g.
+ // flimflam::kTypeWifi).
+ // Note: Shill distinguishes Ethernet without EAP from Ethernet with EAP. If
+ // unsure, better use one of the matchers above.
+ static NetworkTypePattern Primitive(const std::string& shill_network_type);
+
+ bool Equals(const NetworkTypePattern& other) const;
+ bool Matches(const std::string& shill_network_type) const;
+
+ // Returns true if this pattern matches every network type that |subpattern|
+ // matches.
+ bool ContainsPattern(const NetworkTypePattern& subpattern) const;
+
+ std::string ToDebugString() const;
+
+ private:
+ explicit NetworkTypePattern(int pattern);
+
+ // The bit array of the matching network types.
+ int pattern_;
+
+ DISALLOW_ASSIGN(NetworkTypePattern);
+};
+
} // namespace chromeos
#endif // CHROMEOS_NETWORK_SHILL_PROPERTY_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698