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_gsm.cc b/cellular_capability_gsm.cc
index 51f80f3..bfda762 100644
--- a/cellular_capability_gsm.cc
+++ b/cellular_capability_gsm.cc
@@ -115,7 +115,10 @@
   CellularTaskList *tasks = new CellularTaskList();
   ResultCallback cb =
       Bind(&CellularCapabilityGSM::StepCompletedCallback,
-           weak_ptr_factory_.GetWeakPtr(), callback, tasks);
+           weak_ptr_factory_.GetWeakPtr(), callback, false, tasks);
+  ResultCallback cb_ignore_error =
+        Bind(&CellularCapabilityGSM::StepCompletedCallback,
+                   weak_ptr_factory_.GetWeakPtr(), callback, true, tasks);
   tasks->push_back(Bind(&CellularCapabilityGSM::EnableModem,
                         weak_ptr_factory_.GetWeakPtr(), cb));
   tasks->push_back(Bind(&CellularCapabilityGSM::Register,
@@ -127,9 +130,9 @@
   tasks->push_back(Bind(&CellularCapabilityGSM::GetIMSI,
                         weak_ptr_factory_.GetWeakPtr(), cb));
   tasks->push_back(Bind(&CellularCapabilityGSM::GetSPN,
-                        weak_ptr_factory_.GetWeakPtr(), cb));
+                        weak_ptr_factory_.GetWeakPtr(), cb_ignore_error));
   tasks->push_back(Bind(&CellularCapabilityGSM::GetMSISDN,
-                        weak_ptr_factory_.GetWeakPtr(), cb));
+                        weak_ptr_factory_.GetWeakPtr(), cb_ignore_error));
   tasks->push_back(Bind(&CellularCapabilityGSM::GetProperties,
                         weak_ptr_factory_.GetWeakPtr(), cb));
   tasks->push_back(Bind(&CellularCapabilityGSM::GetModemInfo,
@@ -140,25 +143,6 @@
   RunNextStep(tasks);
 }
 
-void CellularCapabilityGSM::StopModem(Error *error,
-                                      const ResultCallback &callback) {
-  VLOG(2) << __func__;
-
-  CellularTaskList *tasks = new CellularTaskList();
-  ResultCallback cb =
-      Bind(&CellularCapabilityGSM::StepCompletedCallback,
-           weak_ptr_factory_.GetWeakPtr(), callback, tasks);
-  tasks->push_back(Bind(&CellularCapabilityGSM::Disconnect,
-                        weak_ptr_factory_.GetWeakPtr(),
-                        static_cast<Error *>(NULL), cb));
-  tasks->push_back(Bind(&CellularCapabilityGSM::DisableModem,
-                        weak_ptr_factory_.GetWeakPtr(), cb));
-  tasks->push_back(Bind(&CellularCapabilityGSM::FinishDisable,
-                        weak_ptr_factory_.GetWeakPtr(), cb));
-
-  RunNextStep(tasks);
-}
-
 void CellularCapabilityGSM::ReleaseProxies() {
   VLOG(2) << __func__;
   CellularCapability::ReleaseProxies();
@@ -808,8 +792,7 @@
   } else {
     VLOG(2) << "GetSPN failed - " << error;
   }
-  // Ignore the error - it's not fatal.
-  callback.Run(Error());
+  callback.Run(error);
 }
 
 void CellularCapabilityGSM::OnGetMSISDNReply(const ResultCallback &callback,
@@ -821,8 +804,7 @@
   } else {
     VLOG(2) << "GetMSISDN failed - " << error;
   }
-  // Ignore the error - it's not fatal.
-  callback.Run(Error());
+  callback.Run(error);
 }
 
 }  // namespace shill