зеркало из https://github.com/mozilla/pjs.git
bug 380421 - get crash reporter params from nsXULAppInfo. r=bsmedberg
This commit is contained in:
Родитель
8ecfc976fc
Коммит
875f7deebb
|
@ -39,6 +39,8 @@
|
|||
|
||||
#include "crashreporter.h"
|
||||
|
||||
// Disable exception handler warnings.
|
||||
#pragma warning( disable : 4530 )
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
|
@ -53,12 +55,9 @@ StringTable gStrings;
|
|||
int gArgc;
|
||||
const char** gArgv;
|
||||
|
||||
static string gSendURL;
|
||||
static string gDumpFile;
|
||||
static string gExtraFile;
|
||||
static string gSettingsPath;
|
||||
static bool gDeleteDump = true;
|
||||
|
||||
|
||||
static string kExtraDataExtension = ".extra";
|
||||
|
||||
|
@ -98,11 +97,6 @@ static bool ReadConfig()
|
|||
if (!ReadStringsFromFile(iniPath, gStrings))
|
||||
return false;
|
||||
|
||||
gSendURL = gStrings["URL"];
|
||||
|
||||
string deleteSetting = gStrings["Delete"];
|
||||
gDeleteDump = deleteSetting.empty() || atoi(deleteSetting.c_str()) != 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -196,12 +190,10 @@ bool CrashReporterSendCompleted(bool success,
|
|||
const string& serverResponse)
|
||||
{
|
||||
if (success) {
|
||||
if (gDeleteDump) {
|
||||
if (!gDumpFile.empty())
|
||||
UIDeleteFile(gDumpFile);
|
||||
if (!gExtraFile.empty())
|
||||
UIDeleteFile(gExtraFile);
|
||||
}
|
||||
|
||||
return AddSubmittedReport(serverResponse);
|
||||
}
|
||||
|
@ -246,6 +238,11 @@ int main(int argc, const char** argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (queryParameters.find("ServerURL") == queryParameters.end()) {
|
||||
UIError("No server URL specified");
|
||||
return 0;
|
||||
}
|
||||
|
||||
string product = queryParameters["ProductName"];
|
||||
string vendor = queryParameters["Vendor"];
|
||||
if (!UIGetSettingsPath(vendor, product, gSettingsPath)) {
|
||||
|
@ -259,7 +256,19 @@ int main(int argc, const char** argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
UIShowCrashUI(gDumpFile, queryParameters, gSendURL);
|
||||
string sendURL = queryParameters["ServerURL"];
|
||||
// we don't need to actually send this
|
||||
queryParameters.erase("ServerURL");
|
||||
|
||||
// allow override of the server url via environment variable
|
||||
//XXX: remove this in the far future when our robot
|
||||
// masters force everyone to use XULRunner
|
||||
char* urlEnv = getenv("MOZ_CRASHREPORTER_URL");
|
||||
if (urlEnv && *urlEnv) {
|
||||
sendURL = urlEnv;
|
||||
}
|
||||
|
||||
UIShowCrashUI(gDumpFile, queryParameters, sendURL);
|
||||
}
|
||||
|
||||
UIShutdown();
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#ifndef CRASHREPORTER_H__
|
||||
#define CRASHREPORTER_H__
|
||||
|
||||
#pragma warning( push )
|
||||
// Disable exception handler warnings.
|
||||
#pragma warning( disable : 4530 )
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <stdlib.h>
|
||||
|
@ -71,4 +74,5 @@ bool UIEnsurePathExists(const std::string& path);
|
|||
bool UIMoveFile(const std::string& oldfile, const std::string& newfile);
|
||||
bool UIDeleteFile(const std::string& oldfile);
|
||||
|
||||
#pragma warning( pop )
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,3 @@ SubmitSuccess=Crash report submitted successfully
|
|||
SubmitFailed=Failed to submit crash report
|
||||
CrashID=Crash ID: %s
|
||||
CrashDetailsURL=You can view details of this crash at %s
|
||||
|
||||
[Settings]
|
||||
URL=https://crash-reports.mozilla.com/submit
|
||||
|
|
|
@ -430,10 +430,11 @@ bool UIEnsurePathExists(const string& path)
|
|||
|
||||
bool UIMoveFile(const string& oldfile, const string& newfile)
|
||||
{
|
||||
return MoveFile(UTF8ToWide(oldfile).c_str(), UTF8ToWide(newfile).c_str());
|
||||
return MoveFile(UTF8ToWide(oldfile).c_str(), UTF8ToWide(newfile).c_str())
|
||||
== TRUE;
|
||||
}
|
||||
|
||||
bool UIDeleteFile(const string& oldfile)
|
||||
{
|
||||
return DeleteFile(UTF8ToWide(oldfile).c_str());
|
||||
return DeleteFile(UTF8ToWide(oldfile).c_str()) == TRUE;
|
||||
}
|
||||
|
|
|
@ -288,21 +288,14 @@ static nsresult GetExecutablePath(nsString& exePath)
|
|||
#endif
|
||||
}
|
||||
|
||||
nsresult SetExceptionHandler(nsILocalFile* aXREDirectory)
|
||||
nsresult SetExceptionHandler(nsILocalFile* aXREDirectory,
|
||||
const char* aServerURL)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (gExceptionHandler)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
// check environment var to see if we're enabled.
|
||||
// we're off by default until we sort out the
|
||||
// rest of the infrastructure,
|
||||
// so it must exist and be set to a non-empty value.
|
||||
const char* airbagEnv = PR_GetEnv("MOZ_AIRBAG");
|
||||
if (airbagEnv == NULL || *airbagEnv == '\0')
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
// this environment variable prevents us from launching
|
||||
// the crash reporter client
|
||||
const char* noReportEnv = PR_GetEnv("MOZ_CRASHREPORTER_NO_REPORT");
|
||||
|
@ -363,7 +356,7 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
|
||||
// finally, set the exception handler
|
||||
// now set the exception handler
|
||||
gExceptionHandler = new google_breakpad::
|
||||
ExceptionHandler(CONVERT_UTF16_TO_XP_CHAR(tempPath).get(),
|
||||
nsnull,
|
||||
|
@ -374,6 +367,11 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory)
|
|||
if (!gExceptionHandler)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// store server URL with the API data
|
||||
if (aServerURL)
|
||||
AnnotateCrashReport(NS_LITERAL_CSTRING("ServerURL"),
|
||||
nsDependentCString(aServerURL));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
#include "nsStringGlue.h"
|
||||
|
||||
namespace CrashReporter {
|
||||
nsresult SetExceptionHandler(nsILocalFile* aXREDirectory);
|
||||
nsresult SetExceptionHandler(nsILocalFile* aXREDirectory,
|
||||
const char* aServerURL);
|
||||
nsresult SetMinidumpPath(const nsAString& aPath);
|
||||
nsresult UnsetExceptionHandler();
|
||||
nsresult AnnotateCrashReport(const nsACString &key, const nsACString &data);
|
||||
|
|
|
@ -63,7 +63,7 @@ char *
|
|||
test_init_exception_handler()
|
||||
{
|
||||
mu_assert("CrashReporter::SetExceptionHandler",
|
||||
CrashReporter::SetExceptionHandler(nsnull));
|
||||
CrashReporter::SetExceptionHandler(nsnull, nsnull));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче