AU: Start checkpointing update progress.

Checkpoint the manifest metadata size and the update
check response hash in the preference store. Also checkpoint
the next operation and data offset.
Add methods for getting/setting hash context.

BUG=7390,7394
TEST=unit tests

Change-Id: I25291bf598ac9b0f1033e11cfe59df45b1f6eeab

Review URL: http://codereview.chromium.org/3521016
diff --git a/omaha_response_handler_action.cc b/omaha_response_handler_action.cc
index 75776ab..cdcf735 100644
--- a/omaha_response_handler_action.cc
+++ b/omaha_response_handler_action.cc
@@ -1,22 +1,20 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #include "update_engine/omaha_response_handler_action.h"
+
 #include <string>
+
+#include <base/logging.h>
+
+#include "update_engine/prefs_interface.h"
 #include "update_engine/utils.h"
 
 using std::string;
 
 namespace chromeos_update_engine {
 
-namespace {
-// If the file part of the download URL contains kFullUpdateTag, then and
-// only then do we assume it's a full update. Otherwise, we assume it's a
-// delta update.
-const string kFullUpdateTag = "_FULL_";
-}  // namespace
-
 void OmahaResponseHandlerAction::PerformAction() {
   CHECK(HasInputObject());
   ScopedActionCompleter completer(processor_, this);
@@ -29,6 +27,12 @@
   install_plan_.download_url = response.codebase;
   install_plan_.size = response.size;
   install_plan_.download_hash = response.hash;
+  // TODO(petkov): Decide here if this is going to be a regular update or
+  // resume-after-boot. This should also set the number of ops performed so far
+  // to invalid if no need to resume.
+  LOG_IF(WARNING, !prefs_->SetString(kPrefsUpdateCheckResponseHash,
+                                     response.hash))
+      << "Unable to save the update check response hash.";
   TEST_AND_RETURN(GetInstallDev(
       (!boot_device_.empty() ? boot_device_ : utils::BootDevice()),
       &install_plan_.install_path));