Classify errors and advance URL index according to the error code.

In CL https://gerrit.chromium.org/gerrit/39638, we always incremented
the URL index irrespective of the error code. That would cause the first
URL to be given up too quickly in favor of the second one even for
transient errors such as when user closes a lid and reopens after some
time.

The right behavior in this case is to just count those failures towards
the URL and only after repeated failures with no progress should we
advance the URL index.

This CL implements this logic and completes the multiple URL-related
work items outlined in the design doc.

BUG=chromium-os:37206
TEST=Tested all uses cases on my ZGB. Added and updated unit tests.

Change-Id: Ida0cfbfeb9bfab732144049d1b27e3b8958bc252
Reviewed-on: https://gerrit.chromium.org/gerrit/39885
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/system_state.h b/system_state.h
index 04ad382..4dee1eb 100644
--- a/system_state.h
+++ b/system_state.h
@@ -44,8 +44,8 @@
   // Gets the interface object for persisted store.
   virtual PrefsInterface* prefs() = 0;
 
-  // Gets the URL State object.
-  virtual PayloadState* payload_state() = 0;
+  // Gets the interface for the payload state object.
+  virtual PayloadStateInterface* payload_state() = 0;
 };
 
 // A real implementation of the SystemStateInterface which is
@@ -58,16 +58,30 @@
 
   virtual bool IsOOBEComplete();
 
-  virtual void set_device_policy(const policy::DevicePolicy* device_policy);
-  virtual const policy::DevicePolicy* device_policy() const;
+  virtual inline void set_device_policy(
+      const policy::DevicePolicy* device_policy) {
+    device_policy_ = device_policy;
+  }
 
-  virtual ConnectionManager* connection_manager();
+  virtual inline const policy::DevicePolicy* device_policy() const {
+    return device_policy_;
+  }
 
-  virtual MetricsLibraryInterface* metrics_lib();
+  virtual inline ConnectionManager* connection_manager() {
+    return &connection_manager_;
+  }
 
-  virtual PrefsInterface* prefs();
+  virtual inline MetricsLibraryInterface* metrics_lib() {
+    return &metrics_lib_;
+  }
 
-  virtual PayloadState* payload_state();
+  virtual inline PrefsInterface* prefs() {
+    return &prefs_;
+  }
+
+  virtual inline PayloadStateInterface* payload_state() {
+    return &payload_state_;
+  }
 
   // Initializs this concrete object. Other methods should be invoked only
   // if the object has been initialized successfully.