OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROMECAST_CRASH_LINUX_DUMP_INFO_H_ | 5 #ifndef CHROMECAST_CRASH_LINUX_DUMP_INFO_H_ |
6 #define CHROMECAST_CRASH_LINUX_DUMP_INFO_H_ | 6 #define CHROMECAST_CRASH_LINUX_DUMP_INFO_H_ |
7 | 7 |
8 #include <ctime> | 8 #include <ctime> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/time/time.h" |
13 #include "chromecast/crash/linux/minidump_params.h" | 14 #include "chromecast/crash/linux/minidump_params.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class Value; | 17 class Value; |
17 } | 18 } |
18 | 19 |
19 namespace chromecast { | 20 namespace chromecast { |
20 | 21 |
21 // Class that encapsulates the construction and parsing of dump entries | 22 // Class that encapsulates the construction and parsing of dump entries |
22 // in the log file. | 23 // in the log file. |
23 class DumpInfo { | 24 class DumpInfo { |
24 public: | 25 public: |
25 // Validate the input as a valid JSON representation of DumpInfo, then | 26 // Validate the input as a valid JSON representation of DumpInfo, then |
26 // populate the relevant fields. | 27 // populate the relevant fields. |
27 explicit DumpInfo(const base::Value* entry); | 28 explicit DumpInfo(const base::Value* entry); |
28 | 29 |
29 // Attempt to construct a DumpInfo object that has the following info: | 30 // Attempt to construct a DumpInfo object that has the following info: |
30 // | 31 // |
31 // -crashed_process_dump: the full path of the dump written | 32 // -crashed_process_dump: the full path of the dump written |
32 // -crashed_process_logfile: the full path of the logfile written | 33 // -crashed_process_logfile: the full path of the logfile written |
33 // -dump_time: the time of the dump written | 34 // -dump_time: the time of the dump written |
34 // -params: a structure containing other useful crash information | 35 // -params: a structure containing other useful crash information |
35 DumpInfo(const std::string& crashed_process_dump, | 36 DumpInfo(const std::string& crashed_process_dump, |
36 const std::string& crashed_process_logfile, | 37 const std::string& crashed_process_logfile, |
37 const time_t& dump_time, | 38 const base::Time& dump_time, |
38 const MinidumpParams& params); | 39 const MinidumpParams& params); |
39 | 40 |
40 ~DumpInfo(); | 41 ~DumpInfo(); |
41 | 42 |
42 const std::string& crashed_process_dump() const { | 43 const std::string& crashed_process_dump() const { |
43 return crashed_process_dump_; | 44 return crashed_process_dump_; |
44 } | 45 } |
45 const std::string& logfile() const { return logfile_; } | 46 const std::string& logfile() const { return logfile_; } |
46 const time_t& dump_time() const { return dump_time_; } | 47 const base::Time& dump_time() const { return dump_time_; } |
47 | 48 |
48 // Return a deep copy of the entry's JSON representation. | 49 // Return a deep copy of the entry's JSON representation. |
49 // The format is: | 50 // The format is: |
50 // { | 51 // { |
51 // "name": <name>, | 52 // "name": <name>, |
52 // "dump_time": <dump_time (kDumpTimeFormat)>, | 53 // "dump_time": <dump_time (kDumpTimeFormat)>, |
53 // "dump": <dump>, | 54 // "dump": <dump>, |
54 // "uptime": <uptime>, | 55 // "uptime": <uptime>, |
55 // "logfile": <logfile>, | 56 // "logfile": <logfile>, |
56 // "suffix": <suffix>, | 57 // "suffix": <suffix>, |
57 // "prev_app_name": <prev_app_name>, | 58 // "prev_app_name": <prev_app_name>, |
58 // "cur_app_name": <current_app_name>, | 59 // "cur_app_name": <current_app_name>, |
59 // "last_app_name": <last_app_name>, | 60 // "last_app_name": <last_app_name>, |
60 // "release_version": <release_version>, | 61 // "release_version": <release_version>, |
61 // "build_number": <build_number> | 62 // "build_number": <build_number> |
62 // "reason": <reason> | 63 // "reason": <reason> |
63 // } | 64 // } |
64 std::unique_ptr<base::Value> GetAsValue() const; | 65 std::unique_ptr<base::Value> GetAsValue() const; |
65 const MinidumpParams& params() const { return params_; } | 66 const MinidumpParams& params() const { return params_; } |
66 bool valid() const { return valid_; } | 67 bool valid() const { return valid_; } |
67 | 68 |
68 private: | 69 private: |
69 // Checks if parsed JSON in |value| is valid, if so populates the object's | 70 // Checks if parsed JSON in |value| is valid, if so populates the object's |
70 // fields from |value|. | 71 // fields from |value|. |
71 bool ParseEntry(const base::Value* value); | 72 bool ParseEntry(const base::Value* value); |
72 bool SetDumpTimeFromString(const std::string& timestr); | 73 bool SetDumpTimeFromString(const std::string& timestr); |
73 | 74 |
74 std::string crashed_process_dump_; | 75 std::string crashed_process_dump_; |
75 std::string logfile_; | 76 std::string logfile_; |
76 time_t dump_time_; | 77 base::Time dump_time_; |
77 MinidumpParams params_; | 78 MinidumpParams params_; |
78 bool valid_; | 79 bool valid_; |
79 | 80 |
80 DISALLOW_COPY_AND_ASSIGN(DumpInfo); | 81 DISALLOW_COPY_AND_ASSIGN(DumpInfo); |
81 }; | 82 }; |
82 | 83 |
83 } // namespace chromecast | 84 } // namespace chromecast |
84 | 85 |
85 #endif // CHROMECAST_CRASH_LINUX_DUMP_INFO_H_ | 86 #endif // CHROMECAST_CRASH_LINUX_DUMP_INFO_H_ |
OLD | NEW |