AU: DeltaPerformer performs the download size/hash check now.

DownloadAction still calculates a hash in this case, however,
we can remove it when we remove old-style download support.

BUG=7393
TEST=unit tests, gmerge on device and updated with signed load,
with different download size/hash.

Change-Id: I5af9a09f87264159fc55070735463ad920fd7373

Review URL: http://codereview.chromium.org/3547019
diff --git a/download_action.cc b/download_action.cc
index 4462ab8..b88e448 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -140,23 +140,28 @@
   ActionExitCode code =
       successful ? kActionCodeSuccess : kActionCodeDownloadTransferError;
   if (code == kActionCodeSuccess) {
-    // Makes sure the hash and size are correct.
-    omaha_hash_calculator_.Finalize();
-    if (omaha_hash_calculator_.hash() != install_plan_.download_hash) {
-      LOG(ERROR) << "Download of " << install_plan_.download_url
-                 << " failed. Expected hash " << install_plan_.download_hash
-                 << " but got hash " << omaha_hash_calculator_.hash();
-      code = kActionCodeDownloadHashMismatchError;
-    } else if (bytes_received_ != install_plan_.size) {
-      LOG(ERROR) << "Download of " << install_plan_.download_url
-                 << " failed. Expected size " << install_plan_.size
-                 << " but got size " << bytes_received_;
-      code = kActionCodeDownloadSizeMismatchError;
-    } else if (!install_plan_.is_full_update &&
-               !delta_performer_->VerifyPayload("")) {
-      LOG(ERROR) << "Download of " << install_plan_.download_url
-                 << " failed due to payload verification error.";
-      code = kActionCodeDownloadPayloadVerificationError;
+    if (!install_plan_.is_full_update) {
+      if (!delta_performer_->VerifyPayload("",
+                                           install_plan_.download_hash,
+                                           install_plan_.size)) {
+        LOG(ERROR) << "Download of " << install_plan_.download_url
+                   << " failed due to payload verification error.";
+        code = kActionCodeDownloadPayloadVerificationError;
+      }
+    } else {
+      // Makes sure the hash and size are correct for an old-style full update.
+      omaha_hash_calculator_.Finalize();
+      if (omaha_hash_calculator_.hash() != install_plan_.download_hash) {
+        LOG(ERROR) << "Download of " << install_plan_.download_url
+                   << " failed. Expected hash " << install_plan_.download_hash
+                   << " but got hash " << omaha_hash_calculator_.hash();
+        code = kActionCodeDownloadHashMismatchError;
+      } else if (bytes_received_ != install_plan_.size) {
+        LOG(ERROR) << "Download of " << install_plan_.download_url
+                   << " failed. Expected size " << install_plan_.size
+                   << " but got size " << bytes_received_;
+        code = kActionCodeDownloadSizeMismatchError;
+      }
     }
   }