Transfer memory ownership when stacking ExtentWriters.

The ExtentWriter implementations are meant to be stacked in a way that
the underlying extent writer can't be reused. Calling End() on the top
of the stack will call End() on every ExtentWriter.

This patch enforces this design decision in the interface transfering
the ownership of the ExtentWriter when stacking them using a unique_ptr
instead of a plain pointer.

Bug: 23604708
Test: Updated unittests.

Change-Id: Ie3b5b9cbb3058359c487a783f6fb3c0ac65bde00
diff --git a/bzip_extent_writer_unittest.cc b/bzip_extent_writer_unittest.cc
index 14e821a..986be9f 100644
--- a/bzip_extent_writer_unittest.cc
+++ b/bzip_extent_writer_unittest.cc
@@ -20,10 +20,14 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
+
 #include <algorithm>
 #include <string>
 #include <vector>
+
+#include <chromeos/make_unique_ptr.h>
 #include <gtest/gtest.h>
+
 #include "update_engine/test_utils.h"
 #include "update_engine/utils.h"
 
@@ -74,8 +78,8 @@
     0x22, 0x9c, 0x28, 0x48, 0x66, 0x61, 0xb8, 0xea, 0x00,
   };
 
-  DirectExtentWriter direct_writer;
-  BzipExtentWriter bzip_writer(&direct_writer);
+  BzipExtentWriter bzip_writer(
+      chromeos::make_unique_ptr(new DirectExtentWriter()));
   EXPECT_TRUE(bzip_writer.Init(fd_, extents, kBlockSize));
   EXPECT_TRUE(bzip_writer.Write(test, sizeof(test)));
   EXPECT_TRUE(bzip_writer.End());
@@ -114,8 +118,8 @@
   chromeos::Blob compressed_data;
   EXPECT_TRUE(utils::ReadFile(compressed_path, &compressed_data));
 
-  DirectExtentWriter direct_writer;
-  BzipExtentWriter bzip_writer(&direct_writer);
+  BzipExtentWriter bzip_writer(
+      chromeos::make_unique_ptr(new DirectExtentWriter()));
   EXPECT_TRUE(bzip_writer.Init(fd_, extents, kBlockSize));
 
   chromeos::Blob original_compressed_data = compressed_data;