AU: Split applied update verification into a separate step.

Use instances of FilesystemCopierAction to do applied update verification. This
speeds it up slightly because asynchronous reads happen in parallel with hash
calculation but, more importantly, makes update_engine be responsive to D-Bus
during that step.

BUG=9140
TEST=unit tests, tested on device

Change-Id: I3ec9445de5e8258a63433a61f1a476aef4434f6c

Review URL: http://codereview.chromium.org/5516009
diff --git a/filesystem_copier_action.h b/filesystem_copier_action.h
index 6dbde41..0658597 100644
--- a/filesystem_copier_action.h
+++ b/filesystem_copier_action.h
@@ -37,7 +37,8 @@
 
 class FilesystemCopierAction : public Action<FilesystemCopierAction> {
  public:
-  explicit FilesystemCopierAction(bool copying_kernel_install_path);
+  FilesystemCopierAction(bool copying_kernel_install_path,
+                         bool verify_hash);
 
   typedef ActionTraits<FilesystemCopierAction>::InputObjectType
   InputObjectType;
@@ -58,7 +59,8 @@
   FRIEND_TEST(FilesystemCopierActionTest, RunAsRootDetermineFilesystemSizeTest);
 
   // Ping-pong buffers generally cycle through the following states:
-  // Empty->Reading->Full->Writing->Empty.
+  // Empty->Reading->Full->Writing->Empty. In hash verification mode the state
+  // is never set to Writing.
   enum BufferState {
     kBufferStateEmpty,
     kBufferStateReading,
@@ -82,23 +84,24 @@
   void SpawnAsyncActions();
 
   // Cleans up all the variables we use for async operations and tells the
-  // ActionProcessor we're done w/ success as passed in. |cancelled_| should be
+  // ActionProcessor we're done w/ |code| as passed in. |cancelled_| should be
   // true if TerminateProcessing() was called.
-  void Cleanup(bool success);
+  void Cleanup(ActionExitCode code);
 
   // Determine, if possible, the source file system size to avoid copying the
   // whole partition. Currently this supports only the root file system assuming
   // it's ext3-compatible.
   void DetermineFilesystemSize(int fd);
 
-  // Returns the number of bytes to read based on the size of the buffer and the
-  // filesystem size.
-  int64_t GetBytesToRead();
-
   // If true, this action is copying to the kernel_install_path from
   // the install plan, otherwise it's copying just to the install_path.
   const bool copying_kernel_install_path_;
 
+  // If true, this action is running in applied update hash verification mode --
+  // it computes a hash for the target install path and compares it against the
+  // expected value.
+  const bool verify_hash_;
+
   // The path to copy from. If empty (the default), the source is from the
   // passed in InstallPlan.
   std::string copy_source_;