Make BsdiffPatchWriter into an Interface.

Currently, all bsdiff() functions take a filename for the patch, which
is called with a temporary file in all cases. To help expose an
interface that allows to write bsdiff patches in different formats (for
example, changing the compressor and header format) we expose the
PatchWriterInterface class in the public interface so callers can use
a different one or define their own to help experimenting with bsdiff
enconding improvements.

Bug: 34220646
Test: make bsdiff and update_engine; ran bsdiff_unittest

Change-Id: Ie450b2790137665bc033cb36d037171090b18a4b
diff --git a/patch_writer.cc b/patch_writer.cc
index 6e9c325..4ed9a50 100644
--- a/patch_writer.cc
+++ b/patch_writer.cc
@@ -31,10 +31,18 @@
 
 namespace bsdiff {
 
-bool BsdiffPatchWriter::Open(const std::string& patch_filename) {
-  fp_ = fopen(patch_filename.c_str(), "w");
+bool BsdiffPatchWriter::InitializeBuffers(const uint8_t* old_buf,
+                                          uint64_t old_size,
+                                          const uint8_t* new_buf,
+                                          uint64_t new_size) {
+  old_buf_ = old_buf;
+  old_size_ = old_size;
+  new_buf_ = new_buf;
+  new_size_ = new_size;
+
+  fp_ = fopen(patch_filename_.c_str(), "w");
   if (!fp_) {
-    LOG(ERROR) << "Opening " << patch_filename << endl;
+    LOG(ERROR) << "Opening " << patch_filename_ << endl;
     return false;
   }
   return true;