shill: Avoid double gets of property store values when iterating.

Cleanup and simplify the property iterator classes by removing the
unused PropertyConstIterator class and caching the property
value. This way we avoid deriving property values twice when iterating
through properties. Also, remove some incorrect and unused logic in
the PropertyStoreInspector related to handling errors coming from the
property store iterators.

BUG=chromium-os:30373
TEST=unit tests

Change-Id: Ie6ba2696f070e1ed43997f17273f48360f85055b
Reviewed-on: https://gerrit.chromium.org/gerrit/24201
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/property_store_unittest.cc b/property_store_unittest.cc
index f69107a..15039fc 100644
--- a/property_store_unittest.cc
+++ b/property_store_unittest.cc
@@ -230,7 +230,6 @@
   // Test that properties registered as write-only are not returned
   // when using Get*PropertiesIter().
   PropertyStore store;
-  Error error;
   {
     const string keys[]  = {"boolp1", "boolp2"};
     bool values[] = {true, true};
@@ -238,11 +237,9 @@
     store.RegisterBool(keys[1], &values[1]);
 
     ReadablePropertyConstIterator<bool> it = store.GetBoolPropertiesIter();
-    error.Reset();
     EXPECT_FALSE(it.AtEnd());
     EXPECT_EQ(keys[1], it.Key());
-    EXPECT_TRUE(values[1] == it.Value(&error));
-    EXPECT_TRUE(error.IsSuccess());
+    EXPECT_TRUE(values[1] == it.value());
     it.Advance();
     EXPECT_TRUE(it.AtEnd());
   }
@@ -253,11 +250,9 @@
     store.RegisterInt16(keys[1], &values[1]);
 
     ReadablePropertyConstIterator<int16> it = store.GetInt16PropertiesIter();
-    error.Reset();
     EXPECT_FALSE(it.AtEnd());
     EXPECT_EQ(keys[1], it.Key());
-    EXPECT_EQ(values[1], it.Value(&error));
-    EXPECT_TRUE(error.IsSuccess());
+    EXPECT_EQ(values[1], it.value());
     it.Advance();
     EXPECT_TRUE(it.AtEnd());
   }
@@ -268,11 +263,9 @@
     store.RegisterInt32(keys[1], &values[1]);
 
     ReadablePropertyConstIterator<int32> it = store.GetInt32PropertiesIter();
-    error.Reset();
     EXPECT_FALSE(it.AtEnd());
     EXPECT_EQ(keys[1], it.Key());
-    EXPECT_EQ(values[1], it.Value(&error));
-    EXPECT_TRUE(error.IsSuccess());
+    EXPECT_EQ(values[1], it.value());
     it.Advance();
     EXPECT_TRUE(it.AtEnd());
   }
@@ -283,11 +276,9 @@
     store.RegisterString(keys[1], &values[1]);
 
     ReadablePropertyConstIterator<string> it = store.GetStringPropertiesIter();
-    error.Reset();
     EXPECT_FALSE(it.AtEnd());
     EXPECT_EQ(keys[1], it.Key());
-    EXPECT_EQ(values[1], it.Value(&error));
-    EXPECT_TRUE(error.IsSuccess());
+    EXPECT_EQ(values[1], it.value());
     it.Advance();
     EXPECT_TRUE(it.AtEnd());
   }
@@ -301,11 +292,9 @@
 
     ReadablePropertyConstIterator<Stringmap> it =
         store.GetStringmapPropertiesIter();
-    error.Reset();
     EXPECT_FALSE(it.AtEnd());
     EXPECT_EQ(keys[1], it.Key());
-    EXPECT_TRUE(values[1] == it.Value(&error));
-    EXPECT_TRUE(error.IsSuccess());
+    EXPECT_TRUE(values[1] == it.value());
     it.Advance();
     EXPECT_TRUE(it.AtEnd());
   }
@@ -323,11 +312,9 @@
 
     ReadablePropertyConstIterator<Stringmaps> it =
         store.GetStringmapsPropertiesIter();
-    error.Reset();
     EXPECT_FALSE(it.AtEnd());
     EXPECT_EQ(keys[1], it.Key());
-    EXPECT_TRUE(values[1] == it.Value(&error));
-    EXPECT_TRUE(error.IsSuccess());
+    EXPECT_TRUE(values[1] == it.value());
     it.Advance();
     EXPECT_TRUE(it.AtEnd());
   }
@@ -344,11 +331,9 @@
 
     ReadablePropertyConstIterator<Strings> it =
         store.GetStringsPropertiesIter();
-    error.Reset();
     EXPECT_FALSE(it.AtEnd());
     EXPECT_EQ(keys[1], it.Key());
-    EXPECT_TRUE(values[1] == it.Value(&error));
-    EXPECT_TRUE(error.IsSuccess());
+    EXPECT_TRUE(values[1] == it.value());
     it.Advance();
     EXPECT_TRUE(it.AtEnd());
   }
@@ -359,11 +344,9 @@
     store.RegisterUint8(keys[1], &values[1]);
 
     ReadablePropertyConstIterator<uint8> it = store.GetUint8PropertiesIter();
-    error.Reset();
     EXPECT_FALSE(it.AtEnd());
     EXPECT_EQ(keys[1], it.Key());
-    EXPECT_EQ(values[1], it.Value(&error));
-    EXPECT_TRUE(error.IsSuccess());
+    EXPECT_EQ(values[1], it.value());
     it.Advance();
     EXPECT_TRUE(it.AtEnd());
   }
@@ -374,11 +357,9 @@
     store.RegisterUint16(keys[1], &values[1]);
 
     ReadablePropertyConstIterator<uint16> it = store.GetUint16PropertiesIter();
-    error.Reset();
     EXPECT_FALSE(it.AtEnd());
     EXPECT_EQ(keys[1], it.Key());
-    EXPECT_EQ(values[1], it.Value(&error));
-    EXPECT_TRUE(error.IsSuccess());
+    EXPECT_EQ(values[1], it.value());
     it.Advance();
     EXPECT_TRUE(it.AtEnd());
   }