#include "handler/crash_report_upload_thread.h"
#include <errno.h>
#include <time.h>
#include <algorithm>
#include <map>
#include <memory>
#include <vector>
#include "base/logging.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "client/settings.h"
#include "handler/minidump_to_upload_parameters.h"
#include "snapshot/minidump/process_snapshot_minidump.h"
#include "snapshot/module_snapshot.h"
#include "util/file/file_reader.h"
#include "util/misc/metrics.h"
#include "util/misc/uuid.h"
#include "util/net/http_body.h"
#include "util/net/http_multipart_builder.h"
#include "util/net/http_transport.h"
#include "util/net/url.h"
#include "util/stdlib/map_insert.h"
#if BUILDFLAG(IS_APPLE)
#include "handler/mac/file_limit_annotation.h"
#endif
#if BUILDFLAG(IS_IOS)
#include "util/ios/scoped_background_task.h"
#endif
namespace crashpad {
namespace {
const int kRetryWorkIntervalSeconds = …;
#if BUILDFLAG(IS_IOS)
const int kRetryAttempts = 5;
#endif
class ScopedFunctionInvoker final { … };
}
CrashReportUploadThread::CrashReportUploadThread(
CrashReportDatabase* database,
const std::string& url,
const Options& options,
ProcessPendingReportsObservationCallback callback)
: … { … }
CrashReportUploadThread::~CrashReportUploadThread() { … }
void CrashReportUploadThread::ReportPending(const UUID& report_uuid) { … }
void CrashReportUploadThread::Start() { … }
void CrashReportUploadThread::Stop() { … }
void CrashReportUploadThread::ProcessPendingReports() { … }
void CrashReportUploadThread::ProcessPendingReport(
const CrashReportDatabase::Report& report) { … }
CrashReportUploadThread::UploadResult CrashReportUploadThread::UploadReport(
const CrashReportDatabase::UploadReport* report,
std::string* response_body) { … }
void CrashReportUploadThread::DoWork(const WorkerThread* thread) { … }
bool CrashReportUploadThread::ShouldRateLimitUpload(
const CrashReportDatabase::Report& report) { … }
#if BUILDFLAG(IS_IOS)
bool CrashReportUploadThread::ShouldRateLimitRetry(
const CrashReportDatabase::Report& report) {
if (retry_uuid_time_map_.find(report.uuid) != retry_uuid_time_map_.end()) {
time_t now = time(nullptr);
if (now < retry_uuid_time_map_[report.uuid]) {
return true;
} else {
retry_uuid_time_map_.erase(report.uuid);
}
}
return false;
}
#endif
}