mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-08-04 10:31:45 +00:00
Allows the caller of CrashReportSender::SendCrashReport() to determine that
the server rejected a crash report, by changing the return value from a boolean to a tri-state enum. Fixes issue #101. Reviewed by mmentovai. git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@99 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
5ac2b9a569
commit
d4e527b7ee
|
@ -36,12 +36,23 @@
|
||||||
namespace google_airbag {
|
namespace google_airbag {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool CrashReportSender::SendCrashReport(
|
ReportResult CrashReportSender::SendCrashReport(
|
||||||
const wstring &url, const map<wstring, wstring> ¶meters,
|
const wstring &url, const map<wstring, wstring> ¶meters,
|
||||||
const wstring &dump_file_name, wstring *report_code) {
|
const wstring &dump_file_name, wstring *report_code) {
|
||||||
|
|
||||||
return HTTPUpload::SendRequest(url, parameters, dump_file_name,
|
int http_response = 0;
|
||||||
L"upload_file_minidump", report_code);
|
bool result = HTTPUpload::SendRequest(
|
||||||
|
url, parameters, dump_file_name, L"upload_file_minidump", report_code,
|
||||||
|
&http_response);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
return RESULT_SUCCEEDED;
|
||||||
|
} else if (http_response == 400) { // TODO: update if/when the server
|
||||||
|
// switches to a different code
|
||||||
|
return RESULT_REJECTED;
|
||||||
|
} else {
|
||||||
|
return RESULT_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace google_airbag
|
} // namespace google_airbag
|
||||||
|
|
|
@ -50,19 +50,26 @@ namespace google_airbag {
|
||||||
using std::wstring;
|
using std::wstring;
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
RESULT_FAILED = 0, // Failed to communicate with the server; try later.
|
||||||
|
RESULT_REJECTED, // Successfully sent the crash report, but the
|
||||||
|
// server rejected it; don't resend this report.
|
||||||
|
RESULT_SUCCEEDED // The server accepted the crash report.
|
||||||
|
} ReportResult;
|
||||||
|
|
||||||
class CrashReportSender {
|
class CrashReportSender {
|
||||||
public:
|
public:
|
||||||
// Sends the specified minidump file, along with the map of
|
// Sends the specified minidump file, along with the map of
|
||||||
// name value pairs, as a multipart POST request to the given URL.
|
// name value pairs, as a multipart POST request to the given URL.
|
||||||
// Parameter names must contain only printable ASCII characters,
|
// Parameter names must contain only printable ASCII characters,
|
||||||
// and may not contain a quote (") character.
|
// and may not contain a quote (") character.
|
||||||
// If the report is sent successfully (the return value is true), a
|
// Only HTTP(S) URLs are currently supported. The return value indicates
|
||||||
// code uniquely identifying the report will be returned in report_code.
|
// the result of the operation (see above for possible results).
|
||||||
// Only HTTP(S) URLs are currently supported. Returns true on success.
|
|
||||||
// If report_code is non-NULL and the report is sent successfully (that is,
|
// If report_code is non-NULL and the report is sent successfully (that is,
|
||||||
// the return value is true), a code uniquely identifying the report will be
|
// the return value is RESULT_SUCCEEDED), a code uniquely identifying the
|
||||||
// returned in report_code. (Otherwise, report_code will be unchanged.)
|
// report will be returned in report_code.
|
||||||
static bool SendCrashReport(const wstring &url,
|
// (Otherwise, report_code will be unchanged.)
|
||||||
|
static ReportResult SendCrashReport(const wstring &url,
|
||||||
const map<wstring, wstring> ¶meters,
|
const map<wstring, wstring> ¶meters,
|
||||||
const wstring &dump_file_name,
|
const wstring &dump_file_name,
|
||||||
wstring *report_code);
|
wstring *report_code);
|
||||||
|
|
|
@ -66,7 +66,12 @@ bool HTTPUpload::SendRequest(const wstring &url,
|
||||||
const map<wstring, wstring> ¶meters,
|
const map<wstring, wstring> ¶meters,
|
||||||
const wstring &upload_file,
|
const wstring &upload_file,
|
||||||
const wstring &file_part_name,
|
const wstring &file_part_name,
|
||||||
wstring *response_body) {
|
wstring *response_body,
|
||||||
|
int *response_code) {
|
||||||
|
if (response_code) {
|
||||||
|
*response_code = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(bryner): support non-ASCII parameter names
|
// TODO(bryner): support non-ASCII parameter names
|
||||||
if (!CheckParameters(parameters)) {
|
if (!CheckParameters(parameters)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -153,7 +158,12 @@ bool HTTPUpload::SendRequest(const wstring &url,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = (wcscmp(http_status, L"200") == 0);
|
int http_response = wcstol(http_status, NULL, 10);
|
||||||
|
if (response_code) {
|
||||||
|
*response_code = http_response;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool result = (http_response == 200);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
result = ReadResponse(request.get(), response_body);
|
result = ReadResponse(request.get(), response_body);
|
||||||
|
|
|
@ -63,11 +63,14 @@ class HTTPUpload {
|
||||||
// Only HTTP(S) URLs are currently supported. Returns true on success.
|
// Only HTTP(S) URLs are currently supported. Returns true on success.
|
||||||
// If the request is successful and response_body is non-NULL,
|
// If the request is successful and response_body is non-NULL,
|
||||||
// the response body will be returned in response_body.
|
// the response body will be returned in response_body.
|
||||||
|
// If response_code is non-NULL, it will be set to the HTTP response code
|
||||||
|
// received (or 0 if the request failed before getting an HTTP response).
|
||||||
static bool SendRequest(const wstring &url,
|
static bool SendRequest(const wstring &url,
|
||||||
const map<wstring, wstring> ¶meters,
|
const map<wstring, wstring> ¶meters,
|
||||||
const wstring &upload_file,
|
const wstring &upload_file,
|
||||||
const wstring &file_part_name,
|
const wstring &file_part_name,
|
||||||
wstring *response_body);
|
wstring *response_body,
|
||||||
|
int *response_code);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class AutoInternetHandle;
|
class AutoInternetHandle;
|
||||||
|
|
|
@ -182,7 +182,8 @@ int wmain(int argc, wchar_t *argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = HTTPUpload::SendRequest(url, parameters,
|
bool success = HTTPUpload::SendRequest(url, parameters,
|
||||||
symbol_file, L"symbol_file", NULL);
|
symbol_file, L"symbol_file",
|
||||||
|
NULL, NULL);
|
||||||
_wunlink(symbol_file.c_str());
|
_wunlink(symbol_file.c_str());
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
|
Loading…
Reference in a new issue