mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 994707 - Write crash submission events. r=ted
--HG-- extra : rebase_source : 11f614bdb0c8f6bf63ddc937957b89b7184eaad9
This commit is contained in:
parent
84d99bb465
commit
cf1bacee7b
@ -32,9 +32,12 @@ namespace CrashReporter {
|
|||||||
|
|
||||||
StringTable gStrings;
|
StringTable gStrings;
|
||||||
string gSettingsPath;
|
string gSettingsPath;
|
||||||
|
string gEventsPath;
|
||||||
int gArgc;
|
int gArgc;
|
||||||
char** gArgv;
|
char** gArgv;
|
||||||
|
|
||||||
|
enum SubmissionResult {Succeeded, Failed};
|
||||||
|
|
||||||
static auto_ptr<ofstream> gLogStream(nullptr);
|
static auto_ptr<ofstream> gLogStream(nullptr);
|
||||||
static string gReporterDumpFile;
|
static string gReporterDumpFile;
|
||||||
static string gExtraFile;
|
static string gExtraFile;
|
||||||
@ -172,6 +175,53 @@ bool WriteStringsToFile(const string& path,
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static string Basename(const string& file)
|
||||||
|
{
|
||||||
|
string::size_type slashIndex = file.rfind(UI_DIR_SEPARATOR);
|
||||||
|
if (slashIndex != string::npos)
|
||||||
|
return file.substr(slashIndex + 1);
|
||||||
|
else
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetDumpLocalID()
|
||||||
|
{
|
||||||
|
string localId = Basename(gReporterDumpFile);
|
||||||
|
string::size_type dot = localId.rfind('.');
|
||||||
|
|
||||||
|
if (dot == string::npos)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
return localId.substr(0, dot);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void WriteSubmissionEvent(SubmissionResult result,
|
||||||
|
const string& remoteId)
|
||||||
|
{
|
||||||
|
if (gEventsPath.empty()) {
|
||||||
|
// If there is no path for writing the submission event, skip it.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string localId = GetDumpLocalID();
|
||||||
|
string fpath = gEventsPath + UI_DIR_SEPARATOR + localId + "-submission";
|
||||||
|
ofstream* f = UIOpenWrite(fpath.c_str());
|
||||||
|
time_t tm;
|
||||||
|
time(&tm);
|
||||||
|
|
||||||
|
if (f->is_open()) {
|
||||||
|
*f << "crash.submission.1\n";
|
||||||
|
*f << tm << "\n";
|
||||||
|
*f << localId << "\n";
|
||||||
|
*f << (result == Succeeded ? "true" : "false") << "\n";
|
||||||
|
*f << remoteId;
|
||||||
|
|
||||||
|
f->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete f;
|
||||||
|
}
|
||||||
|
|
||||||
void LogMessage(const std::string& message)
|
void LogMessage(const std::string& message)
|
||||||
{
|
{
|
||||||
if (gLogStream.get()) {
|
if (gLogStream.get()) {
|
||||||
@ -218,15 +268,6 @@ static string GetExtraDataFilename(const string& dumpfile)
|
|||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string Basename(const string& file)
|
|
||||||
{
|
|
||||||
int slashIndex = file.rfind(UI_DIR_SEPARATOR);
|
|
||||||
if (slashIndex >= 0)
|
|
||||||
return file.substr(slashIndex + 1);
|
|
||||||
else
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool MoveCrashData(const string& toDir,
|
static bool MoveCrashData(const string& toDir,
|
||||||
string& dumpfile,
|
string& dumpfile,
|
||||||
string& extrafile)
|
string& extrafile)
|
||||||
@ -316,6 +357,7 @@ static bool AddSubmittedReport(const string& serverResponse)
|
|||||||
file->close();
|
file->close();
|
||||||
delete file;
|
delete file;
|
||||||
|
|
||||||
|
WriteSubmissionEvent(Succeeded, responseItems["CrashID"]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +385,10 @@ void SendCompleted(bool success, const string& serverResponse)
|
|||||||
return;
|
return;
|
||||||
directory.resize(slashpos);
|
directory.resize(slashpos);
|
||||||
UIPruneSavedDumps(directory);
|
UIPruneSavedDumps(directory);
|
||||||
|
WriteSubmissionEvent(Failed, "");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
WriteSubmissionEvent(Failed, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,6 +559,23 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
OpenLogFile();
|
OpenLogFile();
|
||||||
|
|
||||||
|
#ifdef XP_WIN32
|
||||||
|
static const wchar_t kEventsDirKey[] = L"MOZ_CRASHREPORTER_EVENTS_DIRECTORY";
|
||||||
|
const wchar_t *eventsPath = _wgetenv(kEventsDirKey);
|
||||||
|
if (eventsPath && *eventsPath) {
|
||||||
|
gEventsPath = WideToUTF8(eventsPath);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static const char kEventsDirKey[] = "MOZ_CRASHREPORTER_EVENTS_DIRECTORY";
|
||||||
|
const char *eventsPath = getenv(kEventsDirKey);
|
||||||
|
if (eventsPath && *eventsPath) {
|
||||||
|
gEventsPath = eventsPath;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else {
|
||||||
|
gEventsPath.clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (!UIFileExists(gReporterDumpFile)) {
|
if (!UIFileExists(gReporterDumpFile)) {
|
||||||
UIError(gStrings[ST_ERROR_DUMPFILEEXISTS]);
|
UIError(gStrings[ST_ERROR_DUMPFILEEXISTS]);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -82,6 +82,7 @@ typedef std::map<std::string, std::string> StringTable;
|
|||||||
namespace CrashReporter {
|
namespace CrashReporter {
|
||||||
extern StringTable gStrings;
|
extern StringTable gStrings;
|
||||||
extern std::string gSettingsPath;
|
extern std::string gSettingsPath;
|
||||||
|
extern std::string gEventsPath;
|
||||||
extern int gArgc;
|
extern int gArgc;
|
||||||
extern char** gArgv;
|
extern char** gArgv;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user