Cancel the current download if user chooses a different channel.

In my earlier CL, to keep the implementation simple, we disallowed changing
a channel until the previous change completed in its entirety. Given that
the UI is not going to be updated for M27, such a restriction turned out
to be very confusing when playing around with channel changing. So, we
decided to implement a simple form of canceling the download if the
user selected a different channel while we're downloading the bits. This
implementation can easily be extended to support a general form of cancel
in the future, if required.

This CL also adds validation of libchromeos API calls when interpreting
the policy values. It also cleans up some bogus error messages that were
logged earlier when we abort a download.

BUG=chromium:222617
TEST=All scenarios pass on ZGB. Unit Tests pass.

Change-Id: I7cd691fe461d9ce47314299f6e2598944650ee33
Reviewed-on: https://gerrit.chromium.org/gerrit/46095
Commit-Queue: Jay Srinivasan <jaysri@chromium.org>
Reviewed-by: Jay Srinivasan <jaysri@chromium.org>
Tested-by: Jay Srinivasan <jaysri@chromium.org>
diff --git a/postinstall_runner_action.h b/postinstall_runner_action.h
index 9a2ebcb..6979975 100644
--- a/postinstall_runner_action.h
+++ b/postinstall_runner_action.h
@@ -29,7 +29,9 @@
 
 class PostinstallRunnerAction : public Action<PostinstallRunnerAction> {
  public:
-  PostinstallRunnerAction() {}
+  PostinstallRunnerAction()
+    : powerwash_marker_created_(false) {}
+
   typedef ActionTraits<PostinstallRunnerAction>::InputObjectType
       InputObjectType;
   typedef ActionTraits<PostinstallRunnerAction>::OutputObjectType
@@ -52,6 +54,10 @@
 
   std::string temp_rootfs_dir_;
 
+  // True if Powerwash Marker was created before invoking post-install script.
+  // False otherwise. Used for cleaning up if post-install fails.
+  bool powerwash_marker_created_;
+
   DISALLOW_COPY_AND_ASSIGN(PostinstallRunnerAction);
 };