mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
win: Set last-upload-attempt time in CrashReportDatabaseWin
This resolves some left-behind TODOs referring to a closed bug. It looks like this should have worked since dfaa25af4929. BUG=crashpad:13 TEST=crashpad_snapshot_test CrashReportDatabaseTest.* R=scottmg@chromium.org Review URL: https://codereview.chromium.org/1391993002 .
This commit is contained in:
parent
78592537bc
commit
1f11ddc785
@ -65,14 +65,10 @@ class CrashReportDatabaseTest : public testing::Test {
|
||||
}
|
||||
|
||||
void UploadReport(const UUID& uuid, bool successful, const std::string& id) {
|
||||
#if !defined(OS_WIN)
|
||||
// Enable when ported to Windows.
|
||||
// https://code.google.com/p/crashpad/issues/detail?id=13
|
||||
Settings* const settings = db_->GetSettings();
|
||||
ASSERT_TRUE(settings);
|
||||
time_t times[2];
|
||||
ASSERT_TRUE(settings->GetLastUploadAttemptTime(×[0]));
|
||||
#endif
|
||||
|
||||
const CrashReportDatabase::Report* report = nullptr;
|
||||
ASSERT_EQ(CrashReportDatabase::kNoError,
|
||||
@ -85,13 +81,9 @@ class CrashReportDatabaseTest : public testing::Test {
|
||||
EXPECT_EQ(CrashReportDatabase::kNoError,
|
||||
db_->RecordUploadAttempt(report, successful, id));
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
// Enable when ported to Windows.
|
||||
// https://code.google.com/p/crashpad/issues/detail?id=13
|
||||
ASSERT_TRUE(settings->GetLastUploadAttemptTime(×[1]));
|
||||
EXPECT_NE(times[1], 0);
|
||||
EXPECT_GE(times[1], times[0]);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExpectPreparedCrashReport(const CrashReportDatabase::Report& report) {
|
||||
@ -122,9 +114,6 @@ TEST_F(CrashReportDatabaseTest, Initialize) {
|
||||
// Initialize the database for the first time, creating it.
|
||||
ASSERT_TRUE(db());
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
// Enable when ported to Windows.
|
||||
// https://code.google.com/p/crashpad/issues/detail?id=13
|
||||
Settings* settings = db()->GetSettings();
|
||||
|
||||
UUID client_ids[2];
|
||||
@ -134,7 +123,6 @@ TEST_F(CrashReportDatabaseTest, Initialize) {
|
||||
time_t last_upload_attempt_time;
|
||||
ASSERT_TRUE(settings->GetLastUploadAttemptTime(&last_upload_attempt_time));
|
||||
EXPECT_EQ(0, last_upload_attempt_time);
|
||||
#endif
|
||||
|
||||
// Close and reopen the database at the same path.
|
||||
ResetDatabase();
|
||||
@ -142,9 +130,6 @@ TEST_F(CrashReportDatabaseTest, Initialize) {
|
||||
auto db = CrashReportDatabase::Initialize(path());
|
||||
ASSERT_TRUE(db);
|
||||
|
||||
#if !defined(OS_WIN)
|
||||
// Enable when ported to Windows.
|
||||
// https://code.google.com/p/crashpad/issues/detail?id=13
|
||||
settings = db->GetSettings();
|
||||
|
||||
ASSERT_TRUE(settings->GetClientID(&client_ids[1]));
|
||||
@ -152,7 +137,6 @@ TEST_F(CrashReportDatabaseTest, Initialize) {
|
||||
|
||||
ASSERT_TRUE(settings->GetLastUploadAttemptTime(&last_upload_attempt_time));
|
||||
EXPECT_EQ(0, last_upload_attempt_time);
|
||||
#endif
|
||||
|
||||
std::vector<CrashReportDatabase::Report> reports;
|
||||
EXPECT_EQ(CrashReportDatabase::kNoError, db->GetPendingReports(&reports));
|
||||
|
@ -631,7 +631,7 @@ OperationStatus CrashReportDatabaseWin::ErrorWritingCrashReport(
|
||||
if (!DeleteFile(scoped_report->path.value().c_str())) {
|
||||
PLOG(ERROR) << "DeleteFile "
|
||||
<< base::UTF16ToUTF8(scoped_report->path.value());
|
||||
return CrashReportDatabase::kFileSystemError;
|
||||
return kFileSystemError;
|
||||
}
|
||||
|
||||
return kNoError;
|
||||
@ -691,7 +691,7 @@ OperationStatus CrashReportDatabaseWin::GetReportForUploading(
|
||||
ReportDisk* report_disk;
|
||||
OperationStatus os = metadata->FindSingleReportAndMarkDirty(
|
||||
uuid, ReportState::kPending, &report_disk);
|
||||
if (os == CrashReportDatabase::kNoError) {
|
||||
if (os == kNoError) {
|
||||
report_disk->state = ReportState::kUploading;
|
||||
// Create a copy for passing back to client. This will be freed in
|
||||
// RecordUploadAttempt.
|
||||
@ -714,19 +714,22 @@ OperationStatus CrashReportDatabaseWin::RecordUploadAttempt(
|
||||
ReportDisk* report_disk;
|
||||
OperationStatus os = metadata->FindSingleReportAndMarkDirty(
|
||||
report->uuid, ReportState::kUploading, &report_disk);
|
||||
if (os == CrashReportDatabaseWin::kNoError) {
|
||||
report_disk->uploaded = successful;
|
||||
report_disk->id = id;
|
||||
report_disk->last_upload_attempt_time = time(nullptr);
|
||||
report_disk->upload_attempts++;
|
||||
report_disk->state =
|
||||
successful ? ReportState::kCompleted : ReportState::kPending;
|
||||
}
|
||||
if (os != kNoError)
|
||||
return os;
|
||||
|
||||
// Call Settings::SetLastUploadAttemptTime().
|
||||
// https://code.google.com/p/crashpad/issues/detail?id=13.
|
||||
time_t now = time(nullptr);
|
||||
|
||||
return os;
|
||||
report_disk->uploaded = successful;
|
||||
report_disk->id = id;
|
||||
report_disk->last_upload_attempt_time = now;
|
||||
report_disk->upload_attempts++;
|
||||
report_disk->state =
|
||||
successful ? ReportState::kCompleted : ReportState::kPending;
|
||||
|
||||
if (!settings_.SetLastUploadAttemptTime(now))
|
||||
return kDatabaseError;
|
||||
|
||||
return kNoError;
|
||||
}
|
||||
|
||||
OperationStatus CrashReportDatabaseWin::SkipReportUpload(const UUID& uuid) {
|
||||
@ -738,7 +741,7 @@ OperationStatus CrashReportDatabaseWin::SkipReportUpload(const UUID& uuid) {
|
||||
ReportDisk* report_disk;
|
||||
OperationStatus os = metadata->FindSingleReportAndMarkDirty(
|
||||
uuid, ReportState::kPending, &report_disk);
|
||||
if (os == CrashReportDatabase::kNoError)
|
||||
if (os == kNoError)
|
||||
report_disk->state = ReportState::kCompleted;
|
||||
return os;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user