mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
Add NewReport::Reader to read back new reports
Change-Id: If53a63aac2b213b02619bb5277e5618c0e7842b3 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2019566 Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
parent
2fd16e3392
commit
6c0f5ccaa8
@ -65,6 +65,15 @@ bool CrashReportDatabase::NewReport::Initialize(
|
||||
return true;
|
||||
}
|
||||
|
||||
FileReaderInterface* CrashReportDatabase::NewReport::Reader() {
|
||||
auto reader = std::make_unique<FileReader>();
|
||||
if (!reader->Open(file_remover_.get())) {
|
||||
return nullptr;
|
||||
}
|
||||
reader_ = std::move(reader);
|
||||
return reader_.get();
|
||||
}
|
||||
|
||||
CrashReportDatabase::UploadReport::UploadReport()
|
||||
: Report(),
|
||||
reader_(std::make_unique<FileReader>()),
|
||||
|
@ -113,9 +113,13 @@ class CrashReportDatabase {
|
||||
NewReport();
|
||||
~NewReport();
|
||||
|
||||
//! An open FileWriter with which to write the report.
|
||||
//! \brief An open FileWriter with which to write the report.
|
||||
FileWriter* Writer() const { return writer_.get(); }
|
||||
|
||||
//! \brief Returns a FileReaderInterface to the report, or `nullptr` with a
|
||||
//! message logged.
|
||||
FileReaderInterface* Reader();
|
||||
|
||||
//! A unique identifier by which this report will always be known to the
|
||||
//! database.
|
||||
const UUID& ReportID() const { return uuid_; }
|
||||
@ -142,6 +146,7 @@ class CrashReportDatabase {
|
||||
const base::FilePath::StringType& extension);
|
||||
|
||||
std::unique_ptr<FileWriter> writer_;
|
||||
std::unique_ptr<FileReader> reader_;
|
||||
ScopedRemoveFile file_remover_;
|
||||
std::vector<std::unique_ptr<FileWriter>> attachment_writers_;
|
||||
std::vector<ScopedRemoveFile> attachment_removers_;
|
||||
|
@ -53,6 +53,12 @@ class CrashReportDatabaseTest : public testing::Test {
|
||||
static constexpr char kTest[] = "test";
|
||||
ASSERT_TRUE(new_report->Writer()->Write(kTest, sizeof(kTest)));
|
||||
|
||||
char contents[sizeof(kTest)];
|
||||
FileReaderInterface* reader = new_report->Reader();
|
||||
ASSERT_TRUE(reader->ReadExactly(contents, sizeof(contents)));
|
||||
EXPECT_EQ(memcmp(contents, kTest, sizeof(contents)), 0);
|
||||
EXPECT_EQ(reader->ReadExactly(contents, 1), 0);
|
||||
|
||||
UUID uuid;
|
||||
EXPECT_EQ(db_->FinishedWritingCrashReport(std::move(new_report), &uuid),
|
||||
CrashReportDatabase::kNoError);
|
||||
|
Loading…
x
Reference in New Issue
Block a user