update_engine: Split Extent utils from graph_utils.

"Graph" related utils should only concern parts of the code using the
inplace generator, since other generators don't use a dependency graph.

This patch splits the Extent related utils from the graph related ones
creating a new extent_utils.h file.

BUG=None
TEST=unittest still pass.

Change-Id: I0941698b0a47a6cc222e8dc062fc54eb3cdf4de2
Reviewed-on: https://chromium-review.googlesource.com/274899
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/payload_generator/graph_utils.cc b/payload_generator/graph_utils.cc
index 3f9b28f..7b03236 100644
--- a/payload_generator/graph_utils.cc
+++ b/payload_generator/graph_utils.cc
@@ -13,6 +13,7 @@
 
 #include "update_engine/payload_constants.h"
 #include "update_engine/payload_generator/annotated_operation.h"
+#include "update_engine/payload_generator/extent_utils.h"
 
 using std::make_pair;
 using std::pair;
@@ -20,7 +21,6 @@
 using std::vector;
 
 namespace chromeos_update_engine {
-
 namespace graph_utils {
 
 uint64_t EdgeWeight(const Graph& graph, const Edge& edge) {
@@ -35,24 +35,6 @@
   return weight;
 }
 
-void AppendBlockToExtents(vector<Extent>* extents, uint64_t block) {
-  // First try to extend the last extent in |extents|, if any.
-  if (!extents->empty()) {
-    Extent& extent = extents->back();
-    uint64_t next_block = extent.start_block() == kSparseHole ?
-        kSparseHole : extent.start_block() + extent.num_blocks();
-    if (next_block == block) {
-      extent.set_num_blocks(extent.num_blocks() + 1);
-      return;
-    }
-  }
-  // If unable to extend the last extent, append a new single-block extent.
-  Extent new_extent;
-  new_extent.set_start_block(block);
-  new_extent.set_num_blocks(1);
-  extents->push_back(new_extent);
-}
-
 void AddReadBeforeDep(Vertex* src,
                       Vertex::Index dst,
                       uint64_t block) {
@@ -106,15 +88,6 @@
   }
 }
 
-Extent GetElement(const vector<Extent>& collection, size_t index) {
-  return collection[index];
-}
-Extent GetElement(
-    const google::protobuf::RepeatedPtrField<Extent>& collection,
-    size_t index) {
-  return collection.Get(index);
-}
-
 namespace {
 template<typename T>
 void DumpExtents(const T& field, int prepend_space_count) {
@@ -154,9 +127,4 @@
 }
 
 }  // namespace graph_utils
-
-bool operator==(const Extent& a, const Extent& b) {
-  return a.start_block() == b.start_block() && a.num_blocks() == b.num_blocks();
-}
-
 }  // namespace chromeos_update_engine