Add ICU message format support
[chromium-blink-merge.git] / chromecast / crash / linux / dump_info.h
blobeb1f429b95359d28c20a2dbfbdee1bddf87397e4
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_
8 #include <string>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chromecast/crash/linux/minidump_params.h"
14 namespace base {
15 class Value;
18 namespace chromecast {
20 // Class that encapsulates the construction and parsing of dump entries
21 // in the log file.
22 class DumpInfo {
23 public:
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);
39 ~DumpInfo();
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.
48 // The format is:
49 // {
50 // "name": <name>,
51 // "dump_time": <dump_time (kDumpTimeFormat)>,
52 // "dump": <dump>,
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>
61 // }
62 scoped_ptr<base::Value> GetAsValue() const;
63 const MinidumpParams& params() const { return params_; }
64 const bool valid() const { return valid_; }
66 private:
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_;
73 std::string logfile_;
74 time_t dump_time_;
75 MinidumpParams params_;
76 bool valid_;
78 DISALLOW_COPY_AND_ASSIGN(DumpInfo);
81 } // namespace chromecast
83 #endif // CHROMECAST_CRASH_LINUX_DUMP_INFO_H_