Index: chromecast/crash/dump_info.h |
diff --git a/chromecast/crash/dump_info.h b/chromecast/crash/dump_info.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7c442e12aef351a12a06444b1ea09bda3e110939 |
--- /dev/null |
+++ b/chromecast/crash/dump_info.h |
@@ -0,0 +1,89 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROMECAST_CRASH_DUMP_INFO_H_ |
+#define CHROMECAST_CRASH_DUMP_INFO_H_ |
+ |
+#include <string> |
+ |
+#include "base/macros.h" |
+ |
+namespace chromecast { |
+ |
+struct MinidumpParams { |
gunsch
2015/06/09 18:46:19
This struct could/should be in its own file. This
slan
2015/06/10 01:49:13
Done.
|
+ MinidumpParams(); |
+ MinidumpParams(const std::string& p_process_name, |
+ const uint64_t p_process_uptime, |
+ const std::string& p_suffix, |
+ const std::string& p_previous_app_name, |
+ const std::string& p_current_app_name, |
+ const std::string& p_last_app_name, |
+ const std::string& p_cast_release_version, |
+ const std::string& p_cast_build_number); |
+ MinidumpParams(const MinidumpParams& params); |
+ ~MinidumpParams(); |
+ |
+ std::string process_name; |
+ uint64_t process_uptime; |
+ std::string suffix; |
+ std::string previous_app_name; |
+ std::string current_app_name; |
+ std::string last_app_name; |
+ // Release version is in the format of "major.minor", such as "1.15". |
+ std::string cast_release_version; |
+ // Build number is numerical string such as "20000". |
+ std::string cast_build_number; |
+}; |
+ |
+// Class that encapsulates the construction and parsing of dump entries |
+// in the log file. |
+class DumpInfo { |
+ public: |
+ // Attempt to construct a DumpInfo object by parsing the given entry string |
+ // and extracting the contained information and populate the relevant |
+ // fields. |
+ explicit DumpInfo(const std::string& entry); |
+ |
+ // Attempt to construct a DumpInfo object that has the following info: |
+ // |
+ // -crashed_process_dump: the full path of the dump written |
+ // -crashed_process_logfile: the full path of the logfile written |
+ // -dump_time: the time of the dump written |
+ // -params: a structure containing other useful crash information |
+ // |
+ // As a result of construction, the |entry_| will be filled with the |
+ // appropriate string to add to the log file. |
+ DumpInfo(const std::string& crashed_process_dump, |
+ const std::string& crashed_process_logfile, |
+ const time_t& dump_time, |
+ const MinidumpParams& params); |
+ |
+ ~DumpInfo(); |
+ |
+ // Accessors. |
gunsch
2015/06/09 18:46:19
nit: remove comment
slan
2015/06/10 01:49:13
Done.
|
+ std::string crashed_process_dump() const { return crashed_process_dump_; } |
+ std::string logfile() const { return logfile_; } |
+ time_t dump_time() const { return dump_time_; } |
+ std::string entry() const { return entry_; } |
+ MinidumpParams params() const { return params_; } |
+ bool valid() const { return valid_; } |
+ |
+ private: |
+ bool ParseEntry(const std::string& entry); |
+ bool SetDumpTimeFromString(const std::string& timestr); |
+ std::string GetEntryAsString(); |
+ |
+ std::string crashed_process_dump_; |
+ std::string logfile_; |
+ time_t dump_time_; |
+ std::string entry_; |
+ MinidumpParams params_; |
+ bool valid_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DumpInfo); |
+}; |
+ |
+} // namespace chromecast |
+ |
+#endif // CHROMECAST_CRASH_DUMP_INFO_H_ |