shill: Implement Manager::CalculateState

If at least one service is connected, Manager::CalculateState
returns "online"; otherwise, if returns "offline".

BUG=chromium-os:23338
TEST=Added new unit tests Manager.CalculateStateOffline and
Manager.CalculateStateOnline.  All other unit tests pass.

Change-Id: I5b45df7c08cb30ea0954d7bd97941bc5221ed717
Reviewed-on: https://gerrit.chromium.org/gerrit/19804
Commit-Ready: Gary Morain <gmorain@chromium.org>
Reviewed-by: Gary Morain <gmorain@chromium.org>
Tested-by: Gary Morain <gmorain@chromium.org>
diff --git a/manager.h b/manager.h
index 53dd223..193eebc 100644
--- a/manager.h
+++ b/manager.h
@@ -180,6 +180,8 @@
   friend class ManagerTest;
   friend class WiFiMainTest;
   FRIEND_TEST(ManagerTest, AvailableTechnologies);
+  FRIEND_TEST(ManagerTest, CalculateStateOffline);
+  FRIEND_TEST(ManagerTest, CalculateStateOnline);
   FRIEND_TEST(ManagerTest, ConnectedTechnologies);
   FRIEND_TEST(ManagerTest, DefaultTechnology);
   FRIEND_TEST(ManagerTest, DeviceRegistrationAndStart);
@@ -254,6 +256,8 @@
   bool connect_profiles_to_rpc_;
   std::vector<DeviceRefPtr> devices_;
   // We store Services in a vector, because we want to keep them sorted.
+  // Services that are connected appear first in the vector.  See
+  // Service::Compare() for details of the sorting criteria.
   std::vector<ServiceRefPtr> services_;
   // List of startup profile names to push on the profile stack on startup.
   std::vector<std::string> startup_profiles_;