OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Crashpad Authors. All rights reserved. | |
Mark Mentovai
2015/01/08 22:38:09
Top-level question: what do you do about reports t
Robert Sesek
2015/01/13 16:18:22
They can be retrieved with GetReportsNotUploaded()
| |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 | |
15 #ifndef CRASHPAD_CLIENT_CRASH_REPORT_DATABASE_H_ | |
16 #define CRASHPAD_CLIENT_CRASH_REPORT_DATABASE_H_ | |
17 | |
18 #include <time.h> | |
19 | |
20 #include <string> | |
21 #include <vector> | |
22 | |
23 #include "base/basictypes.h" | |
24 #include "base/files/file_path.h" | |
25 #include "base/memory/scoped_ptr.h" | |
26 #include "util/misc/uuid.h" | |
27 | |
28 namespace crashpad { | |
29 | |
30 //! \brief An interface for managing a collection of crash report files and | |
31 //! metadata associated with the crash reports. | |
32 //! | |
33 //! All \a Report objects that are returned by this class are logically const. | |
Mark Mentovai
2015/01/08 22:38:09
You don’t need the \a, this gets linked automatica
Robert Sesek
2015/01/13 16:18:22
Done.
| |
34 //! They are snapshots of the database at the time the query was ran, and the | |
Mark Mentovai
2015/01/08 22:38:09
run
Robert Sesek
2015/01/13 16:18:22
Done.
| |
35 //! data returned is liable to change after the query is executed. | |
36 class CrashReportDatabase { | |
37 public: | |
38 //! \brief A crash report record. | |
39 //! | |
40 //! This represents the metadata for a crash report, as well as the location | |
41 //! of the report itself. A \a CrashReportDatabase maintains at least this | |
Mark Mentovai
2015/01/08 22:38:09
No \a, it gets linked automatically.
Robert Sesek
2015/01/13 16:18:22
Done.
| |
42 //! information. | |
43 struct Report { | |
44 Report() : uuid(), file_path(), id(), uploaded(false), | |
Mark Mentovai
2015/01/08 22:38:09
I wouldn’t inline this.
Robert Sesek
2015/01/13 16:18:22
Done.
| |
45 last_upload_attempt_time(0), upload_attempts(0) {} | |
46 | |
47 // A unique identifier by which this report will always be known to the | |
Mark Mentovai
2015/01/08 22:38:09
//! doxygen me, throughout this struct.
Looks lik
Robert Sesek
2015/01/13 16:18:22
Done.
| |
48 // database. | |
49 UUID uuid; | |
50 | |
51 // The current location of the crash report on the client's filesystem. | |
Mark Mentovai
2015/01/08 22:38:09
Your quotes aren’t too smart (but if you find it h
Robert Sesek
2015/01/13 16:18:22
Done.
| |
52 // The location of a crash report may change over time, so the UUID should | |
53 // be used as the canonical identifier. | |
54 base::FilePath file_path; | |
55 | |
56 // An identifier issued to this crash report by a collection server. | |
57 std::string id; | |
58 | |
59 // Whether this crash report was successfully uploaded to a collection | |
60 // server. | |
61 bool uploaded; | |
62 | |
63 // The last timestamp at which an attempt was made to submit this crash | |
64 // report to a collection server. If this is zero, then the report has never | |
65 // been uploaded. If \a uploaded is true, then this timestamp is the time | |
Mark Mentovai
2015/01/08 22:38:09
#uploaded
Robert Sesek
2015/01/13 16:18:22
Done.
| |
66 // at which the report was uploaded, and no other attempts to upload this | |
67 // report will be made. | |
68 time_t last_upload_attempt_time; | |
69 | |
70 // The number of times an attempt was made to submit this report to | |
71 // a collection server. If this is more than zero, then \a | |
Mark Mentovai
2015/01/08 22:38:09
#last_upload_attempt_time.
Robert Sesek
2015/01/13 16:18:22
Done.
| |
72 // last_upload_attempt_time will be set to the timestamp of the most | |
73 // recent attempt. | |
74 int upload_attempts; | |
75 }; | |
76 | |
77 //! \brief The result code for operations performed on a database. | |
78 enum OperationStatus { | |
79 //! \brief No error occurred. | |
80 kNoError = 0, | |
81 | |
82 //! \brief The report that was requested could not be located. | |
83 kReportNotFound, | |
84 | |
85 //! \brief An error occured while performing a file operation on a crash | |
86 //! report. | |
87 //! | |
88 //! A database is responsible for managing both the metadata about a report | |
89 //! and the actual crash report itself. This error is returned when an | |
90 //! error occurred when managing the report file. Additional information | |
91 //! will be logged. | |
92 kFileSystemError, | |
93 | |
94 //! \brief An error occured while recording metadata for a crash report. | |
95 //! | |
96 //! A database is responsible for managing both the metadata about a report | |
97 //! and the actual crash report itself. This error is returned when an | |
98 //! error occurred when managing the metadata about a crash report. | |
99 //! Additional information will be logged. | |
100 kDatabaseError, | |
101 }; | |
102 | |
103 virtual ~CrashReportDatabase() {} | |
104 | |
105 //! \brief Initializes a database of crash reports. | |
106 //! | |
107 //! \param[in] path A path to a writable directory, where the database can | |
Mark Mentovai
2015/01/08 22:38:09
It’s kinda weird for the interface to take the par
Mark Mentovai
2015/01/08 22:38:09
The database doesn’t have to be a directory as far
Robert Sesek
2015/01/13 16:18:22
No.
Robert Sesek
2015/01/13 16:18:22
I disagree. The caller does not know the structure
| |
108 //! be created or opened. | |
109 //! | |
110 //! \return A database object on success, NULL on failure with an error | |
Mark Mentovai
2015/01/08 22:38:09
`nullptr`
Robert Sesek
2015/01/13 16:18:22
Done.
| |
111 //! logged. | |
112 static scoped_ptr<CrashReportDatabase> Initialize(const base::FilePath& path); | |
113 | |
114 //! \brief Creates a record of a new crash report. | |
115 //! | |
116 //! Callers can then write the crash report at the file path provided in the | |
117 //! record. The file at the Report::file_path will not be created as a result | |
118 //! of this call. | |
119 //! | |
120 //! \param[out] report A crash report record. | |
Mark Mentovai
2015/01/08 22:38:09
…only valid if this returns OperationStatus::kNoEr
Robert Sesek
2015/01/13 16:18:22
Done.
| |
121 //! | |
122 //! \return The operation status code. | |
123 virtual OperationStatus PrepareNewCrashReport(Report* report) = 0; | |
124 | |
125 //! \brief Informs the database that a crash report has been written. | |
126 //! | |
127 //! After calling this method, the database is permitted to move and rename | |
128 //! the file at Record::file_path. | |
129 //! | |
130 //! \param[in] uuid The crash report record unique identifier. The identifier | |
131 //! must be valid. | |
132 //! | |
133 //! \return The operation status code. | |
134 virtual OperationStatus FinishedWritingCrashReport(const UUID& uuid) = 0; | |
135 | |
136 //! \brief Returns the crash report record for the unique identifier. | |
137 //! | |
138 //! \param[in] uuid The crash report record unique identifier. | |
139 //! \param[out] report A crash report record. | |
140 //! | |
141 //! \return The operation status code. | |
142 virtual OperationStatus LookUpCrashReport(const UUID& uuid, | |
143 Report* report) = 0; | |
144 | |
145 //! \brief Returns a list of crash report records that have not been uploaded. | |
146 //! | |
147 //! \param[out] reports A list of crash report record objects. This must be | |
148 //! empty. | |
Mark Mentovai
2015/01/08 22:38:09
must be empty on entry.
Same for GetUploadedRepor
Robert Sesek
2015/01/13 16:18:22
Done.
| |
149 //! | |
150 //! \return The operation status code. | |
151 virtual OperationStatus GetNotUploadedReports( | |
152 std::vector<const Report>* reports) = 0; | |
153 | |
154 //! \brief Returns a list of crash report records that have been uploaded. | |
155 //! | |
156 //! \param[out] reports A list of crash report record objects. This must be | |
157 //! empty. | |
158 //! | |
159 //! \return The operation status code. | |
160 virtual OperationStatus GetUploadedReports( | |
161 std::vector<const Report>* reports) = 0; | |
162 | |
163 //! \brief Adjusts a crash report record's metadata to account for an upload | |
164 //! attempt. | |
165 //! | |
166 //! After calling this method, the database is permitted to move and rename | |
167 //! the file at Record::file_path. | |
168 //! | |
169 //! \param[in] uuid The unique identifier for the crash report record. The | |
170 //! identifier must be valid. | |
171 //! \param[in] successful Whether the upload attempt was successful. | |
172 //! \param[in] id The identifier assigned to this crash report by the | |
173 //! collection server. Must be empty if \a successful is `false`; may be | |
174 //! empty if it is `true`. | |
175 //! | |
176 //! \return The operation status code. | |
177 virtual OperationStatus RecordUploadAttempt(const UUID& uuid, | |
178 bool successful, | |
179 const std::string& id) = 0; | |
180 | |
181 protected: | |
182 CrashReportDatabase() {} | |
183 | |
184 private: | |
185 DISALLOW_COPY_AND_ASSIGN(CrashReportDatabase); | |
186 }; | |
187 | |
188 } // namespace crashpad | |
189 | |
190 #endif // CRASHPAD_CLIENT_CRASH_REPORT_DATABASE_H_ | |
OLD | NEW |