3G: Add ability to ignore an error that occurs during asynchronous calls.

Shill performs several tasks when stopping a modem.  The first task is
to disconnect.  This task fails if the modem is not currently connected.
However, we still want to process the remaining tasks.  This CL adds the
ability to ignore errors at any particular task to allow execution of
susbsequent tasks.  Existing code that ignored errors in the callback
has been migrated to use this new mechanism.  This CL also moves the
StopModem() implementation into the base class CellularCapability.

BUG=chromium-os:28862
TEST=Unit tests, manually enable/disable cellular on device

Change-Id: I772a732c1fbcea9042328fcb10884ee2e9706a46
Reviewed-on: https://gerrit.chromium.org/gerrit/19781
Reviewed-by: Gary Morain <gmorain@chromium.org>
Commit-Ready: Thieu Le <thieule@chromium.org>
Reviewed-by: Thieu Le <thieule@chromium.org>
Tested-by: Thieu Le <thieule@chromium.org>
diff --git a/cellular_capability.h b/cellular_capability.h
index 0234b8e..ef0060f 100644
--- a/cellular_capability.h
+++ b/cellular_capability.h
@@ -72,9 +72,10 @@
   // have been completed, at which point StartModem() is finished.
   virtual void StartModem(Error *error,
                           const ResultCallback &callback) = 0;
-  // StopModem is also a multi-step operation consisting of several
-  // non-blocking calls.
-  virtual void StopModem(Error *error, const ResultCallback &callback) = 0;
+  // StopModem disconnects and disables a modem asynchronously.
+  // |callback| is invoked when this completes and the result is passed
+  // to the callback.
+  virtual void StopModem(Error *error, const ResultCallback &callback);
   virtual void Connect(const DBusPropertiesMap &properties, Error *error,
                        const ResultCallback &callback);
   virtual void Disconnect(Error *error, const ResultCallback &callback);
@@ -145,7 +146,13 @@
   // Run the next task in a list.
   // Precondition: |tasks| is not empty.
   void RunNextStep(CellularTaskList *tasks);
-  void StepCompletedCallback(const ResultCallback &callback,
+  // StepCompletedCallback is called after a task completes.
+  // |callback| is the original callback that needs to be invoked when all of
+  // the tasks complete or if there is a failure.  |ignore_error| will be set
+  // to true if the next task should be run regardless of the result of the
+  // just-completed task.  |tasks| is the list of tasks remaining.  |error| is
+  // the result of the just-completed task.
+  void StepCompletedCallback(const ResultCallback &callback, bool ignore_error,
                              CellularTaskList *tasks, const Error &error);
   // Properties
   bool allow_roaming_;
@@ -163,8 +170,9 @@
   std::string hardware_revision_;
 
  private:
-  friend class CellularTest;
+  friend class CellularCapabilityGSMTest;
   friend class CellularCapabilityTest;
+  friend class CellularTest;
   FRIEND_TEST(CellularCapabilityGSMTest, SetStorageIdentifier);
   FRIEND_TEST(CellularCapabilityGSMTest, UpdateStatus);
   FRIEND_TEST(CellularCapabilityTest, AllowRoaming);