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
3 // found in the LICENSE file.
5 #ifndef CHROMECAST_CRASH_LINUX_DUMP_INFO_H_
6 #define CHROMECAST_CRASH_LINUX_DUMP_INFO_H_
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chromecast/crash/linux/minidump_params.h"
18 namespace chromecast
{
20 // Class that encapsulates the construction and parsing of dump entries
24 // Validate the input as a valid JSON representation of DumpInfo, then
25 // populate the relevant fields.
26 explicit DumpInfo(const base::Value
* entry
);
28 // Attempt to construct a DumpInfo object that has the following info:
30 // -crashed_process_dump: the full path of the dump written
31 // -crashed_process_logfile: the full path of the logfile written
32 // -dump_time: the time of the dump written
33 // -params: a structure containing other useful crash information
34 DumpInfo(const std::string
& crashed_process_dump
,
35 const std::string
& crashed_process_logfile
,
36 const time_t& dump_time
,
37 const MinidumpParams
& params
);
41 const std::string
& crashed_process_dump() const {
42 return crashed_process_dump_
;
44 const std::string
& logfile() const { return logfile_
; }
45 const time_t& dump_time() const { return dump_time_
; }
47 // Return a deep copy of the entry's JSON representation.
51 // "dump_time": <dump_time (kDumpTimeFormat)>,
53 // "uptime": <uptime>,
54 // "logfile": <logfile>,
55 // "suffix": <suffix>,
56 // "prev_app_name": <prev_app_name>,
57 // "cur_app_name": <current_app_name>,
58 // "last_app_name": <last_app_name>,
59 // "release_version": <release_version>,
60 // "build_number": <build_number>
62 scoped_ptr
<base::Value
> GetAsValue() const;
63 const MinidumpParams
& params() const { return params_
; }
64 const bool valid() const { return valid_
; }
67 // Checks if parsed JSON in |value| is valid, if so populates the object's
68 // fields from |value|.
69 bool ParseEntry(const base::Value
* value
);
70 bool SetDumpTimeFromString(const std::string
& timestr
);
72 std::string crashed_process_dump_
;
75 MinidumpParams params_
;
78 DISALLOW_COPY_AND_ASSIGN(DumpInfo
);
81 } // namespace chromecast
83 #endif // CHROMECAST_CRASH_LINUX_DUMP_INFO_H_