[REFACTOR] Pass DeltaArchiveManifest to DynamicPartitionControl

DynamicPartitionControl need the list of operations to calculate
COW sizes.

- Remove BootControlInterface::PartitionMetadata. Replace all references
  with DeltaArchiveManifest. DeltaArchiveManifest has all information
  that PartitionMetadata has.
- Rename all InitPartitionMetadata to PreparePartitionsForUpdate
- Change all PreparePartitionsForUpdate to use new signature
Bug: 138816109
Test: update_enigne_unittests --gtest_filter=*BootControl*:*Dynamic*
Change-Id: I4389ba2b1801addf8c3bc8395e2ea6a9a3ed27a0
diff --git a/common/boot_control_interface.h b/common/boot_control_interface.h
index 392d785..9bf639a 100644
--- a/common/boot_control_interface.h
+++ b/common/boot_control_interface.h
@@ -25,6 +25,8 @@
 #include <base/callback.h>
 #include <base/macros.h>
 
+#include "update_engine/update_metadata.pb.h"
+
 namespace chromeos_update_engine {
 
 // The abstract boot control interface defines the interaction with the
@@ -35,19 +37,6 @@
  public:
   using Slot = unsigned int;
 
-  struct PartitionMetadata {
-    struct Partition {
-      std::string name;
-      uint64_t size;
-    };
-    struct Group {
-      std::string name;
-      uint64_t size;
-      std::vector<Partition> partitions;
-    };
-    std::vector<Group> groups;
-  };
-
   static const Slot kInvalidSlot = UINT_MAX;
 
   virtual ~BootControlInterface() = default;
@@ -67,9 +56,9 @@
   // The |slot| number must be between 0 and GetNumSlots() - 1 and the
   // |partition_name| is a platform-specific name that identifies a partition on
   // every slot. In order to access the dynamic partitions in the target slot,
-  // InitPartitionMetadata() must be called (once per payload) prior to calling
-  // this function. On success, returns true and stores the block device in
-  // |device|.
+  // PreparePartitionsForUpdate() must be called (once per payload) prior to
+  // calling this function. On success, returns true and stores the block device
+  // in |device|.
   virtual bool GetPartitionDevice(const std::string& partition_name,
                                   Slot slot,
                                   std::string* device) const = 0;
@@ -96,12 +85,11 @@
 
   // Initializes the metadata of the underlying partitions for a given |slot|
   // and sets up the states for accessing dynamic partitions.
-  // |partition_metadata| will be written to the specified |slot| if
+  // Metadata will be written to the specified |slot| if
   // |update_metadata| is set.
-  virtual bool InitPartitionMetadata(
-      Slot slot,
-      const PartitionMetadata& partition_metadata,
-      bool update_metadata) = 0;
+  virtual bool PreparePartitionsForUpdate(Slot slot,
+                                          const DeltaArchiveManifest& manifest,
+                                          bool update_metadata) = 0;
 
   // Do necessary clean-up operations after the whole update.
   virtual void Cleanup() = 0;
diff --git a/common/boot_control_stub.cc b/common/boot_control_stub.cc
index 0fe8a98..b10e82f 100644
--- a/common/boot_control_stub.cc
+++ b/common/boot_control_stub.cc
@@ -59,10 +59,8 @@
   return false;
 }
 
-bool BootControlStub::InitPartitionMetadata(
-    Slot slot,
-    const PartitionMetadata& partition_metadata,
-    bool update_metadata) {
+bool BootControlStub::PreparePartitionsForUpdate(
+    Slot slot, const DeltaArchiveManifest& manifest, bool update_metadata) {
   LOG(ERROR) << __FUNCTION__ << " should never be called.";
   return false;
 }
diff --git a/common/boot_control_stub.h b/common/boot_control_stub.h
index 8dfaffc..f2973a2 100644
--- a/common/boot_control_stub.h
+++ b/common/boot_control_stub.h
@@ -45,9 +45,9 @@
   bool MarkSlotUnbootable(BootControlInterface::Slot slot) override;
   bool SetActiveBootSlot(BootControlInterface::Slot slot) override;
   bool MarkBootSuccessfulAsync(base::Callback<void(bool)> callback) override;
-  bool InitPartitionMetadata(Slot slot,
-                             const PartitionMetadata& partition_metadata,
-                             bool update_metadata) override;
+  bool PreparePartitionsForUpdate(Slot slot,
+                                  const DeltaArchiveManifest& manifest,
+                                  bool update_metadata) override;
   void Cleanup() override;
 
  private:
diff --git a/common/fake_boot_control.h b/common/fake_boot_control.h
index 3d65075..11810d1 100644
--- a/common/fake_boot_control.h
+++ b/common/fake_boot_control.h
@@ -74,9 +74,9 @@
     return true;
   }
 
-  bool InitPartitionMetadata(Slot slot,
-                             const PartitionMetadata& partition_metadata,
-                             bool update_metadata) override {
+  bool PreparePartitionsForUpdate(Slot slot,
+                                  const DeltaArchiveManifest& manifest,
+                                  bool update_metadata) override {
     return true;
   }