Implement XzExtentWriter.

The new XzExtentWriter class is an ExtentWriter that uses xz-embedded
to decompress an xz stream and write it to the underlying extent
writer. This will be used to implement REPLACE_XZ in a follow up CL.

Bug: 23604708
Test: Added unittests.

Change-Id: Ifd2ba0c917b66ab33e5cff1d6069da833ad54882
diff --git a/main.cc b/main.cc
index 516c72c..f56d447 100644
--- a/main.cc
+++ b/main.cc
@@ -14,7 +14,10 @@
 // limitations under the License.
 //
 
+#include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
+#include <xz.h>
 
 #include <string>
 
@@ -27,8 +30,6 @@
 #include <chromeos/flag_helper.h>
 #include <chromeos/message_loops/base_message_loop.h>
 #include <metrics/metrics_library.h>
-#include <sys/stat.h>
-#include <sys/types.h>
 
 #include "update_engine/daemon.h"
 #include "update_engine/terminator.h"
@@ -113,6 +114,9 @@
 
   LOG(INFO) << "Chrome OS Update Engine starting";
 
+  // xz-embedded requires to initialize its CRC-32 table once on startup.
+  xz_crc32_init();
+
   // Ensure that all written files have safe permissions.
   // This is a mask, so we _block_ all permissions for the group owner and other
   // users but allow all permissions for the user owner. We allow execution