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