Clean up DumpData-related functions

This change cleans a few DumpData-related functions:

* Makes GetDumpFds return the std::vector<DumpData> by value instead of
  by pointer.
* Makes Dumpstate own the list of open tombstone and ANR files.
* Removes two more globals.
* Prevents a potential FD leak.

Bug: None
Test: `adb bugreport` succeeded
Change-Id: I5fe6964266c8c1393da274cb54000521e6ab8a17
diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h
index 7757c1e..69b0a5e 100644
--- a/cmds/dumpstate/dumpstate.h
+++ b/cmds/dumpstate/dumpstate.h
@@ -26,6 +26,7 @@
 #include <vector>
 
 #include <android-base/macros.h>
+#include <android-base/unique_fd.h>
 #include <android/os/IDumpstateListener.h>
 #include <utils/StrongPointer.h>
 #include <ziparchive/zip_writer.h>
@@ -159,6 +160,20 @@
 static std::string VERSION_DEFAULT = "default";
 
 /*
+ * Structure that contains the information of an open dump file.
+ */
+struct DumpData {
+    // Path of the file.
+    std::string name;
+
+    // Open file descriptor for the file.
+    android::base::unique_fd fd;
+
+    // Modification time of the file.
+    time_t mtime;
+};
+
+/*
  * Main class driving a bugreport generation.
  *
  * Currently, it only contains variables that are accessed externally, but gradually the functions
@@ -340,6 +355,12 @@
     std::string notification_title;
     std::string notification_description;
 
+    // List of open tombstone dump files.
+    std::vector<DumpData> tombstone_data_;
+
+    // List of open ANR dump files.
+    std::vector<DumpData> anr_data_;
+
   private:
     // Used by GetInstance() only.
     Dumpstate(const std::string& version = VERSION_CURRENT);