PM: Make the connection type an enum class.

This improves type safety and encapsulation, but otherwise a superficial
syntactic substitution.

BUG=None
TEST=Unit tests.

Change-Id: I0ec880833704227cf6277ff37e37b51f8a8c5ce7
Reviewed-on: https://chromium-review.googlesource.com/189852
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/policy_manager/real_shill_provider.cc b/policy_manager/real_shill_provider.cc
index 244a059..48d01e6 100644
--- a/policy_manager/real_shill_provider.cc
+++ b/policy_manager/real_shill_provider.cc
@@ -32,11 +32,11 @@
 // ShillConnector methods.
 
 const ShillConnector::ConnStrToType ShillConnector::shill_conn_str_to_type[] = {
-  {shill::kTypeEthernet, kShillConnTypeEthernet},
-  {shill::kTypeWifi, kShillConnTypeWifi},
-  {shill::kTypeWimax, kShillConnTypeWimax},
-  {shill::kTypeBluetooth, kShillConnTypeBluetooth},
-  {shill::kTypeCellular, kShillConnTypeCellular},
+  {shill::kTypeEthernet, ConnectionType::kEthernet},
+  {shill::kTypeWifi, ConnectionType::kWifi},
+  {shill::kTypeWimax, ConnectionType::kWimax},
+  {shill::kTypeBluetooth, ConnectionType::kBluetooth},
+  {shill::kTypeCellular, ConnectionType::kCellular},
 };
 
 ShillConnector::~ShillConnector() {
@@ -76,7 +76,7 @@
 }
 
 bool ShillConnector::GetConnectionType(const string& service_path,
-                                       ShillConnType* conn_type_p) {
+                                       ConnectionType* conn_type_p) {
   // Obtain a proxy for the service path.
   DBusGProxy* service_proxy = GetProxy(service_path.c_str(),
                                        shill::kFlimflamServiceInterface);
@@ -112,12 +112,12 @@
                                 path, interface);
 }
 
-ShillConnType ShillConnector::ParseConnType(const char* str) {
+ConnectionType ShillConnector::ParseConnType(const char* str) {
   for (unsigned i = 0; i < arraysize(shill_conn_str_to_type); i++)
     if (!strcmp(str, shill_conn_str_to_type[i].str))
       return shill_conn_str_to_type[i].type;
 
-  return kShillConnTypeUnknown;
+  return ConnectionType::kUnknown;
 }
 
 bool ShillConnector::GetProperties(DBusGProxy* proxy, GHashTable** result_p) {
@@ -133,24 +133,24 @@
 
 
 // A variable returning the curent connection type.
-class ConnTypeVariable : public Variable<ShillConnType> {
+class ConnTypeVariable : public Variable<ConnectionType> {
  public:
   ConnTypeVariable(const string& name, ShillConnector* connector,
                    RealShillProvider* provider)
-      : Variable<ShillConnType>(name, kVariableModePoll),
+      : Variable<ConnectionType>(name, kVariableModePoll),
         connector_(connector), provider_(provider) {}
 
  protected:
   // TODO(garnold) Shift to a non-blocking version, respect the timeout.
-  virtual const ShillConnType* GetValue(base::TimeDelta /* timeout */,
-                                        string* errmsg) {
+  virtual const ConnectionType* GetValue(base::TimeDelta /* timeout */,
+                                         string* errmsg) {
     if (!(provider_->is_connected_)) {
       if (errmsg)
         *errmsg = "No connection detected";
       return NULL;
     }
 
-    ShillConnType conn_type;
+    ConnectionType conn_type;
     if (provider_->is_conn_type_valid_) {
       conn_type = provider_->conn_type_;
     } else {
@@ -165,7 +165,7 @@
       provider_->is_conn_type_valid_ = true;
     }
 
-    return new ShillConnType(conn_type);
+    return new ConnectionType(conn_type);
   }
 
  private: