Observe devices in NetworkStateHandler

This includes a bit of cleanup to NetworkStateHandler and ShillPropertyHandler.

I made ShillServicePropertyObserver support devices, renamed it 
ShillPropertyObserver, and moved it into ShillPropertyHandler since:
 a) naming it would be challenging without context
 b) It doesn't really do much, so if we want something similar (e.g. in NetworkConfigurationHandler) it will be easier just to copy/paste the code we need

BUG=161869


Review URL: https://chromiumcodereview.appspot.com/12211051

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181254 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chromeos/network/shill_property_handler_unittest.cc b/chromeos/network/shill_property_handler_unittest.cc
index 9f6e6098e..d660d00 100644
--- a/chromeos/network/shill_property_handler_unittest.cc
+++ b/chromeos/network/shill_property_handler_unittest.cc
@@ -39,16 +39,6 @@
     UpdateEntries(GetTypeString(type), entries);
   }
 
-  virtual void UpdateAvailableTechnologies(
-      const base::ListValue& technologies) OVERRIDE {
-    UpdateEntries(flimflam::kAvailableTechnologiesProperty, technologies);
-  }
-
-  virtual void UpdateEnabledTechnologies(
-      const base::ListValue& technologies) OVERRIDE {
-    UpdateEntries(flimflam::kEnabledTechnologiesProperty, technologies);
-  }
-
   virtual void UpdateManagedStateProperties(
       ManagedState::ManagedType type,
       const std::string& path,
@@ -63,6 +53,13 @@
     AddPropertyUpdate(flimflam::kServicesProperty, service_path);
   }
 
+  virtual void UpdateDeviceProperty(
+      const std::string& device_path,
+      const std::string& key,
+      const base::Value& value) OVERRIDE {
+    AddPropertyUpdate(flimflam::kDevicesProperty, device_path);
+  }
+
   virtual void ManagerPropertyChanged() OVERRIDE {
     ++manager_updates_;
   }
@@ -228,13 +225,10 @@
   EXPECT_EQ(1, listener_->manager_updates());
   // ShillManagerClient default stub entries are in shill_manager_client.cc.
   // TODO(stevenjb): Eliminate default stub entries and add them explicitly.
-  const size_t kNumShillManagerClientStubImplTechnologies = 3;
-  EXPECT_EQ(kNumShillManagerClientStubImplTechnologies,
-            listener_->entries(
-                flimflam::kAvailableTechnologiesProperty).size());
-  EXPECT_EQ(kNumShillManagerClientStubImplTechnologies,
-            listener_->entries(
-                flimflam::kEnabledTechnologiesProperty).size());
+  EXPECT_TRUE(shill_property_handler_->TechnologyAvailable(
+      flimflam::kTypeWifi));
+  EXPECT_TRUE(shill_property_handler_->TechnologyEnabled(
+      flimflam::kTypeWifi));
   const size_t kNumShillManagerClientStubImplDevices = 2;
   EXPECT_EQ(kNumShillManagerClientStubImplDevices,
             listener_->entries(flimflam::kDevicesProperty).size());
@@ -254,22 +248,19 @@
   manager_test_->AddTechnology(flimflam::kTypeWimax, false);
   message_loop_.RunUntilIdle();
   EXPECT_EQ(2, listener_->manager_updates());
-  const size_t kNumShillManagerClientStubImplTechnologies = 3;
-  EXPECT_EQ(kNumShillManagerClientStubImplTechnologies + 1,
-            listener_->entries(
-                flimflam::kAvailableTechnologiesProperty).size());
-  EXPECT_EQ(kNumShillManagerClientStubImplTechnologies,
-            listener_->entries(
-                flimflam::kEnabledTechnologiesProperty).size());
+  EXPECT_TRUE(shill_property_handler_->TechnologyAvailable(
+      flimflam::kTypeWimax));
+  EXPECT_FALSE(shill_property_handler_->TechnologyEnabled(
+      flimflam::kTypeWimax));
+
   // Enable the technology.
   DBusThreadManager::Get()->GetShillManagerClient()->EnableTechnology(
       flimflam::kTypeWimax,
       base::Bind(&base::DoNothing), base::Bind(&ErrorCallbackFunction));
   message_loop_.RunUntilIdle();
   EXPECT_EQ(3, listener_->manager_updates());
-  EXPECT_EQ(kNumShillManagerClientStubImplTechnologies + 1,
-            listener_->entries(
-                flimflam::kEnabledTechnologiesProperty).size());
+  EXPECT_TRUE(shill_property_handler_->TechnologyEnabled(
+      flimflam::kTypeWimax));
 
   EXPECT_EQ(0, listener_->errors());
 }
@@ -318,7 +309,8 @@
              flimflam::kStateIdle, false);
   message_loop_.RunUntilIdle();
   EXPECT_EQ(1, listener_->manager_updates());  // No new manager updates.
-  EXPECT_EQ(2, listener_->list_updates(flimflam::kServicesProperty));
+  // Only watched services trigger a service list update.
+  EXPECT_EQ(1, listener_->list_updates(flimflam::kServicesProperty));
   EXPECT_EQ(kNumShillManagerClientStubImplServices + 1,
             listener_->entries(flimflam::kServicesProperty).size());
   // Change a property.
@@ -338,7 +330,7 @@
              flimflam::kStateIdle, true);
   message_loop_.RunUntilIdle();
   // Service list update should be received when watch list changes.
-  EXPECT_EQ(3, listener_->list_updates(flimflam::kServicesProperty));
+  EXPECT_EQ(2, listener_->list_updates(flimflam::kServicesProperty));
   // Number of services shouldn't change.
   EXPECT_EQ(kNumShillManagerClientStubImplServices + 1,
             listener_->entries(flimflam::kServicesProperty).size());
@@ -360,7 +352,7 @@
   // Remove a service
   RemoveService(kTestServicePath);
   message_loop_.RunUntilIdle();
-  EXPECT_EQ(4, listener_->list_updates(flimflam::kServicesProperty));
+  EXPECT_EQ(3, listener_->list_updates(flimflam::kServicesProperty));
   EXPECT_EQ(kNumShillManagerClientStubImplServices,
             listener_->entries(flimflam::kServicesProperty).size());